Commit 896a9c92f806e2c0ff442c0deb0ff20b5a55c84c

Authored by hausdoerfer
1 parent 5a166841

persistence in common moved and imports adjusted

Showing 21 changed files with 55 additions and 54 deletions
services/Common/build.gradle
... ... @@ -9,6 +9,12 @@ dependencies {
9 9 compile "org.jboss.spec:jboss-javaee-7.0:1.1.0.Final",
10 10 "com.google.code.gson:gson:2.8.1",
11 11 "org.slf4j:slf4j-api:1.7.25"
  12 +
  13 + compile group: 'org.postgresql', name: 'postgresql', version: '9.3-1100-jdbc4'
  14 + compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
  15 +
  16 + compileOnly group: 'org.hibernate', name: 'hibernate-core', version: '5.2.12.Final'
  17 + compileOnly group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.6.Final'
12 18 }
13 19  
14 20 sourceCompatibility = 1.8
15 21 \ No newline at end of file
... ...
services/Common/src/main/java/de/bht/beuthbot/dataAccess/UserDAO.java renamed to services/Common/src/main/java/de/bht/beuthbot/daos/AppUserDAO.java
1   -package de.bht.beuthbot.dataAccess;
  1 +package de.bht.beuthbot.daos;
2 2  
3   -import de.bht.beuthbot.model.entities.User;
  3 +import de.bht.beuthbot.model.entities.AppUser;
4 4  
5 5 import javax.ejb.Remote;
6 6  
... ... @@ -8,7 +8,7 @@ import javax.ejb.Remote;
8 8 * Created by Benjamin Rühl on 19.12.2017.
9 9 */
10 10 @Remote
11   -public interface UserDAO extends GenericDAO<User, Long> {
  11 +public interface AppUserDAO extends GenericDAO<AppUser, Long> {
12 12  
13   - User createUser();
  13 + AppUser createUser();
14 14 }
... ...
services/Global/src/main/java/de/bht/beuthbot/daos/AppUserDAO.java renamed to services/Common/src/main/java/de/bht/beuthbot/daos/AppUserDAOImpl.java
1 1 package de.bht.beuthbot.daos;
2 2  
3   -import de.bht.beuthbot.dataAccess.UserDAO;
4   -import de.bht.beuthbot.entities.AppUser;
5   -import de.bht.beuthbot.model.entities.User;
  3 +import de.bht.beuthbot.model.entities.AppUserImpl;
  4 +import de.bht.beuthbot.model.entities.AppUser;
6 5  
7 6 import javax.ejb.Stateless;
8 7  
... ... @@ -10,10 +9,10 @@ import javax.ejb.Stateless;
10 9 * Created by Benjamin Rühl on 19.12.2017.
11 10 */
12 11 @Stateless
13   -public class AppUserDAO extends GenericHibernateDAO<User, AppUser, Long> implements UserDAO {
  12 +public class AppUserDAOImpl extends GenericHibernateDAO<AppUser, AppUserImpl, Long> implements AppUserDAO {
14 13  
15 14 @Override
16   - public User createUser() {
17   - return new AppUser();
  15 + public AppUser createUser() {
  16 + return new AppUserImpl();
18 17 }
19 18 }
... ...
services/Common/src/main/java/de/bht/beuthbot/dataAccess/GenericDAO.java renamed to services/Common/src/main/java/de/bht/beuthbot/daos/GenericDAO.java
1   -package de.bht.beuthbot.dataAccess;
  1 +package de.bht.beuthbot.daos;
2 2  
3   -import de.bht.beuthbot.model.entities.Entity;
  3 +import de.bht.beuthbot.model.entities.EntityBase;
4 4  
5 5 import javax.ejb.Remote;
6 6 import java.io.Serializable;
... ... @@ -10,7 +10,7 @@ import java.util.List;
10 10 * Created by Benjamin Rühl on 19.12.2017.
11 11 */
12 12 @Remote
13   -public interface GenericDAO<T extends Entity, ID extends Serializable> {
  13 +public interface GenericDAO<T extends EntityBase, ID extends Serializable> {
14 14  
15 15 T findById(ID id);
16 16  
... ...
services/Global/src/main/java/de/bht/beuthbot/daos/GenericHibernateDAO.java renamed to services/Common/src/main/java/de/bht/beuthbot/daos/GenericHibernateDAO.java
1 1 package de.bht.beuthbot.daos;
2 2  
3   -import de.bht.beuthbot.dataAccess.GenericDAO;
4   -import de.bht.beuthbot.model.entities.Entity;
5   -import org.hibernate.Session;
  3 +import de.bht.beuthbot.model.entities.EntityBase;
6 4  
7 5 import javax.annotation.PostConstruct;
8 6 import javax.ejb.Stateless;
... ... @@ -27,7 +25,7 @@ import java.util.List;
27 25 * @param <ID> Type of entity's primary id
28 26 */
29 27 @Stateless
30   -public class GenericHibernateDAO<I extends Entity, T extends I, ID extends Serializable> implements GenericDAO<I, ID> {
  28 +public class GenericHibernateDAO<I extends EntityBase, T extends I, ID extends Serializable> implements GenericDAO<I, ID> {
31 29  
32 30 private Class<T> entityClass;
33 31  
... ...
services/Common/src/main/java/de/bht/beuthbot/model/entities/User.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/AppUser.java
... ... @@ -3,9 +3,11 @@ package de.bht.beuthbot.model.entities;
3 3 /**
4 4 * Created by Benjamin Rühl on 19.11.2017.
5 5 */
6   -public interface User extends Entity {
  6 +public interface AppUser extends EntityBase {
7 7  
  8 + void setFacebookUserId(String facebookUserId);
8 9 String getFacebookUserId();
  10 + void setTelegramUserId(String telegramUserId);
9 11 String getTelegramUserId();
10 12 <T extends Object> T getProperty(String propertyName, Class<T> propertyType);
11 13 void setProperty(String propertyName, Object propertyValue);
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/AppUser.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/AppUserImpl.java
1   -package de.bht.beuthbot.entities;
  1 +package de.bht.beuthbot.model.entities;
2 2  
3 3 import de.bht.beuthbot.persistence.GenericEntityAccessFacade;
4   -import de.bht.beuthbot.persistence.GenericEntityJsonConverter;
5   -import de.bht.beuthbot.persistence.JsonHelper;
6 4  
7 5 import javax.persistence.CascadeType;
8 6 import javax.persistence.Entity;
9 7 import javax.persistence.OneToOne;
10 8 import javax.persistence.Table;
11   -import java.io.IOException;
12   -import java.util.List;
13   -import java.util.stream.Collectors;
14 9  
15 10 /**
16 11 * Created by Benjamin Rühl on 19.11.2017.
... ... @@ -19,7 +14,7 @@ import java.util.stream.Collectors;
19 14 */
20 15 @Entity
21 16 @Table
22   -public class AppUser extends EntityBase implements de.bht.beuthbot.model.entities.User {
  17 +public class AppUserImpl extends EntityBaseImpl implements AppUser {
23 18  
24 19 private String facebookUserId;
25 20  
... ... @@ -31,7 +26,7 @@ public class AppUser extends EntityBase implements de.bht.beuthbot.model.entitie
31 26 //@Type(type = "JsonMapType")
32 27 //private Map<String, String> additionalData = new HashMap<>();
33 28  
34   - public AppUser() {
  29 + public AppUserImpl() {
35 30 additionalData = new GenericEntity();
36 31 additionalData.setName("User");
37 32 }
... ...
services/Common/src/main/java/de/bht/beuthbot/model/entities/Entity.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/EntityBase.java
... ... @@ -6,7 +6,7 @@ import java.util.Date;
6 6 /**
7 7 * Created by Benjamin Rühl on 19.11.2017.
8 8 */
9   -public interface Entity extends Serializable {
  9 +public interface EntityBase extends Serializable {
10 10  
11 11 Long getId();
12 12  
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/EntityBase.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/EntityBaseImpl.java
1   -package de.bht.beuthbot.entities;
  1 +package de.bht.beuthbot.model.entities;
2 2  
3   -import de.bht.beuthbot.model.entities.Entity;
4 3 import de.bht.beuthbot.persistence.JsonMapUserType;
  4 +
5 5 import org.hibernate.annotations.TypeDef;
6 6  
7 7 import javax.persistence.*;
... ... @@ -14,7 +14,7 @@ import java.util.Objects;
14 14 @MappedSuperclass
15 15 @Access(AccessType.FIELD)
16 16 @TypeDef(name = "JsonMapType", typeClass = JsonMapUserType.class)
17   -public class EntityBase implements Entity {
  17 +public class EntityBaseImpl implements EntityBase {
18 18  
19 19 @Id
20 20 @GeneratedValue
... ... @@ -62,7 +62,7 @@ public class EntityBase implements Entity {
62 62 if (obj.getClass() != getClass())
63 63 return false;
64 64  
65   - EntityBase other = (EntityBase)obj;
  65 + EntityBaseImpl other = (EntityBaseImpl)obj;
66 66  
67 67 if (other.getId() == 0 && getId() == 0)
68 68 return super.equals(obj);
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/GenericEntity.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/GenericEntity.java
1   -package de.bht.beuthbot.entities;
  1 +package de.bht.beuthbot.model.entities;
2 2  
3 3 import javax.persistence.CascadeType;
4 4 import javax.persistence.Entity;
... ... @@ -15,7 +15,7 @@ import java.util.stream.Collectors;
15 15 */
16 16 @Entity
17 17 @Table
18   -public class GenericEntity extends EntityBase {
  18 +public class GenericEntity extends EntityBaseImpl {
19 19  
20 20 /**
21 21 * name is not mandatory, but can help to identify the entity's purpose for the developer
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/GenericEntityAttribute.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/GenericEntityAttribute.java
1   -package de.bht.beuthbot.entities;
  1 +package de.bht.beuthbot.model.entities;
2 2  
3 3 import javax.persistence.CascadeType;
4 4 import javax.persistence.Entity;
... ... @@ -13,7 +13,7 @@ import java.util.List;
13 13 */
14 14 @Entity
15 15 @Table
16   -public class GenericEntityAttribute extends EntityBase {
  16 +public class GenericEntityAttribute extends EntityBaseImpl {
17 17  
18 18 private String name;
19 19  
... ...
services/Global/src/main/java/de/bht/beuthbot/entities/GenericEntityAttributeValue.java renamed to services/Common/src/main/java/de/bht/beuthbot/model/entities/GenericEntityAttributeValue.java
1   -package de.bht.beuthbot.entities;
  1 +package de.bht.beuthbot.model.entities;
2 2  
3   -import javax.persistence.*;
  3 +import javax.persistence.CascadeType;
  4 +import javax.persistence.Entity;
  5 +import javax.persistence.OneToOne;
  6 +import javax.persistence.Table;
4 7  
5 8 /**
6 9 * Created by Benjamin Rühl on 22.12.2017.
... ... @@ -9,7 +12,7 @@ import javax.persistence.*;
9 12 */
10 13 @Entity
11 14 @Table
12   -public class GenericEntityAttributeValue extends EntityBase {
  15 +public class GenericEntityAttributeValue extends EntityBaseImpl {
13 16  
14 17 private Boolean valueAsBool;
15 18  
... ...
services/Global/src/main/java/de/bht/beuthbot/persistence/ExtendedPostgreSQLDialect.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/ExtendedPostgreSQLDialect.java
services/Global/src/main/java/de/bht/beuthbot/persistence/GenericEntityAccessFacade.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/GenericEntityAccessFacade.java
... ... @@ -2,8 +2,9 @@ package de.bht.beuthbot.persistence;
2 2  
3 3 import com.fasterxml.jackson.databind.ObjectMapper;
4 4 import com.fasterxml.jackson.databind.module.SimpleModule;
5   -import de.bht.beuthbot.entities.GenericEntity;
6   -import de.bht.beuthbot.entities.GenericEntityAttribute;
  5 +
  6 +import de.bht.beuthbot.model.entities.GenericEntity;
  7 +import de.bht.beuthbot.model.entities.GenericEntityAttribute;
7 8  
8 9 import java.io.IOException;
9 10 import java.util.List;
... ...
services/Global/src/main/java/de/bht/beuthbot/persistence/GenericEntityAttributeDeserializer.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/GenericEntityAttributeDeserializer.java
... ... @@ -5,9 +5,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
5 5 import com.fasterxml.jackson.core.JsonToken;
6 6 import com.fasterxml.jackson.databind.DeserializationContext;
7 7 import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
8   -import de.bht.beuthbot.entities.GenericEntity;
9   -import de.bht.beuthbot.entities.GenericEntityAttribute;
10   -import de.bht.beuthbot.entities.GenericEntityAttributeValue;
  8 +
  9 +import de.bht.beuthbot.model.entities.GenericEntity;
  10 +import de.bht.beuthbot.model.entities.GenericEntityAttribute;
  11 +import de.bht.beuthbot.model.entities.GenericEntityAttributeValue;
11 12  
12 13 import javax.naming.OperationNotSupportedException;
13 14 import java.io.IOException;
... ...
services/Global/src/main/java/de/bht/beuthbot/persistence/GenericEntityDeserializer.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/GenericEntityDeserializer.java
... ... @@ -5,8 +5,9 @@ import com.fasterxml.jackson.core.JsonProcessingException;
5 5 import com.fasterxml.jackson.core.JsonToken;
6 6 import com.fasterxml.jackson.databind.DeserializationContext;
7 7 import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
8   -import de.bht.beuthbot.entities.GenericEntity;
9   -import de.bht.beuthbot.entities.GenericEntityAttribute;
  8 +
  9 +import de.bht.beuthbot.model.entities.GenericEntity;
  10 +import de.bht.beuthbot.model.entities.GenericEntityAttribute;
10 11  
11 12 import java.io.IOException;
12 13  
... ...
services/Global/src/main/java/de/bht/beuthbot/persistence/GenericEntityJsonConverter.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/GenericEntityJsonConverter.java
... ... @@ -2,9 +2,10 @@ package de.bht.beuthbot.persistence;
2 2  
3 3 import com.fasterxml.jackson.core.JsonFactory;
4 4 import com.fasterxml.jackson.core.JsonGenerator;
5   -import de.bht.beuthbot.entities.GenericEntity;
6   -import de.bht.beuthbot.entities.GenericEntityAttribute;
7   -import de.bht.beuthbot.entities.GenericEntityAttributeValue;
  5 +
  6 +import de.bht.beuthbot.model.entities.GenericEntity;
  7 +import de.bht.beuthbot.model.entities.GenericEntityAttribute;
  8 +import de.bht.beuthbot.model.entities.GenericEntityAttributeValue;
8 9  
9 10 import java.io.IOException;
10 11 import java.io.StringWriter;
... ...
services/Global/src/main/java/de/bht/beuthbot/persistence/JsonHelper.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/JsonHelper.java
services/Global/src/main/java/de/bht/beuthbot/persistence/JsonMapUserType.java renamed to services/Common/src/main/java/de/bht/beuthbot/persistence/JsonMapUserType.java
services/Global/src/main/resources/META-INF/persistence.xml renamed to services/Common/src/main/resources/META-INF/persistence.xml
services/Global/build.gradle
... ... @@ -13,14 +13,8 @@ dependencies {
13 13 "org.apache.httpcomponents:httpclient:4.5.3",
14 14 "commons-io:commons-io:2.5"
15 15  
16   - compile group: 'org.postgresql', name: 'postgresql', version: '9.3-1100-jdbc4'
17   - compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
18   -
19 16 providedCompile "org.slf4j:slf4j-api:1.7.25"
20 17  
21   - compileOnly group: 'org.hibernate', name: 'hibernate-core', version: '5.2.12.Final'
22   - compileOnly group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.6.Final'
23   -
24 18 testCompile "org.jboss.arquillian.junit:arquillian-junit-container:1.1.13.Final",
25 19 "junit:junit:4.12"
26 20  
... ...