From 78db1e055e3156356d03d3b5eb506a4f12b5cc2f Mon Sep 17 00:00:00 2001 From: Charity Hilton Date: Thu, 30 Apr 2015 14:23:18 -0400 Subject: [PATCH] Rename to match endpoint; follow webapi endpoint pattern --- .../CohortEntity.java | 2 +- .../CohortRepository.java | 2 +- .../CohortService.java} | 33 ++++++++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) rename src/main/java/org/ohdsi/webapi/{cohortimportexport => cohort}/CohortEntity.java (98%) rename src/main/java/org/ohdsi/webapi/{cohortimportexport => cohort}/CohortRepository.java (88%) rename src/main/java/org/ohdsi/webapi/{cohortimportexport/CohortImportExportService.java => service/CohortService.java} (76%) diff --git a/src/main/java/org/ohdsi/webapi/cohortimportexport/CohortEntity.java b/src/main/java/org/ohdsi/webapi/cohort/CohortEntity.java similarity index 98% rename from src/main/java/org/ohdsi/webapi/cohortimportexport/CohortEntity.java rename to src/main/java/org/ohdsi/webapi/cohort/CohortEntity.java index 864b639387..f27c6458e9 100644 --- a/src/main/java/org/ohdsi/webapi/cohortimportexport/CohortEntity.java +++ b/src/main/java/org/ohdsi/webapi/cohort/CohortEntity.java @@ -1,4 +1,4 @@ -package org.ohdsi.webapi.cohortimportexport; +package org.ohdsi.webapi.cohort; import java.io.Serializable; import java.util.Date; diff --git a/src/main/java/org/ohdsi/webapi/cohortimportexport/CohortRepository.java b/src/main/java/org/ohdsi/webapi/cohort/CohortRepository.java similarity index 88% rename from src/main/java/org/ohdsi/webapi/cohortimportexport/CohortRepository.java rename to src/main/java/org/ohdsi/webapi/cohort/CohortRepository.java index 99c2b8f38b..0ccc1d9ec9 100644 --- a/src/main/java/org/ohdsi/webapi/cohortimportexport/CohortRepository.java +++ b/src/main/java/org/ohdsi/webapi/cohort/CohortRepository.java @@ -1,4 +1,4 @@ -package org.ohdsi.webapi.cohortimportexport; +package org.ohdsi.webapi.cohort; import java.util.List; diff --git a/src/main/java/org/ohdsi/webapi/cohortimportexport/CohortImportExportService.java b/src/main/java/org/ohdsi/webapi/service/CohortService.java similarity index 76% rename from src/main/java/org/ohdsi/webapi/cohortimportexport/CohortImportExportService.java rename to src/main/java/org/ohdsi/webapi/service/CohortService.java index c6c1670970..2cb6829153 100644 --- a/src/main/java/org/ohdsi/webapi/cohortimportexport/CohortImportExportService.java +++ b/src/main/java/org/ohdsi/webapi/service/CohortService.java @@ -1,4 +1,4 @@ -package org.ohdsi.webapi.cohortimportexport; +package org.ohdsi.webapi.service; import java.util.List; @@ -11,18 +11,20 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; +import org.ohdsi.webapi.cohort.CohortEntity; +import org.ohdsi.webapi.cohort.CohortRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionTemplate; + /** - * Imports exports cohorts using something like http://localhost:8080/WebAPI/import/cohort/7 - * + * Service to read/write to the Cohort table */ @Path("/cohort/") @Component -public class CohortImportExportService { +public class CohortService { @Autowired public CohortRepository cohortRepository; @@ -33,19 +35,30 @@ public class CohortImportExportService { @Autowired private EntityManager em; + /** + * Retrieves all cohort entities for the given cohort definition id + * from the COHORT table + * + * @param id Cohort Definition id + * @return List of CohortEntity + */ @GET - @Path("import/{id}") + @Path("{id}") @Produces(MediaType.APPLICATION_JSON) public List getCohortListById(@PathParam("id") final long id) { List d = this.cohortRepository.getAllCohortsForId(id); - - return d; } + /** + * Imports a List of CohortEntity into the COHORT table + * + * @param cohort List of CohortEntity + * @return status + */ @POST - @Path("export") + @Path("import") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) public String saveCohortListToCDM(final List cohort) { @@ -66,9 +79,7 @@ public Void doInTransaction(TransactionStatus status) { return null; } }); - - //System.out.println(cohort); - + return "ok"; }