Skip to content

Commit d73ab0c

Browse files
committed
Merge pull request #39 from OHDSI/cohort-importer-route-fi
Rename to match endpoint; follow webapi endpoint pattern
2 parents bd83f5f + 78db1e0 commit d73ab0c

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/main/java/org/ohdsi/webapi/cohortimportexport/CohortEntity.java src/main/java/org/ohdsi/webapi/cohort/CohortEntity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.ohdsi.webapi.cohortimportexport;
1+
package org.ohdsi.webapi.cohort;
22

33
import java.io.Serializable;
44
import java.util.Date;

src/main/java/org/ohdsi/webapi/cohortimportexport/CohortRepository.java src/main/java/org/ohdsi/webapi/cohort/CohortRepository.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.ohdsi.webapi.cohortimportexport;
1+
package org.ohdsi.webapi.cohort;
22

33
import java.util.List;
44

src/main/java/org/ohdsi/webapi/cohortimportexport/CohortImportExportService.java src/main/java/org/ohdsi/webapi/service/CohortService.java

+22-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.ohdsi.webapi.cohortimportexport;
1+
package org.ohdsi.webapi.service;
22

33
import java.util.List;
44

@@ -11,18 +11,20 @@
1111
import javax.ws.rs.Produces;
1212
import javax.ws.rs.core.MediaType;
1313

14+
import org.ohdsi.webapi.cohort.CohortEntity;
15+
import org.ohdsi.webapi.cohort.CohortRepository;
1416
import org.springframework.beans.factory.annotation.Autowired;
1517
import org.springframework.stereotype.Component;
1618
import org.springframework.transaction.TransactionStatus;
1719
import org.springframework.transaction.support.TransactionCallback;
1820
import org.springframework.transaction.support.TransactionTemplate;
21+
1922
/**
20-
* Imports exports cohorts using something like http://localhost:8080/WebAPI/import/cohort/7
21-
*
23+
* Service to read/write to the Cohort table
2224
*/
2325
@Path("/cohort/")
2426
@Component
25-
public class CohortImportExportService {
27+
public class CohortService {
2628

2729
@Autowired
2830
public CohortRepository cohortRepository;
@@ -33,19 +35,30 @@ public class CohortImportExportService {
3335
@Autowired
3436
private EntityManager em;
3537

38+
/**
39+
* Retrieves all cohort entities for the given cohort definition id
40+
* from the COHORT table
41+
*
42+
* @param id Cohort Definition id
43+
* @return List of CohortEntity
44+
*/
3645
@GET
37-
@Path("import/{id}")
46+
@Path("{id}")
3847
@Produces(MediaType.APPLICATION_JSON)
3948
public List<CohortEntity> getCohortListById(@PathParam("id") final long id) {
4049

4150
List<CohortEntity> d = this.cohortRepository.getAllCohortsForId(id);
42-
43-
4451
return d;
4552
}
4653

54+
/**
55+
* Imports a List of CohortEntity into the COHORT table
56+
*
57+
* @param cohort List of CohortEntity
58+
* @return status
59+
*/
4760
@POST
48-
@Path("export")
61+
@Path("import")
4962
@Consumes(MediaType.APPLICATION_JSON)
5063
@Produces(MediaType.TEXT_PLAIN)
5164
public String saveCohortListToCDM(final List<CohortEntity> cohort) {
@@ -66,9 +79,7 @@ public Void doInTransaction(TransactionStatus status) {
6679
return null;
6780
}
6881
});
69-
70-
//System.out.println(cohort);
71-
82+
7283
return "ok";
7384
}
7485

0 commit comments

Comments
 (0)