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