diff --git a/cust-services/.externalToolBuilders/OpenJPAEnhancer.launch b/cust-services/.externalToolBuilders/OpenJPAEnhancer.launch
new file mode 100644
index 0000000..7361208
--- /dev/null
+++ b/cust-services/.externalToolBuilders/OpenJPAEnhancer.launch
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cust-services/builder_project/enhance.xml b/cust-services/builder_project/enhance.xml
new file mode 100644
index 0000000..b324fbb
--- /dev/null
+++ b/cust-services/builder_project/enhance.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cust-services/derby.log b/cust-services/derby.log
new file mode 100644
index 0000000..c026fcf
--- /dev/null
+++ b/cust-services/derby.log
@@ -0,0 +1,13 @@
+----------------------------------------------------------------
+Wed Apr 12 17:45:24 CEST 2017:
+Booting Derby version The Apache Software Foundation - Apache Derby - 10.13.1.1 - (1765088): instance a816c00e-015b-62d7-3c87-00000d85f220
+on database directory /home/mi/Projekte/Hostsharing/hs.hsadmin.jee-all/cust-services/hsadmin-test-db/derbydb3 with class loader sun.misc.Launcher$AppClassLoader@372f7a8d
+Loaded from file:/home/mi/.m2/repository/org/apache/derby/derby/10.13.1.1/derby-10.13.1.1.jar
+java.vendor=Oracle Corporation
+java.runtime.version=1.8.0_121-8u121-b13-0ubuntu1.16.04.2-b13
+user.dir=/home/mi/Projekte/Hostsharing/hs.hsadmin.jee-all/cust-services
+os.name=Linux
+os.arch=amd64
+os.version=4.4.0-72-generic
+derby.system.home=null
+Database Class Loader started - derby.database.classpath=''
diff --git a/cust-services/pom.xml b/cust-services/pom.xml
index 297f2f8..c92f904 100644
--- a/cust-services/pom.xml
+++ b/cust-services/pom.xml
@@ -40,6 +40,40 @@
0.5
test
+
+ org.apache.openjpa
+ openjpa
+ 2.4.2
+ test
+
+
+
+ com.h2database
+ h2
+ 1.4.194
+ test
+
+
+
+ org.liquibase
+ liquibase-core
+ 3.5.3
+ test
+
org.apache.xmlrpc
xmlrpc-server
@@ -55,13 +89,16 @@
+ org.apache.maven.plugins
maven-war-plugin
+ 3.0.0
true
org.apache.maven.plugins
+ 3.0.2
maven-jar-plugin
@@ -100,6 +137,27 @@
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.6.0
+
+
+ migratePostgresLiquibaseChangeLogToH2
+ generate-sources
+
+ exec
+
+
+ ${project.basedir}/scripts/migratePostgresLiquibaseChangeLogToH2.${script.extension}
+
+ ${project.parent.basedir}/db-migration/src/main/resources/liquibase/db.changelog.xml
+ ${project.build.directory}/classes/liquibase/db.changelog.xml
+
+
+
+
+
org.apache.openejb.maven
tomee-maven-plugin
@@ -115,6 +173,34 @@
+
+ org.apache.openjpa
+ openjpa-maven-plugin
+ 2.4.2
+
+ **/bo/*.class
+ true
+ true
+
+
+
+ enhancer
+ process-classes
+
+ enhance
+
+
+
+
+
+ org.apache.openjpa
+ openjpa
+
+ 2.4.2
+ compile
+
+
+
diff --git a/cust-services/scripts/migratePostgresLiquibaseChangeLogToH2.sh b/cust-services/scripts/migratePostgresLiquibaseChangeLogToH2.sh
new file mode 100755
index 0000000..c06c1e1
--- /dev/null
+++ b/cust-services/scripts/migratePostgresLiquibaseChangeLogToH2.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+mkdir -p $(dirname "$2")
+sed \
+ -e's/ deferrable="[a-z]*" initiallyDeferred="[a-z]*"//' \
+ -e's/ type="INET"/ type="VARCHAR(19)"/' \
+ -e'/generated.69/,+5d' \
+ <"$1" >"$2"
+
+# -e'/changeset.* id="generated-69"/,+5d' \
diff --git a/cust-services/src/main/java/de/hsadmin/bo/customer/Customer.java b/cust-services/src/main/java/de/hsadmin/bo/customer/Customer.java
index 007ba92..2bdbf62 100644
--- a/cust-services/src/main/java/de/hsadmin/bo/customer/Customer.java
+++ b/cust-services/src/main/java/de/hsadmin/bo/customer/Customer.java
@@ -97,6 +97,9 @@ public class Customer implements Serializable {
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
@OrderBy("name")
private Set pacs;
+
+ @Column(name = "shares_signed", columnDefinition = "integer")
+ private int sharesSigned;
public Customer() {
contacts = new HashSet<>();
@@ -252,5 +255,9 @@ public class Customer implements Serializable {
public void setSepaDirectDebits(final Set sepaDirectDebits) {
this.sepaDirectDebits = sepaDirectDebits;
}
+
+ public void setSharesSigned(int sharesSigned) {
+ this.sharesSigned = sharesSigned;
+ }
}
diff --git a/cust-services/src/main/java/de/hsadmin/dao/customer/CustomerDao.java b/cust-services/src/main/java/de/hsadmin/dao/customer/CustomerDao.java
index e90c76b..c024884 100644
--- a/cust-services/src/main/java/de/hsadmin/dao/customer/CustomerDao.java
+++ b/cust-services/src/main/java/de/hsadmin/dao/customer/CustomerDao.java
@@ -16,6 +16,13 @@ public class CustomerDao {
@PersistenceContext(name="hsar")
private EntityManager entityManager;
+ public CustomerDao() {
+ }
+
+ public CustomerDao(EntityManager em) {
+ this.entityManager = em;
+ }
+
public Customer findCustomerByName(final String customerName) throws UserException {
return findCustomerByNameImpl(customerName);
}
diff --git a/cust-services/src/test/java/de/hsadmin/dao/customer/CustomerDaoTest.java b/cust-services/src/test/java/de/hsadmin/dao/customer/CustomerDaoTest.java
new file mode 100644
index 0000000..980f855
--- /dev/null
+++ b/cust-services/src/test/java/de/hsadmin/dao/customer/CustomerDaoTest.java
@@ -0,0 +1,36 @@
+package de.hsadmin.dao.customer;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import de.hsadmin.bo.customer.Customer;
+import de.hsadmin.common.error.UserException;
+import de.hsadmin.test.JpaBasedTest;
+
+public class CustomerDaoTest extends JpaBasedTest {
+
+ private CustomerDao customerDao;
+
+ @Before
+ public void init() {
+ customerDao = new CustomerDao(getEM());
+ }
+
+ @Test
+ public void findCustomerByName() throws UserException {
+ Customer newCustomer = store(createNewCustomer(100001, "test"));
+
+ Customer foundCustomer = customerDao.findCustomerByName(newCustomer.getName());
+ assertEquals(newCustomer.getId(), foundCustomer.getId());
+ }
+
+ private Customer createNewCustomer(int memberNo, String memberCode) {
+ Customer newCustomer = new Customer();
+ newCustomer.setMemberNo(memberNo);
+ newCustomer.setName(memberCode);
+ newCustomer.setSharesSigned(5);
+ return newCustomer;
+ }
+}
diff --git a/cust-services/src/test/java/de/hsadmin/test/JpaBasedTest.java b/cust-services/src/test/java/de/hsadmin/test/JpaBasedTest.java
new file mode 100644
index 0000000..8eaad47
--- /dev/null
+++ b/cust-services/src/test/java/de/hsadmin/test/JpaBasedTest.java
@@ -0,0 +1,77 @@
+package de.hsadmin.test;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+
+import liquibase.Liquibase;
+import liquibase.database.Database;
+import liquibase.database.DatabaseFactory;
+import liquibase.database.jvm.JdbcConnection;
+import liquibase.resource.ClassLoaderResourceAccessor;
+
+public abstract class JpaBasedTest {
+
+ private static final String UNIT_NAME = "HSADMIN_H2_TEST_DB";
+
+ private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory(UNIT_NAME);
+
+ private EntityManager em;
+
+ @BeforeClass
+ public static void setupDatabase() throws Exception {
+ EntityManager em = emf.createEntityManager();
+ java.sql.Connection connection = em.unwrap(java.sql.Connection.class);
+ em.getTransaction().begin();
+ try {
+ Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
+ Liquibase liquibase = new Liquibase("liquibase/db.changelog.xml", new ClassLoaderResourceAccessor(), database);
+ liquibase.update("test");
+ } finally {
+ em.getTransaction().commit();
+ }
+ }
+
+ @Before
+ public void startTransaction() {
+ em = emf.createEntityManager();
+ em.getTransaction().begin();
+ }
+
+ @After
+ public void rollbacktransaction() {
+ // make sure constraint violations are found
+ em.flush();
+
+ // but rollback the transaction
+ try {
+ EntityTransaction transaction = em.getTransaction();
+ if ( transaction.isActive() ) {
+ em.getTransaction().rollback();
+ }
+ } finally {
+ // and close the EntityManager
+ if (em.isOpen()) {
+ em.close();
+ }
+ }
+ }
+
+ public EntityManager getEM() {
+ return em;
+ }
+
+
+
+ public T store(T newEntity) {
+ getEM().persist(newEntity);
+ getEM().flush();
+ getEM().clear();
+ return newEntity;
+ }
+}
diff --git a/cust-services/src/test/resources/META-INF/persistence.xml b/cust-services/src/test/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..21a0ff5
--- /dev/null
+++ b/cust-services/src/test/resources/META-INF/persistence.xml
@@ -0,0 +1,36 @@
+
+
+
+ org.apache.openjpa.persistence.PersistenceProviderImpl
+
+ de.hsadmin.bo.customer.Customer
+ de.hsadmin.bo.customer.Contact
+ de.hsadmin.bo.customer.SEPADirectDebit
+ de.hsadmin.bo.pac.Pac
+ de.hsadmin.bo.pac.PacComponent
+ de.hsadmin.bo.pac.UnixUser
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/framework/pom.xml b/framework/pom.xml
index bbe0b37..7d2739a 100644
--- a/framework/pom.xml
+++ b/framework/pom.xml
@@ -66,6 +66,40 @@
joda-time
2.9.9
+
+
+ com.h2database
+ h2
+ 1.4.194
+ test
+
+
+
+ org.apache.openjpa
+ openjpa
+ 2.4.2
+ test
+
+
+ org.liquibase
+ liquibase-core
+ 3.5.3
+ test
+
diff --git a/pom.xml b/pom.xml
index eb99e12..754efe0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,9 @@
org.apache.maven.plugins
maven-surefire-plugin
2.19.1
+
+ -XX:+AlwaysLockClassLoader
+
@@ -55,4 +58,30 @@
test
+
+
+
+ Windows
+
+
+ Windows
+
+
+
+ bat
+
+
+
+ unix
+
+
+ unix
+
+
+
+ sh
+
+
+
+