1
- package org .ohdsi .webapi .cohortimportexport ;
1
+ package org .ohdsi .webapi .service ;
2
2
3
3
import java .util .List ;
4
4
11
11
import javax .ws .rs .Produces ;
12
12
import javax .ws .rs .core .MediaType ;
13
13
14
+ import org .ohdsi .webapi .cohort .CohortEntity ;
15
+ import org .ohdsi .webapi .cohort .CohortRepository ;
14
16
import org .springframework .beans .factory .annotation .Autowired ;
15
17
import org .springframework .stereotype .Component ;
16
18
import org .springframework .transaction .TransactionStatus ;
17
19
import org .springframework .transaction .support .TransactionCallback ;
18
20
import org .springframework .transaction .support .TransactionTemplate ;
21
+
19
22
/**
20
- * Imports exports cohorts using something like http://localhost:8080/WebAPI/import/cohort/7
21
- *
23
+ * Service to read/write to the Cohort table
22
24
*/
23
25
@ Path ("/cohort/" )
24
26
@ Component
25
- public class CohortImportExportService {
27
+ public class CohortService {
26
28
27
29
@ Autowired
28
30
public CohortRepository cohortRepository ;
@@ -33,19 +35,30 @@ public class CohortImportExportService {
33
35
@ Autowired
34
36
private EntityManager em ;
35
37
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
+ */
36
45
@ GET
37
- @ Path ("import/ {id}" )
46
+ @ Path ("{id}" )
38
47
@ Produces (MediaType .APPLICATION_JSON )
39
48
public List <CohortEntity > getCohortListById (@ PathParam ("id" ) final long id ) {
40
49
41
50
List <CohortEntity > d = this .cohortRepository .getAllCohortsForId (id );
42
-
43
-
44
51
return d ;
45
52
}
46
53
54
+ /**
55
+ * Imports a List of CohortEntity into the COHORT table
56
+ *
57
+ * @param cohort List of CohortEntity
58
+ * @return status
59
+ */
47
60
@ POST
48
- @ Path ("export " )
61
+ @ Path ("import " )
49
62
@ Consumes (MediaType .APPLICATION_JSON )
50
63
@ Produces (MediaType .TEXT_PLAIN )
51
64
public String saveCohortListToCDM (final List <CohortEntity > cohort ) {
@@ -66,9 +79,7 @@ public Void doInTransaction(TransactionStatus status) {
66
79
return null ;
67
80
}
68
81
});
69
-
70
- //System.out.println(cohort);
71
-
82
+
72
83
return "ok" ;
73
84
}
74
85
0 commit comments