diff --git a/IRCT-API/pom.xml b/IRCT-API/pom.xml index b7e5cbcd..acc7184b 100644 --- a/IRCT-API/pom.xml +++ b/IRCT-API/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 edu.harvard.hms.dbmi.bd2k.irct @@ -7,6 +8,13 @@ IRCT-API INTER-RESOURCE COMMUNICATION TOOL : API + + + 3.5.3 + 1.7 + 5.1.45 + + @@ -63,59 +71,87 @@ org.apache.httpcomponents httpclient - - src/main/java - - src/main/resources - true - - + + src/main/resources + true + + IRCT-API - - - org.apache.maven.plugins - maven-eclipse-plugin - - true - true - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - package - - copy-dependencies - - - runtime - ${project.build.directory}/dependency-jars/ - - - - - + + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + true + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.version} + ${maven.compiler.version} + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + runtime + ${project.build.directory}/dependency-jars/ + + + + + + org.liquibase + liquibase-maven-plugin + ${liquibase.version} + + true + edu/harvard/hms/dbmi/bd2k/irct/db/liquibase.properties + edu/harvard/hms/dbmi/bd2k/irct/db/changelog-master.xml + false + + + + process-resources + + update + + + + + + + + mysql + mysql-connector-java + ${mysql-version} + + + + + diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/event/EventConverterImplementation.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/event/EventConverterImplementation.java index bb3f48bc..e9d55f54 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/event/EventConverterImplementation.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/event/EventConverterImplementation.java @@ -13,6 +13,7 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.MapKeyColumn; @@ -31,7 +32,7 @@ public class EventConverterImplementation implements Serializable { private static final long serialVersionUID = -8700481468758389000L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/IRCTJoin.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/IRCTJoin.java index 53629c71..7b7f00a1 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/IRCTJoin.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/IRCTJoin.java @@ -14,10 +14,10 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; -import edu.harvard.hms.dbmi.bd2k.irct.model.join.JoinImplementation; import edu.harvard.hms.dbmi.bd2k.irct.model.resource.Field; import edu.harvard.hms.dbmi.bd2k.irct.util.converter.JoinImplementationConverter; @@ -34,7 +34,7 @@ public class IRCTJoin implements Serializable { private static final long serialVersionUID = 5173414123049320818L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/Join.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/Join.java index 685bd683..e63548b1 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/Join.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/join/Join.java @@ -7,34 +7,25 @@ import java.util.HashMap; import java.util.Map; -import javax.persistence.CollectionTable; -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.MapKeyColumn; import javax.persistence.Transient; -@Entity +//@Entity public class Join implements Serializable { private static final long serialVersionUID = 4869490865776072674L; - @Id - @GeneratedValue +// @Id +// @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private JoinImplementation joinImplementation; private IRCTJoin joinType; - @ElementCollection(fetch = FetchType.EAGER) - @MapKeyColumn(name = "name") - @Column(name = "value") - @CollectionTable(name = "where_values", joinColumns = @JoinColumn(name = "where_id")) +// @ElementCollection(fetch = FetchType.EAGER) +// @MapKeyColumn(name = "name") +// @Column(name = "value") +// @CollectionTable(name = "where_values", joinColumns = @JoinColumn(name = "where_id")) private Map stringValues; @Transient diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/ontology/Entity.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/ontology/Entity.java index b2028ec0..c0b4f046 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/ontology/Entity.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/ontology/Entity.java @@ -12,6 +12,7 @@ import javax.json.JsonObjectBuilder; import javax.persistence.Convert; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Transient; import java.util.ArrayList; @@ -31,7 +32,7 @@ public class Entity { @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String pui; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/process/IRCTProcess.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/process/IRCTProcess.java index aba2a297..53940e0e 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/process/IRCTProcess.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/process/IRCTProcess.java @@ -14,6 +14,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -35,7 +36,7 @@ public class IRCTProcess implements Serializable { private static final long serialVersionUID = -1805899138692864630L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/ClauseAbstract.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/ClauseAbstract.java index 8c1d9b58..e9b22f56 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/ClauseAbstract.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/ClauseAbstract.java @@ -8,6 +8,7 @@ import javax.json.JsonObjectBuilder; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; /** @@ -21,7 +22,7 @@ public abstract class ClauseAbstract { @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; /** diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/JoinType.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/JoinType.java index ce7a2d73..4380a25b 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/JoinType.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/JoinType.java @@ -15,6 +15,7 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; @@ -30,7 +31,7 @@ public class JoinType implements Serializable { private static final long serialVersionUID = 7650772906469344618L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/PredicateType.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/PredicateType.java index eff74176..af28d57e 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/PredicateType.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/PredicateType.java @@ -14,6 +14,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; @@ -36,7 +37,7 @@ public class PredicateType implements Serializable { private static final long serialVersionUID = -8767223525164395205L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/Query.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/Query.java index 92832019..723dbb73 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/Query.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/Query.java @@ -9,6 +9,7 @@ import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; + import javax.persistence.*; import java.io.Serializable; import java.util.*; @@ -22,12 +23,12 @@ * */ @Entity -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Inheritance(strategy = InheritanceType.JOINED) public class Query implements Serializable { private static final long serialVersionUID = -407606258205399129L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String name; @@ -133,6 +134,7 @@ public String toString() { + where; } + @SuppressWarnings("unchecked") public List getClausesOfType( Class clauseType) { List returns = new ArrayList(); @@ -218,7 +220,7 @@ public final SubQuery getSubQuery(String id) { * SubQuery ID */ public final void removeSubQuery(Long id) { - this.subQueries.remove(id); + this.subQueries.remove(Long.toString(id)); } /** diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SelectOperationType.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SelectOperationType.java index 79cf7505..56509d72 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SelectOperationType.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SelectOperationType.java @@ -14,6 +14,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; @@ -36,7 +37,7 @@ public class SelectOperationType implements Serializable { private static final long serialVersionUID = -2715703805087374126L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SortOperationType.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SortOperationType.java index 2ce60549..bc137a7f 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SortOperationType.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/query/SortOperationType.java @@ -16,6 +16,7 @@ import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany; @@ -38,7 +39,7 @@ public class SortOperationType implements Serializable { private static final long serialVersionUID = -2715703805087374126L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Field.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Field.java index 58661667..574cd6dd 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Field.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Field.java @@ -14,6 +14,7 @@ import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -36,7 +37,7 @@ public class Field implements Serializable { private static final long serialVersionUID = -2150406406694041615L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String name; diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Resource.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Resource.java index 0c9d8dd9..367817d2 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Resource.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/resource/Resource.java @@ -6,8 +6,6 @@ import java.io.Serializable; import java.util.List; import java.util.Map; -import java.util.logging.Logger; - import javax.persistence.*; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -27,7 +25,6 @@ import edu.harvard.hms.dbmi.bd2k.irct.util.converter.DataTypeConverter; import edu.harvard.hms.dbmi.bd2k.irct.util.converter.OntologyRelationshipConverter; import edu.harvard.hms.dbmi.bd2k.irct.util.converter.ResourceImplementationConverter; -import org.apache.commons.logging.impl.Log4JLogger; /** * The resource class provides a way for the IRCT application to keep track of @@ -38,7 +35,7 @@ public class Resource implements Serializable { private static final long serialVersionUID = 8099637983212553759L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Column(unique = true) diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/DataConverterImplementation.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/DataConverterImplementation.java index 24b26971..f5db0161 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/DataConverterImplementation.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/DataConverterImplementation.java @@ -10,6 +10,7 @@ import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import edu.harvard.hms.dbmi.bd2k.irct.dataconverter.ResultDataConverter; @@ -28,7 +29,7 @@ public class DataConverterImplementation implements Serializable { private static final long serialVersionUID = -8700481468758389000L; @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; @Enumerated(EnumType.STRING) diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/Result.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/Result.java index 2ffb819f..bb6c5491 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/Result.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/result/Result.java @@ -4,7 +4,6 @@ package edu.harvard.hms.dbmi.bd2k.irct.model.result; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import edu.harvard.hms.dbmi.bd2k.irct.executable.Executable; import edu.harvard.hms.dbmi.bd2k.irct.model.security.User; import edu.harvard.hms.dbmi.bd2k.irct.util.converter.DataConverter; @@ -31,9 +30,8 @@ @Entity public class Result { @Id - @GeneratedValue(generator = "resultSequencer") - @SequenceGenerator(name = "resultSequencer", sequenceName = "resSeq") - @JsonProperty("resultId") + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Long id; @Transient diff --git a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/security/User.java b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/security/User.java index 935600bd..88721dd5 100644 --- a/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/security/User.java +++ b/IRCT-API/src/main/java/edu/harvard/hms/dbmi/bd2k/irct/model/security/User.java @@ -8,7 +8,6 @@ import javax.persistence.*; import java.io.Serializable; import java.security.Principal; - /** * A basic user representation. It can be associated with a session in EE 7. The * userId, and name are the same in this implementation. @@ -19,8 +18,7 @@ public class User implements Principal, Serializable { private static final long serialVersionUID = 225027371671010450L; @Id - @GeneratedValue(generator = "userSequencer") - @SequenceGenerator(name = "userSequencer", sequenceName = "userSeq") + @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; private String userId; diff --git a/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/changelog-master.xml b/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/changelog-master.xml new file mode 100755 index 00000000..ca09de94 --- /dev/null +++ b/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/changelog-master.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/changelogs/changelog-0.1.0.xml b/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/changelogs/changelog-0.1.0.xml new file mode 100755 index 00000000..eaf72be2 --- /dev/null +++ b/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/changelogs/changelog-0.1.0.xml @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + alter table `irct`.`EventConverterImplementation` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + + + + + + + + + alter table `irct`.`IRCTJoin` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + + + + + + + + + + + alter table `irct`.`Entity` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + + + + + + + + + alter table `irct`.`IRCTProcess` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + alter table `irct`.`Result` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + + + + + + + alter table `irct`.`User` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + + + + + insert into Query (id, name, payload) + select id, name, payload + from SubQuery + + + + + + + + + + + + + + + + + + + + + + + + + + alter table `irct`.`Token` change column `id` `id` BIGINT(20) not null + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/liquibase.properties b/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/liquibase.properties new file mode 100755 index 00000000..d6e99414 --- /dev/null +++ b/IRCT-API/src/main/resources/edu/harvard/hms/dbmi/bd2k/irct/db/liquibase.properties @@ -0,0 +1,8 @@ +#Liquibase.properties +#driver: already specified in maven -> liquibase plugin -> dependencies +#changeLogFile: already specified in maven +url: jdbc:mysql://localhost:3306/irct?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true +username: root +password: root +verbose: true +dropFirst: false \ No newline at end of file diff --git a/IRCT-API/src/test/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTBaseTest.java b/IRCT-API/src/test/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTBaseTest.java new file mode 100755 index 00000000..d94e3e26 --- /dev/null +++ b/IRCT-API/src/test/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTBaseTest.java @@ -0,0 +1,62 @@ +/** + * + */ +package edu.harvard.hms.dbmi.bd2k.irct; +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; + +/** + * @author Yu + * + */ +public class IRCTBaseTest { + + private static final EntityManagerFactory emf ; + private static final ThreadLocal threadLocal; + EntityManager em; + + static { + emf = Persistence.createEntityManagerFactory("primary"); + threadLocal = new ThreadLocal(); + } + + public static EntityManager getEntityManager() { + EntityManager em = threadLocal.get(); + + if (em == null) { + em = emf.createEntityManager(); + // set your flush mode here + threadLocal.set(em); + } + return em; + } + + public static void closeEntityManager() { + EntityManager em = threadLocal.get(); + if (em != null) { + em.close(); + threadLocal.set(null); + } + } + + public static void closeEntityManagerFactory() { + emf.close(); + } + + public static void beginTransaction() { + getEntityManager().getTransaction().begin(); + } + + public static void rollback() { + getEntityManager().getTransaction().rollback(); + } + + public static void commit() { + getEntityManager().getTransaction().commit(); + } + + + + +} diff --git a/IRCT-API/src/test/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTQueryTest.java b/IRCT-API/src/test/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTQueryTest.java new file mode 100755 index 00000000..f1695936 --- /dev/null +++ b/IRCT-API/src/test/java/edu/harvard/hms/dbmi/bd2k/irct/IRCTQueryTest.java @@ -0,0 +1,43 @@ +package edu.harvard.hms.dbmi.bd2k.irct; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import edu.harvard.hms.dbmi.bd2k.irct.model.query.Query; +import edu.harvard.hms.dbmi.bd2k.irct.model.query.SubQuery; + +public class IRCTQueryTest extends IRCTBaseTest{ + + +// @Before +// public void before() { +// em = getEntityManager(); +// } +// +// @Test +// public void test() { +// em.getTransaction().begin(); +// Query query = new Query(); +// query.setId(2999l); +// query.setName("parent test query"); +// query.setPayload(" "); +// +// SubQuery sq = new SubQuery(); +// sq.setId(3111l); +// sq.setName("sub query test"); +// sq.setPayload(" "); +// query.getSubQueries().put(Long.toString(sq.getId()), sq); +// +// +// em.getTransaction().commit(); +// } +// +// @After +// public void after() { +// closeEntityManager(); +// } + +} diff --git a/IRCT-CL/src/main/resources/META-INF/persistence.xml b/IRCT-CL/src/main/resources/META-INF/persistence.xml index d997aa45..7661521d 100644 --- a/IRCT-CL/src/main/resources/META-INF/persistence.xml +++ b/IRCT-CL/src/main/resources/META-INF/persistence.xml @@ -47,6 +47,7 @@ +