File tree 3 files changed +28
-0
lines changed
grails-app/services/au/org/ala/ecodata/forms
src/test/groovy/au/org/ala/ecodata/forms
3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import org.grails.web.json.JSONObject
10
10
class ActivityFormService {
11
11
12
12
static final String ACTIVITY_FORM_PATH = ' /activityForm'
13
+ static final String ACTIVITY_FORM_SEARCH_PATH = ' /activityForm/search'
13
14
def webService
14
15
def grailsApplication
15
16
@@ -66,6 +67,21 @@ class ActivityFormService {
66
67
model
67
68
}
68
69
70
+ /**
71
+ * Returns a Map with keys: [resp:List<Map>, statusCode:<>]
72
+ * @param criteria Used to build a GORM criteria query, e.g. [category:'paratoo']
73
+ */
74
+ Map searchActivityForms (Map criteria ) {
75
+ String url = grailsApplication. config. getProperty(' ecodata.service.url' ) +
76
+ ACTIVITY_FORM_SEARCH_PATH
77
+ Map result = webService. doPost(url, criteria)
78
+ if (! result || result. error) {
79
+ result = null
80
+ }
81
+
82
+ result
83
+ }
84
+
69
85
private Map missingForm (String name , Integer version ) {
70
86
String message = " No activity form found with name ${ name} "
71
87
if (version) {
Original file line number Diff line number Diff line change @@ -30,4 +30,8 @@ class WebService {
30
30
def doPostWithParams (String url , Map params ) {
31
31
[:]
32
32
}
33
+
34
+ def doPost (String url , Map params ) {
35
+ [:]
36
+ }
33
37
}
Original file line number Diff line number Diff line change @@ -80,4 +80,12 @@ class ActivityFormServiceSpec extends Specification implements ServiceUnitTest<A
80
80
81
81
result. outputModels[" Not found" ] != null
82
82
}
83
+
84
+ void " The service can interface to ecodata to search available activity forms" () {
85
+ when :
86
+ service. searchActivityForms([type :' Protocol' ])
87
+
88
+ then :
89
+ 1 * webService. doPost({it. endsWith(ActivityFormService . ACTIVITY_FORM_SEARCH_PATH )}, [type :' Protocol' ])
90
+ }
83
91
}
You can’t perform that action at this time.
0 commit comments