From 28df4f0abe672ee8f01b7e3334355da5a8f3c997 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Wed, 22 Dec 2021 12:00:47 -0500 Subject: [PATCH 01/10] Update all dependencies Use pavlab-starter-parent to manage common dependencies with other Pavlidis Lab projects. Add missing and entries in pom.xml. Use Hibernate 3.6.10.Final and remove ehcache dependency since we don't use it directly (it is still imported through hibernate-ehcache). Use gsec 0.0.7 and update context configuration loading accordingly. Use commons-pool2 and modify data source configurations accordingly. --- aspiredb/pom.xml | 174 ++++++++---------- .../aspiredb/cli/SpringContextUtil.java | 2 +- .../main/resources/production-data-source.xml | 126 ++++++------- aspiredb/src/main/webapp/WEB-INF/web.xml | 2 +- .../server/BaseSpringContextTest.java | 2 +- .../src/test/resources/test-data-source.xml | 50 ++--- 6 files changed, 140 insertions(+), 216 deletions(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index f46fd296..b6339d10 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -3,21 +3,25 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - aspiredb project + ASPIREdb Project ubc.pavlab aspiredb war 1.5-SNAPSHOT - - UTF-8 - 1.7 - 1.7 + + ubc.pavlab + pavlab-starter-parent + 1.0 + + UTF-8 - 3.2.4.RELEASE - 3.1.4.RELEASE - + 1.8 + 1.8 + 3.2.18.RELEASE + 3.2.10.RELEASE + 0.0.7 @@ -29,9 +33,13 @@ + scm:git:https://github.com/PavlidisLab/aspiredb.git + scm:git:git@github.com:PavlidisLab/aspiredb.git + GitHub + https://github.com/PavlidisLab/aspiredb/issues @@ -39,45 +47,34 @@ baseCode baseCode - 1.1.2 - jar pavlab gemma-gsec - 0.0.1-SNAPSHOT - jar + ${gsec.version} - - org.directwebremoting - dwr - 3.0.2-RELEASE - jar + + org.directwebremoting + dwr + 3.0.2-RELEASE junit junit - 4.7 - test - jar org.easymock easymock - 3.2 + 4.3 test - jar org.mockito - mockito-all - 1.10.19 - test - jar + mockito-core org.springframework @@ -90,19 +87,19 @@ 1.13 - commons-lang - commons-lang - 2.6 + org.apache.commons + commons-lang3 + 3.12.0 commons-beanutils commons-beanutils - 1.8.3 + 1.9.4 commons-fileupload commons-fileupload - 1.3.1 + 1.4 org.apache.commons @@ -118,7 +115,6 @@ org.springframework spring-core ${spring.version} - jar org.springframework @@ -149,7 +145,6 @@ org.springframework spring-beans ${spring.version} - jar org.springframework @@ -188,89 +183,67 @@ ${spring.version} - commons-dbcp - commons-dbcp - 1.4 + org.apache.commons + commons-dbcp2 org.aspectj aspectjrt - 1.6.6 - jar + 1.9.7 org.aspectj aspectjweaver - 1.6.6 - jar + 1.9.7 runtime org.hibernate hibernate-core - 3.6.3.Final org.hibernate hibernate-ehcache - 3.6.7.Final - - - net.sf.ehcache - ehache-core - - - - - net.sf.ehcache - ehcache-core - 2.6.6 javassist javassist - 3.4.GA + 3.12.1.GA runtime - jar org.hibernate hibernate-validator - 4.2.0.Final + 4.3.2.Final javax.validation validation-api - 1.0.0.GA + 2.0.1.Final mysql mysql-connector-java - 5.1.9 org.apache.logging.log4j log4j-core - 2.17.0 org.apache.logging.log4j log4j-1.2-api - 2.17.0 org.slf4j slf4j-api - 1.6.6 - jar commons-cli commons-cli - 1.2 + 1.5.0 net.sourceforge.csvjdbc @@ -280,7 +253,7 @@ com.sencha.gxt gxt - 3.0.1 + 3.1.1 javax.servlet @@ -295,12 +268,11 @@ com.google.gwt gwt-servlet - 2.5.1 + 2.9.0 javax.servlet - servlet-api - 2.4 + javax.servlet-api @@ -311,8 +283,8 @@ javax.mail - mail - 1.4.7 + javax.mail-api + 1.6.2 @@ -340,27 +312,27 @@ maven-surefire-plugin - 2.12 - - -enableassertions -Xmx512m -Djava.awt.headless=true -Dlog4j.compatibility=true - target/surefire-reports - true - - **/Test*.java - **/*Test.java - - - **/AllTests.java - **/gui/Test*.java - **/AbstractTest*.java - **/*$* - - + 2.22.2 + + -enableassertions -Xmx512m -Djava.awt.headless=true -Dlog4j.compatibility=true + target/surefire-reports + true + + **/Test*.java + **/*Test.java + + + **/AllTests.java + **/gui/Test*.java + **/AbstractTest*.java + **/*$* + + org.apache.maven.plugins maven-eclipse-plugin - 2.8 + 2.10 true false @@ -381,7 +353,7 @@ org.codehaus.mojo hibernate3-maven-plugin - 2.2 + 3.0 default-cli @@ -412,7 +384,7 @@ org.apache.maven.plugins maven-jar-plugin - 2.4 + 3.2.0 package @@ -426,7 +398,7 @@ org.apache.maven.plugins maven-antrun-plugin - 1.7 + 3.0.0 version-file @@ -448,7 +420,7 @@ org.codehaus.mojo cobertura-maven-plugin - 2.6 + 2.7 true @@ -461,7 +433,7 @@ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes - org.eclipse.m2e @@ -506,7 +478,7 @@ maven-dependency-plugin - 2.8 + 3.2.0 process-resources @@ -518,8 +490,7 @@ pavlab gemma-gsec - 0.0.1-SNAPSHOT - jar + ${gsec.version} true ${project.build.directory}/schema **/*.sql @@ -537,8 +508,8 @@ mysql mysql-connector-java - 5.1.10 - jar + + 8.0.27 @@ -606,7 +577,7 @@ maven-dependency-plugin - 2.8 + 3.2.0 process-resources @@ -618,8 +589,7 @@ pavlab gemma-gsec - 0.0.1-SNAPSHOT - jar + ${gsec.version} true ${project.build.directory}/schema **/*.sql @@ -637,8 +607,8 @@ mysql mysql-connector-java - 5.1.10 - jar + + 8.0.27 @@ -727,7 +697,7 @@ org.codehaus.mojo cobertura-maven-plugin - 2.6 + 2.7 diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/cli/SpringContextUtil.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/cli/SpringContextUtil.java index c479b8c5..49e154f0 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/cli/SpringContextUtil.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/cli/SpringContextUtil.java @@ -88,7 +88,7 @@ public static String[] getConfigLocations( boolean testing ) { * @param paths */ private static void addCommonConfig( List paths ) { - paths.add( "classpath*:gemma/gsec/acl/security-bean-baseconfig.xml" ); + paths.add( "classpath*:gemma/gsec/applicationContext-*.xml" ); paths.add( "classpath*:application-context.xml" ); paths.add( "classpath*:applicationContext-security.xml" ); paths.add( "classpath*:applicationContext-serviceBeans.xml" ); diff --git a/aspiredb/src/main/resources/production-data-source.xml b/aspiredb/src/main/resources/production-data-source.xml index e27743de..7305f145 100644 --- a/aspiredb/src/main/resources/production-data-source.xml +++ b/aspiredb/src/main/resources/production-data-source.xml @@ -1,99 +1,77 @@ - - - - + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + + + + classpath:default.properties - classpath:database.properties - file:${user.home}/aspiredb.properties - - - + classpath:database.properties + file:${user.home}/aspiredb.properties + + + - - - - - - - - - - - + + + + + + + + + + + - + - + - - - + - - classpath:hibernate.cfg.xml - + - - classpath:gemma/gsec/model/AclEntry.hbm.xml - classpath:gemma/gsec/model/AclObjectIdentity.hbm.xml - classpath:gemma/gsec/model/AclSid.hbm.xml - + + classpath:gemma/gsec/model/AclEntry.hbm.xml + classpath:gemma/gsec/model/AclObjectIdentity.hbm.xml + classpath:gemma/gsec/model/AclSid.hbm.xml + - - - - ${hibernate.dialect} - false + + + + ${hibernate.dialect} + false true false false false org.hibernate.cache.StandardQueryCacheFactory - org.hibernate.cache.EhCacheProvider - + org.hibernate.cache.EhCacheProvider + 3 512 512 256 true - true - - - - - - - - - - - - - ${mail.host} - - - ${mail.username} - - - ${mail.password} + true + + + + - + + + + + + + \ No newline at end of file diff --git a/aspiredb/src/main/webapp/WEB-INF/web.xml b/aspiredb/src/main/webapp/WEB-INF/web.xml index d54cdb3d..c1b00e03 100644 --- a/aspiredb/src/main/webapp/WEB-INF/web.xml +++ b/aspiredb/src/main/webapp/WEB-INF/web.xml @@ -6,7 +6,7 @@ contextConfigLocation - classpath*:gemma/gsec/acl/security-bean-baseconfig.xml, + classpath*:gemma/gsec/applicationContext-*.xml, classpath*:application-context.xml, classpath*:applicationContext-security.xml, classpath*:production-data-source.xml, diff --git a/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/BaseSpringContextTest.java b/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/BaseSpringContextTest.java index 073d078b..3f7df549 100644 --- a/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/BaseSpringContextTest.java +++ b/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/BaseSpringContextTest.java @@ -56,7 +56,7 @@ * @version $Id: BaseSpringContextTest.java,v 1.4 2013/06/12 20:18:48 cmcdonald Exp $ */ @ContextConfiguration(locations = { "classpath:/test-data-source.xml", - "classpath:gemma/gsec/acl/security-bean-baseconfig.xml", "classpath:/application-context.xml", + "classpath*:/gemma/gsec/applicationContext-*.xml", "classpath:/application-context.xml", "classpath:/applicationContext-security.xml", "classpath*:applicationContext-serviceBeans.xml" }) public abstract class BaseSpringContextTest extends AbstractJUnit4SpringContextTests implements InitializingBean { diff --git a/aspiredb/src/test/resources/test-data-source.xml b/aspiredb/src/test/resources/test-data-source.xml index 5337c4c2..fc68d74d 100644 --- a/aspiredb/src/test/resources/test-data-source.xml +++ b/aspiredb/src/test/resources/test-data-source.xml @@ -1,15 +1,7 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.2.xsd"> @@ -22,34 +14,20 @@ - - - com.mysql.jdbc.Driver - - - ${test.jdbc.username} - - - ${test.jdbc.password} - - - ${test.jdbc.url} - - - 20 - - - + + + + + + + + - - - + - - classpath:hibernate.cfg.xml - + @@ -72,9 +50,7 @@ - - - + From c75bd58d2c78079cd5d740463397e800edefb6a3 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 09:52:52 -0700 Subject: [PATCH 02/10] Update pavlab-starter-parent to 1.1.8 --- aspiredb/pom.xml | 29 +++++++++---------- .../server/ontology/OntologyService.java | 5 ++-- .../server/ontology/OntologyServiceImpl.java | 5 ++-- .../aspiredb/server/service/QueryService.java | 3 +- .../server/service/QueryServiceImpl.java | 3 +- .../controller/SignupControllerTest.java | 2 +- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index b6339d10..11e6a7e6 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -12,7 +12,7 @@ ubc.pavlab pavlab-starter-parent - 1.0 + 1.1.8 @@ -21,7 +21,7 @@ 1.8 3.2.18.RELEASE 3.2.10.RELEASE - 0.0.7 + 0.0.8 @@ -209,10 +209,8 @@ - javassist + org.javassist javassist - 3.12.1.GA - runtime org.hibernate @@ -429,6 +427,17 @@ + + org.apache.maven.plugins + maven-javadoc-plugin + 3.3.1 + + true + 8 + none + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes @@ -678,16 +687,6 @@ localDeploy file:///space/aspiredbData - - repo - Pavlab - file:///space/maven2 - - - repo - Pavlab - file:///space/maven2 - diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyService.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyService.java index 6b070b0d..5424bf59 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyService.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyService.java @@ -24,6 +24,7 @@ import ubic.basecode.ontology.model.OntologyTerm; import ubic.basecode.ontology.providers.DiseaseOntologyService; import ubic.basecode.ontology.providers.HumanPhenotypeOntologyService; +import ubic.basecode.ontology.search.OntologySearchException; /** * @author paul @@ -35,7 +36,7 @@ public interface OntologyService extends InitializingBean { * @param givenSearch * @return */ - public Collection findIndividuals( String givenSearch ); + public Collection findIndividuals( String givenSearch ) throws OntologySearchException; /** * Given a search string will look through the loaded ontologies for terms that match the search term. this a lucene @@ -44,7 +45,7 @@ public interface OntologyService extends InitializingBean { * @param search * @return returns a collection of ontologyTerm's */ - public Collection findTerms( String search ); + public Collection findTerms( String search ) throws OntologySearchException; /** * @return the diseaseOntologyService diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyServiceImpl.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyServiceImpl.java index 6073e806..f09fe508 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyServiceImpl.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/ontology/OntologyServiceImpl.java @@ -28,6 +28,7 @@ import ubic.basecode.ontology.providers.DiseaseOntologyService; import ubic.basecode.ontology.providers.HumanPhenotypeOntologyService; import ubic.basecode.ontology.search.OntologySearch; +import ubic.basecode.ontology.search.OntologySearchException; /** * Has a static method for finding out which ontologies are loaded into the system and a general purpose find method @@ -64,7 +65,7 @@ public void afterPropertiesSet() { } @Override - public Collection findIndividuals( String givenSearch ) { + public Collection findIndividuals( String givenSearch ) throws OntologySearchException { String query = OntologySearch.stripInvalidCharacters( givenSearch ); Collection results = new HashSet(); @@ -80,7 +81,7 @@ public Collection findIndividuals( String givenSearch ) { } @Override - public Collection findTerms( String search ) { + public Collection findTerms( String search ) throws OntologySearchException { String query = OntologySearch.stripInvalidCharacters( search ); diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryService.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryService.java index 9b661d0e..73360eb0 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryService.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryService.java @@ -38,6 +38,7 @@ import ubc.pavlab.aspiredb.shared.suggestions.PhenotypeSuggestion; import com.sencha.gxt.data.shared.loader.PagingLoadResult; +import ubic.basecode.ontology.search.OntologySearchException; /** * Methods for various query operations such as querying a list of subjects and variants given a list of filters, @@ -53,7 +54,7 @@ public BoundedList querySubjects( Set public BoundedList queryVariants( Set filters ) throws NotLoggedInException, ExternalDependencyException; - public PagingLoadResult getOntologyTermSuggestions( String query ); + public PagingLoadResult getOntologyTermSuggestions( String query ) throws OntologySearchException; public List getValuesForOntologyTerm( String ontologyTermUri ); diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryServiceImpl.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryServiceImpl.java index 28a41987..105bafd6 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryServiceImpl.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/service/QueryServiceImpl.java @@ -77,6 +77,7 @@ import ubc.pavlab.aspiredb.shared.suggestions.PhenotypeSuggestion; import ubic.basecode.ontology.model.OntologyTerm; import ubic.basecode.ontology.providers.HumanPhenotypeOntologyService; +import ubic.basecode.ontology.search.OntologySearchException; /** * Methods for various query operations such as querying a list of subjects and variants given a list of filters, @@ -151,7 +152,7 @@ public PagingLoadResult getNeurocartaPhenotypeSu } @Override - public PagingLoadResult getOntologyTermSuggestions( String query ) { + public PagingLoadResult getOntologyTermSuggestions( String query ) throws OntologySearchException { HumanPhenotypeOntologyService HPOService = ontologyService.getHumanPhenotypeOntologyService(); // if ( !HPOService.isOntologyLoaded() ) { // HPOService.startInitializationThread( true ); diff --git a/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/controller/SignupControllerTest.java b/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/controller/SignupControllerTest.java index 9007a287..f45e496f 100644 --- a/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/controller/SignupControllerTest.java +++ b/aspiredb/src/test/java/ubc/pavlab/aspiredb/server/controller/SignupControllerTest.java @@ -15,7 +15,7 @@ package ubc.pavlab.aspiredb.server.controller; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.Mockito.any; import static org.mockito.Mockito.when; import java.util.ArrayList; From cd70250a19ce53d1d654fca918f0078cb3c87236 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 10:01:49 -0700 Subject: [PATCH 03/10] Update dependencies --- aspiredb/pom.xml | 21 ++++++++++--------- .../main/resources/application-context.xml | 13 ++++++------ .../resources/applicationContext-security.xml | 14 ++++++------- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index 11e6a7e6..b8fe4e73 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -22,6 +22,7 @@ 3.2.18.RELEASE 3.2.10.RELEASE 0.0.8 + 1.9.9.1 @@ -69,7 +70,7 @@ org.easymock easymock - 4.3 + 5.0.1 test @@ -82,9 +83,9 @@ ${spring.version} - com.sun.jersey - jersey-bundle - 1.13 + org.glassfish.jersey.core + jersey-client + 3.0.8 org.apache.commons @@ -104,7 +105,7 @@ org.apache.commons commons-configuration2 - 2.7 + 2.8.0 commons-io @@ -190,12 +191,12 @@ org.aspectj aspectjrt - 1.9.7 + ${aspectj.version} org.aspectj aspectjweaver - 1.9.7 + ${aspectj.version} runtime @@ -246,7 +247,7 @@ net.sourceforge.csvjdbc csvjdbc - 1.0.38 + 1.0.40 com.sencha.gxt @@ -264,9 +265,9 @@ 1.5.3 - com.google.gwt + org.gwtproject gwt-servlet - 2.9.0 + 2.10.0 javax.servlet diff --git a/aspiredb/src/main/resources/application-context.xml b/aspiredb/src/main/resources/application-context.xml index a43d9567..b15e265f 100644 --- a/aspiredb/src/main/resources/application-context.xml +++ b/aspiredb/src/main/resources/application-context.xml @@ -1,14 +1,13 @@ From a629c6419e9e10a83c1cb6666149eb318eab5d8a Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 11:35:45 -0700 Subject: [PATCH 04/10] Fix missing reference to test.jdbc.driverClassName --- aspiredb/src/test/resources/test-data-source.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspiredb/src/test/resources/test-data-source.xml b/aspiredb/src/test/resources/test-data-source.xml index fc68d74d..f23985ef 100644 --- a/aspiredb/src/test/resources/test-data-source.xml +++ b/aspiredb/src/test/resources/test-data-source.xml @@ -15,7 +15,7 @@ - + From a9b984ffc19af09c80eb0086ac72fb8db96e4769 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 11:35:45 -0700 Subject: [PATCH 05/10] Use new driver location com.mysql.cj.jdbc.Driver --- aspiredb/README.txt | 2 +- aspiredb/pom.xml | 7 +++---- aspiredb/src/main/resources/database.properties | 3 +-- aspiredb/src/test/resources/database.properties | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/aspiredb/README.txt b/aspiredb/README.txt index 28d4f80d..9fcc39a0 100644 --- a/aspiredb/README.txt +++ b/aspiredb/README.txt @@ -36,7 +36,7 @@ whatever directory CATALINA_HOME is set to). the contents of aspiredb.properties should be as follows: -jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.driverClassName=com.mysql.cj.jdbc.Driver # change this value to whatever the path is to your database with the aspiredb schema jdbc.url=jdbc:mysql://localhost:3306/aspiredb diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index b8fe4e73..455e428a 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -524,7 +524,7 @@ - com.mysql.jdbc.Driver + com.mysql.cj.jdbc.Driver ${aspiredb.db.build.user} ${aspiredb.db.build.password} abort @@ -617,13 +617,12 @@ mysql mysql-connector-java - - 8.0.27 + ${mysql.version} - com.mysql.jdbc.Driver + com.mysql.cj.jdbc.Driver ${aspiredb.db.build.user} ${aspiredb.db.build.password} abort diff --git a/aspiredb/src/main/resources/database.properties b/aspiredb/src/main/resources/database.properties index bd41b915..1f96e93b 100644 --- a/aspiredb/src/main/resources/database.properties +++ b/aspiredb/src/main/resources/database.properties @@ -1,6 +1,5 @@ -jdbc.driverClassName=com.mysql.jdbc.Driver +jdbc.driverClassName=com.mysql.cj.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/aspiredb?rewriteBatchedStatements=true jdbc.username=aspiredb_web jdbc.password=aspiredb -#hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect \ No newline at end of file diff --git a/aspiredb/src/test/resources/database.properties b/aspiredb/src/test/resources/database.properties index 2f967a78..23c9a0ae 100644 --- a/aspiredb/src/test/resources/database.properties +++ b/aspiredb/src/test/resources/database.properties @@ -1,6 +1,5 @@ -test.jdbc.driverClassName=com.mysql.jdbc.Driver +test.jdbc.driverClassName=com.mysql.cj.jdbc.Driver test.jdbc.url=jdbc:mysql://localhost:3306/aspiredbtest test.jdbc.username=default_testdb_user test.jdbc.password=default_testdb_password -#test.hibernate.dialect=org.hibernate.dialect.MySQLDialect test.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect \ No newline at end of file From a9bffd523937c501c7598178cc0ccee02e7edeaf Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 11:51:44 -0700 Subject: [PATCH 06/10] Fix indentation for production-data-source.xml --- aspiredb/.editorconfig | 4 + .../main/resources/production-data-source.xml | 122 +++++++++--------- 2 files changed, 65 insertions(+), 61 deletions(-) create mode 100644 aspiredb/.editorconfig diff --git a/aspiredb/.editorconfig b/aspiredb/.editorconfig new file mode 100644 index 00000000..d8403426 --- /dev/null +++ b/aspiredb/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[production-data-source.xml] +indent_style=tab diff --git a/aspiredb/src/main/resources/production-data-source.xml b/aspiredb/src/main/resources/production-data-source.xml index 7305f145..65b032d8 100644 --- a/aspiredb/src/main/resources/production-data-source.xml +++ b/aspiredb/src/main/resources/production-data-source.xml @@ -1,77 +1,77 @@ - - - - classpath:default.properties - classpath:database.properties - file:${user.home}/aspiredb.properties - - - + + + + classpath:default.properties + classpath:database.properties + file:${user.home}/aspiredb.properties + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - + - + - - - classpath:gemma/gsec/model/AclEntry.hbm.xml - classpath:gemma/gsec/model/AclObjectIdentity.hbm.xml - classpath:gemma/gsec/model/AclSid.hbm.xml - - + + + classpath:gemma/gsec/model/AclEntry.hbm.xml + classpath:gemma/gsec/model/AclObjectIdentity.hbm.xml + classpath:gemma/gsec/model/AclSid.hbm.xml + + - - - ${hibernate.dialect} - false - true - false - false - false - org.hibernate.cache.StandardQueryCacheFactory - org.hibernate.cache.EhCacheProvider + + + ${hibernate.dialect} + false + true + false + false + false + org.hibernate.cache.StandardQueryCacheFactory + org.hibernate.cache.EhCacheProvider - 3 - 512 - 512 - 256 - true - true + 3 + 512 + 512 + 256 + true + true - - - - + + + + - - - - - + + + + + \ No newline at end of file From 0a8ccf021ba3cc53c7aba2ff32d7ba0ef760e3ef Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 14:35:24 -0700 Subject: [PATCH 07/10] Update jersey-client to 2.27 --- aspiredb/pom.xml | 2 +- .../biomartquery/BioMartQueryServiceImpl.java | 27 +++++------ .../gemma/NeurocartaQueryServiceImpl.java | 45 ++++++++++--------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index 455e428a..fae43e04 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -85,7 +85,7 @@ org.glassfish.jersey.core jersey-client - 3.0.8 + 2.27 org.apache.commons diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java index 5581002a..affb7634 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java @@ -22,11 +22,12 @@ import java.util.Map; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.PostConstruct; +import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -37,6 +38,8 @@ import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.glassfish.jersey.client.ClientResponse; +import org.glassfish.jersey.client.JerseyClientBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -45,10 +48,7 @@ import ubc.pavlab.aspiredb.shared.GeneValueObject; import ubc.pavlab.aspiredb.shared.GenomicRange; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.core.util.MultivaluedMapImpl; +import javax.ws.rs.client.Client; /** * Simple wrapper that calls BioMart REST query service. @@ -84,27 +84,24 @@ public void run() { } private static String sendRequest( String xmlQueryString ) throws BioMartServiceException { - Client client = Client.create(); + Client client = JerseyClientBuilder.newBuilder() + .readTimeout( BIOMART_TIMEOUT_SECONDS, TimeUnit.SECONDS ) + .build(); - MultivaluedMap queryData = new MultivaluedMapImpl(); - queryData.add( "query", xmlQueryString ); + WebTarget resource = client.target( BIO_MART_URL ).queryParam( "query", xmlQueryString ); - WebResource resource = client.resource( BIO_MART_URL ).queryParams( queryData ); - client.setReadTimeout( 1000 * BIOMART_TIMEOUT_SECONDS ); - - ClientResponse response = resource.type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ) - .get( ClientResponse.class ); + Response response = resource.request( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).get(); // Check return code if ( Response.Status.fromStatusCode( response.getStatus() ).getFamily() != Response.Status.Family.SUCCESSFUL ) { String errorMessage = "Error occurred when accessing BioMart web service: " - + response.getEntity( String.class ); + + response.getEntity(); log.error( errorMessage ); throw new BioMartServiceException( errorMessage ); } - return response.getEntity( String.class ); + return ( String ) response.getEntity(); } @Autowired diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java index 1df4fdb7..6e243a8a 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java @@ -14,12 +14,9 @@ */ package ubc.pavlab.aspiredb.server.gemma; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.core.util.MultivaluedMapImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.glassfish.jersey.client.JerseyClientBuilder; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -32,13 +29,16 @@ import ubc.pavlab.aspiredb.server.util.GemmaURLUtils; import ubc.pavlab.aspiredb.shared.GeneValueObject; import ubc.pavlab.aspiredb.shared.NeurocartaPhenotypeValueObject; -import ubic.basecode.ontology.model.OntologyTerm; import javax.annotation.PostConstruct; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import java.util.*; +import java.util.concurrent.TimeUnit; /** * Simple wrapper that calls Phenocarta REST web service. @@ -56,25 +56,28 @@ public class NeurocartaQueryServiceImpl implements NeurocartaQueryService { private static String sendRequest( String urlSuffix, MultivaluedMap queryParams ) throws NeurocartaServiceException { - Client client = Client.create(); - client.setReadTimeout( 1000 * REQUEST_TIMEOUT_SECONDS ); - client.setConnectTimeout( 1000 * REQUEST_TIMEOUT_SECONDS ); - WebResource resource = client.resource( GemmaURLUtils.makeWebServiceUrl( urlSuffix ) ).queryParams( - queryParams ); - - ClientResponse response = resource.type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ) - .get( ClientResponse.class ); + Client client = JerseyClientBuilder.newBuilder() + .readTimeout( REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS ) + .connectTimeout( REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS ) + .build(); + WebTarget webTarget = client.target( GemmaURLUtils.makeWebServiceUrl( urlSuffix ) ); + queryParams.forEach( ( k, l ) -> { + webTarget.queryParam( k, l.toArray() ); + } ); + Response response = webTarget + .request( MediaType.APPLICATION_FORM_URLENCODED_TYPE ) + .get(); // Check return code if ( Response.Status.fromStatusCode( response.getStatus() ).getFamily() != Response.Status.Family.SUCCESSFUL ) { String errorMessage = "Error occurred when accessing Phenocarta web service: (" + GemmaURLUtils.makeWebServiceUrl( urlSuffix ) + ") " - + response.getEntity( String.class ); + + response.getEntity(); log.error( errorMessage ); throw new NeurocartaServiceException( errorMessage ); } - return response.getEntity( String.class ); + return ( String ) response.getEntity(); } @Autowired @@ -90,13 +93,13 @@ private static String sendRequest( String urlSuffix, MultivaluedMap fetchAllPhenotypes() throws NeurocartaServiceException, BioMartServiceException { - String result = sendRequest( LOAD_PHENOTYPES_URL_SUFFIX, new MultivaluedMapImpl() ); + String result = sendRequest( LOAD_PHENOTYPES_URL_SUFFIX, new MultivaluedHashMap<>() ); Collection neurocartaPhenotypes = new HashSet<>(); try { JSONObject jsonResult = new JSONObject( result ); - JSONArray phenotypes = (JSONArray) jsonResult.get( "data" ); + JSONArray phenotypes = ( JSONArray ) jsonResult.get( "data" ); for ( int i = 0; i < phenotypes.length(); i++ ) { JSONObject phen = phenotypes.getJSONObject( i ); @@ -121,7 +124,7 @@ public Collection fetchAllPhenotypes() @Override public Collection fetchGenesAssociatedWithPhenotype( String phenotypeUri ) throws NeurocartaServiceException, BioMartServiceException { - MultivaluedMap queryParams = new MultivaluedMapImpl(); + MultivaluedMap queryParams = new MultivaluedHashMap<>(); queryParams.add( "editableOnly", "false" ); queryParams.add( "phenotypes", phenotypeUri ); // Example result : @@ -132,7 +135,7 @@ public Collection fetchGenesAssociatedWithPhenotype( String phe try { JSONObject jsonResult = new JSONObject( result ); - JSONArray genes = (JSONArray) jsonResult.get( "data" ); + JSONArray genes = ( JSONArray ) jsonResult.get( "data" ); geneSymbols = new HashSet<>( genes.length() ); @@ -157,7 +160,7 @@ public Collection fetchGenesAssociatedWithPhenotype( String phe public Map findPhenotypeGenes( String phenotypeUri ) throws NeurocartaServiceException, BioMartServiceException { - MultivaluedMap queryParams = new MultivaluedMapImpl(); + MultivaluedMap queryParams = new MultivaluedHashMap<>(); queryParams.add( "editableOnly", "false" ); queryParams.add( "phenotypes", phenotypeUri ); @@ -165,7 +168,7 @@ public Map findPhenotypeGenes( String phenotypeUri ) th Map geneToURI = new HashMap<>(); try { JSONObject jsonResult = new JSONObject( result ); - JSONArray genes = (JSONArray) jsonResult.get( "data" ); + JSONArray genes = ( JSONArray ) jsonResult.get( "data" ); for ( int i = 0; i < genes.length(); i++ ) { JSONObject gene = genes.getJSONObject( i ); From 1459c17f604b05019d749a84f8ff488845142ae7 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Sun, 30 Oct 2022 14:38:05 -0700 Subject: [PATCH 08/10] Remove redundant groupId --- aspiredb/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index fae43e04..4c9593e5 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -4,7 +4,6 @@ 4.0.0 ASPIREdb Project - ubc.pavlab aspiredb war 1.5-SNAPSHOT From 6fc7ef55ae4a689522352a6c06f981a74992e82a Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Mon, 31 Oct 2022 09:00:29 -0700 Subject: [PATCH 09/10] Update Maven plugins --- aspiredb/pom.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index 4c9593e5..e743477a 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -11,7 +11,7 @@ ubc.pavlab pavlab-starter-parent - 1.1.8 + 1.1.9 @@ -308,11 +308,15 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + maven-surefire-plugin 2.22.2 - -enableassertions -Xmx512m -Djava.awt.headless=true -Dlog4j.compatibility=true + -enableassertions -Xmx512m -Djava.awt.headless=true -Dlog4j1.compatibility=true target/surefire-reports true @@ -430,7 +434,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.3.1 + 3.3.2 true 8 @@ -487,7 +491,7 @@ maven-dependency-plugin - 3.2.0 + 3.1.2 process-resources @@ -586,7 +590,7 @@ maven-dependency-plugin - 3.2.0 + 3.1.2 process-resources From e8b6e47da85d1cf3831290a79ebf64e045c3e6f4 Mon Sep 17 00:00:00 2001 From: Guillaume Poirier-Morency Date: Mon, 31 Oct 2022 09:34:24 -0700 Subject: [PATCH 10/10] [WIP] --- aspiredb/pom.xml | 463 +++++++----------- .../biomartquery/BioMartQueryServiceImpl.java | 27 +- .../gemma/NeurocartaQueryServiceImpl.java | 45 +- aspiredb/src/main/resources/hibernate.cfg.xml | 2 +- 4 files changed, 223 insertions(+), 314 deletions(-) diff --git a/aspiredb/pom.xml b/aspiredb/pom.xml index e743477a..b765cc96 100644 --- a/aspiredb/pom.xml +++ b/aspiredb/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 ASPIREdb Project @@ -15,9 +15,6 @@ - UTF-8 - 1.8 - 1.8 3.2.18.RELEASE 3.2.10.RELEASE 0.0.8 @@ -82,9 +79,9 @@ ${spring.version} - org.glassfish.jersey.core - jersey-client - 2.27 + com.sun.jersey + jersey-bundle + 1.13 org.apache.commons @@ -280,8 +277,8 @@ 1.7 - javax.mail - javax.mail-api + com.sun.mail + javax.mail 1.6.2 @@ -298,13 +295,13 @@ + com.sun.jersey jersey-json 1.8 + Jersey + Spring com.sun.jersey.contribs jersey-spring + 1.12 org.springframework spring-aop + org.springframework spring-core + org.springframework spring-web org.springframework + spring-context org.springframework spring-beans + --> @@ -312,25 +309,6 @@ org.apache.maven.plugins maven-enforcer-plugin - - maven-surefire-plugin - 2.22.2 - - -enableassertions -Xmx512m -Djava.awt.headless=true -Dlog4j1.compatibility=true - target/surefire-reports - true - - **/Test*.java - **/*Test.java - - - **/AllTests.java - **/gui/Test*.java - **/AbstractTest*.java - **/*$* - - - org.apache.maven.plugins maven-eclipse-plugin @@ -351,50 +329,11 @@ - - - org.codehaus.mojo - hibernate3-maven-plugin - 3.0 - - - default-cli - - - - - hbm2ddl - - - annotationconfiguration - - - - src/main/resources/hibernate.cfg.xml - false - true - true - false - schema.sql - - - - - - org.apache.maven.plugins maven-jar-plugin 3.2.0 - - - package - - jar - - - @@ -411,11 +350,47 @@ aspiredb.version=${project.version} built ${maven.build.timestamp} + file="${project.build.directory}/${project.build.finalName}/WEB-INF/classes/version.properties">aspiredb.version=${project.version} built ${maven.build.timestamp} + + + + + + schema-export + pre-integration-test + + run + + + + + + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + pavlab + gemma-gsec + ${gsec.version} + + + ${project.groupId} + ${project.artifactId} + ${project.version} + system + ${project.build.directory}/${project.build.finalName}.jar + + @@ -442,12 +417,146 @@ + + + + + maven-dependency-plugin + 3.1.2 + + + pre-integration-test + + unpack + + + + + pavlab + gemma-gsec + ${gsec.version} + true + ${project.build.directory}/schema + **/*.sql + + + + + + + + org.codehaus.mojo + sql-maven-plugin + 1.5 + + + mysql + mysql-connector-java + + 8.0.27 + + + + + com.mysql.cj.jdbc.Driver + ${aspiredb.db.build.user} + ${aspiredb.db.build.password} + abort + true + + + + drop-add-testdb + pre-integration-test + + execute + + + ${bootstrap.db.url} + ${aspiredb.db.build.user} + ${aspiredb.db.build.password} + false + + + + + + + load-testdb-schema + pre-integration-test + + execute + + + ${aspiredb.testdb.build.url} + + ${project.build.directory}/hibernate3/sql/schema.sql + ${project.build.directory}/schema/gsec-acl-ddl.sql + src/main/resources/sql/init-acls.sql + src/main/resources/sql/init-entities.sql + src/main/resources/sql/init-indices.sql + ${project.build.directory}/schema/sql/init-acl-indices.sql + + abort + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + **/Test*.java + **/*Test.java + **/AllTests.java + **/gui/Test*.java + **/AbstractTest*.java + **/*$* + + + + + maven-failsafe-plugin + 2.22.2 + + + + integration-test + verify + + + + + -enableassertions -Xmx512m -Djava.awt.headless=true -Dlog4j1.compatibility=true + ${project.build.directory}/surefire-reports + true + + **/Test*.java + **/*Test.java + + + **/AllTests.java + **/gui/Test*.java + **/AbstractTest*.java + + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + build itself. --> org.eclipse.m2e lifecycle-mapping @@ -465,7 +574,7 @@ - + @@ -476,205 +585,7 @@ - - - testdb.build - - false - - testdb.build - - - - - - - maven-dependency-plugin - 3.1.2 - - - process-resources - - unpack - - - - - pavlab - gemma-gsec - ${gsec.version} - true - ${project.build.directory}/schema - **/*.sql - - - - - - - - org.codehaus.mojo - sql-maven-plugin - 1.5 - - - mysql - mysql-connector-java - - 8.0.27 - - - - - com.mysql.cj.jdbc.Driver - ${aspiredb.db.build.user} - ${aspiredb.db.build.password} - abort - true - - - - drop-add-testdb - initialize - - execute - - - ${bootstrap.db.url} - ${aspiredb.db.build.user} - ${aspiredb.db.build.password} - false - - - - - - - load-testdb-schema - process-test-resources - - execute - - - ${aspiredb.testdb.build.url} - - target/hibernate3/sql/schema.sql - target/schema/gsec-acl-ddl.sql - src/main/resources/sql/init-acls.sql - src/main/resources/sql/init-entities.sql - src/main/resources/sql/init-indices.sql - target/schema/sql/init-acl-indices.sql - - abort - - - - - - - - - db.build - - false - - db.build - - - - - - - maven-dependency-plugin - 3.1.2 - - - process-resources - - unpack - - - - - pavlab - gemma-gsec - ${gsec.version} - true - ${project.build.directory}/schema - **/*.sql - - - - - - - - org.codehaus.mojo - sql-maven-plugin - 1.5 - - - mysql - mysql-connector-java - ${mysql.version} - - - - - com.mysql.cj.jdbc.Driver - ${aspiredb.db.build.user} - ${aspiredb.db.build.password} - abort - true - - - - drop-add-db - initialize - - execute - - - ${bootstrap.db.url} - false - - - - - - - load-db-schema - process-resources - - execute - - - ${aspiredb.db.build.url} - ${aspiredb.db.build.user} - ${aspiredb.db.build.password} - - target/hibernate3/sql/schema.sql - target/schema/gsec-acl-ddl.sql - src/main/resources/sql/init-acls.sql - src/main/resources/sql/init-entities.sql - src/main/resources/sql/init-indices.sql - target/schema/sql/init-acl-indices.sql - - abort - - - - - - - local-deploy @@ -704,6 +615,4 @@ - - diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java index affb7634..5581002a 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/biomartquery/BioMartQueryServiceImpl.java @@ -22,12 +22,11 @@ import java.util.Map; import java.util.Timer; import java.util.TimerTask; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.PostConstruct; -import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -38,8 +37,6 @@ import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.glassfish.jersey.client.ClientResponse; -import org.glassfish.jersey.client.JerseyClientBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -48,7 +45,10 @@ import ubc.pavlab.aspiredb.shared.GeneValueObject; import ubc.pavlab.aspiredb.shared.GenomicRange; -import javax.ws.rs.client.Client; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.core.util.MultivaluedMapImpl; /** * Simple wrapper that calls BioMart REST query service. @@ -84,24 +84,27 @@ public void run() { } private static String sendRequest( String xmlQueryString ) throws BioMartServiceException { - Client client = JerseyClientBuilder.newBuilder() - .readTimeout( BIOMART_TIMEOUT_SECONDS, TimeUnit.SECONDS ) - .build(); + Client client = Client.create(); - WebTarget resource = client.target( BIO_MART_URL ).queryParam( "query", xmlQueryString ); + MultivaluedMap queryData = new MultivaluedMapImpl(); + queryData.add( "query", xmlQueryString ); - Response response = resource.request( MediaType.APPLICATION_FORM_URLENCODED_TYPE ).get(); + WebResource resource = client.resource( BIO_MART_URL ).queryParams( queryData ); + client.setReadTimeout( 1000 * BIOMART_TIMEOUT_SECONDS ); + + ClientResponse response = resource.type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ) + .get( ClientResponse.class ); // Check return code if ( Response.Status.fromStatusCode( response.getStatus() ).getFamily() != Response.Status.Family.SUCCESSFUL ) { String errorMessage = "Error occurred when accessing BioMart web service: " - + response.getEntity(); + + response.getEntity( String.class ); log.error( errorMessage ); throw new BioMartServiceException( errorMessage ); } - return ( String ) response.getEntity(); + return response.getEntity( String.class ); } @Autowired diff --git a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java index 6e243a8a..1df4fdb7 100644 --- a/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java +++ b/aspiredb/src/main/java/ubc/pavlab/aspiredb/server/gemma/NeurocartaQueryServiceImpl.java @@ -14,9 +14,12 @@ */ package ubc.pavlab.aspiredb.server.gemma; +import com.sun.jersey.api.client.Client; +import com.sun.jersey.api.client.ClientResponse; +import com.sun.jersey.api.client.WebResource; +import com.sun.jersey.core.util.MultivaluedMapImpl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.glassfish.jersey.client.JerseyClientBuilder; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -29,16 +32,13 @@ import ubc.pavlab.aspiredb.server.util.GemmaURLUtils; import ubc.pavlab.aspiredb.shared.GeneValueObject; import ubc.pavlab.aspiredb.shared.NeurocartaPhenotypeValueObject; +import ubic.basecode.ontology.model.OntologyTerm; import javax.annotation.PostConstruct; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import java.util.*; -import java.util.concurrent.TimeUnit; /** * Simple wrapper that calls Phenocarta REST web service. @@ -56,28 +56,25 @@ public class NeurocartaQueryServiceImpl implements NeurocartaQueryService { private static String sendRequest( String urlSuffix, MultivaluedMap queryParams ) throws NeurocartaServiceException { - Client client = JerseyClientBuilder.newBuilder() - .readTimeout( REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS ) - .connectTimeout( REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS ) - .build(); - WebTarget webTarget = client.target( GemmaURLUtils.makeWebServiceUrl( urlSuffix ) ); - queryParams.forEach( ( k, l ) -> { - webTarget.queryParam( k, l.toArray() ); - } ); - Response response = webTarget - .request( MediaType.APPLICATION_FORM_URLENCODED_TYPE ) - .get(); + Client client = Client.create(); + client.setReadTimeout( 1000 * REQUEST_TIMEOUT_SECONDS ); + client.setConnectTimeout( 1000 * REQUEST_TIMEOUT_SECONDS ); + WebResource resource = client.resource( GemmaURLUtils.makeWebServiceUrl( urlSuffix ) ).queryParams( + queryParams ); + + ClientResponse response = resource.type( MediaType.APPLICATION_FORM_URLENCODED_TYPE ) + .get( ClientResponse.class ); // Check return code if ( Response.Status.fromStatusCode( response.getStatus() ).getFamily() != Response.Status.Family.SUCCESSFUL ) { String errorMessage = "Error occurred when accessing Phenocarta web service: (" + GemmaURLUtils.makeWebServiceUrl( urlSuffix ) + ") " - + response.getEntity(); + + response.getEntity( String.class ); log.error( errorMessage ); throw new NeurocartaServiceException( errorMessage ); } - return ( String ) response.getEntity(); + return response.getEntity( String.class ); } @Autowired @@ -93,13 +90,13 @@ private static String sendRequest( String urlSuffix, MultivaluedMap fetchAllPhenotypes() throws NeurocartaServiceException, BioMartServiceException { - String result = sendRequest( LOAD_PHENOTYPES_URL_SUFFIX, new MultivaluedHashMap<>() ); + String result = sendRequest( LOAD_PHENOTYPES_URL_SUFFIX, new MultivaluedMapImpl() ); Collection neurocartaPhenotypes = new HashSet<>(); try { JSONObject jsonResult = new JSONObject( result ); - JSONArray phenotypes = ( JSONArray ) jsonResult.get( "data" ); + JSONArray phenotypes = (JSONArray) jsonResult.get( "data" ); for ( int i = 0; i < phenotypes.length(); i++ ) { JSONObject phen = phenotypes.getJSONObject( i ); @@ -124,7 +121,7 @@ public Collection fetchAllPhenotypes() @Override public Collection fetchGenesAssociatedWithPhenotype( String phenotypeUri ) throws NeurocartaServiceException, BioMartServiceException { - MultivaluedMap queryParams = new MultivaluedHashMap<>(); + MultivaluedMap queryParams = new MultivaluedMapImpl(); queryParams.add( "editableOnly", "false" ); queryParams.add( "phenotypes", phenotypeUri ); // Example result : @@ -135,7 +132,7 @@ public Collection fetchGenesAssociatedWithPhenotype( String phe try { JSONObject jsonResult = new JSONObject( result ); - JSONArray genes = ( JSONArray ) jsonResult.get( "data" ); + JSONArray genes = (JSONArray) jsonResult.get( "data" ); geneSymbols = new HashSet<>( genes.length() ); @@ -160,7 +157,7 @@ public Collection fetchGenesAssociatedWithPhenotype( String phe public Map findPhenotypeGenes( String phenotypeUri ) throws NeurocartaServiceException, BioMartServiceException { - MultivaluedMap queryParams = new MultivaluedHashMap<>(); + MultivaluedMap queryParams = new MultivaluedMapImpl(); queryParams.add( "editableOnly", "false" ); queryParams.add( "phenotypes", phenotypeUri ); @@ -168,7 +165,7 @@ public Map findPhenotypeGenes( String phenotypeUri ) th Map geneToURI = new HashMap<>(); try { JSONObject jsonResult = new JSONObject( result ); - JSONArray genes = ( JSONArray ) jsonResult.get( "data" ); + JSONArray genes = (JSONArray) jsonResult.get( "data" ); for ( int i = 0; i < genes.length(); i++ ) { JSONObject gene = genes.getJSONObject( i ); diff --git a/aspiredb/src/main/resources/hibernate.cfg.xml b/aspiredb/src/main/resources/hibernate.cfg.xml index 0b7e3a4d..97127e93 100644 --- a/aspiredb/src/main/resources/hibernate.cfg.xml +++ b/aspiredb/src/main/resources/hibernate.cfg.xml @@ -6,7 +6,7 @@ - org.hibernate.dialect.MySQLDialect + org.hibernate.dialect.MySQL5InnoDBDialect