Skip to content

Commit a1d5a0b

Browse files
committed
Tag surveys based on config #823
1 parent 401ac4c commit a1d5a0b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

grails-app/domain/au/org/ala/ecodata/ActivityForm.groovy

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import org.bson.types.ObjectId
88
*/
99
class ActivityForm {
1010

11+
static String SURVEY_TAG = "survey"
12+
static String INTERVENTION_TAG = "intervention"
13+
static String SITE_TAG = "site"
14+
1115
static graphql = ActivityFormGraphQLMapper.graphqlMapping()
1216

1317
/** The list of properties to be used when binding request data to an ActivityForm */
@@ -101,6 +105,9 @@ class ActivityForm {
101105
String createdUserId
102106
String lastUpdatedUserId
103107

108+
/** Currently only used to describe whether this form is collecting survey data (and hence a data set summary will be created) */
109+
List tags = []
110+
104111
boolean isPublished() {
105112
return publicationStatus == PublicationStatus.PUBLISHED
106113
}

grails-app/services/au/org/ala/ecodata/ParatooService.groovy

+7-2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ class ParatooService {
198198
result
199199
}
200200

201+
202+
201203
private static Map mapActivity(Map surveyData, Map activity, ParatooProtocolConfig config) {
202204
activity.startDate = config.getStartDate(surveyData)
203205
activity.endDate = config.getEndDate(surveyData)
@@ -282,6 +284,7 @@ class ParatooService {
282284
String guid = protocol.attributes.identifier
283285
guids << guid
284286
String name = protocol.attributes.name
287+
ParatooProtocolConfig protocolConfig = getProtocolConfig(id)
285288
ActivityForm form = ActivityForm.findByExternalId(guid)
286289
if (!form) {
287290
form = new ActivityForm()
@@ -312,7 +315,8 @@ class ParatooService {
312315

313316
}
314317

315-
mapProtocolToActivityForm(protocol, form)
318+
List tags = protocolConfig?.tags ?: [ActivityForm.SURVEY_TAG]
319+
mapProtocolToActivityForm(protocol, form, tags)
316320
form.save()
317321

318322
if (form.hasErrors()) {
@@ -358,14 +362,15 @@ class ParatooService {
358362
syncParatooProtocols(response?.data)
359363
}
360364

361-
private static void mapProtocolToActivityForm(Map protocol, ActivityForm form) {
365+
private static void mapProtocolToActivityForm(Map protocol, ActivityForm form, List tags) {
362366
form.name = protocol.attributes.name
363367
form.formVersion = protocol.attributes.version
364368
form.type = PARATOO_PROTOCOL_FORM_TYPE
365369
form.category = protocol.attributes.module
366370
form.external = true
367371
form.publicationStatus = PublicationStatus.PUBLISHED
368372
form.description = protocol.attributes.description
373+
form.tags = tags
369374
}
370375

371376
private ParatooProject mapProject(Project project, AccessLevel accessLevel, List<Site> sites) {

src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProtocolConfig.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ParatooProtocolConfig {
1414

1515
String apiEndpoint
1616
boolean usesPlotLayout = true
17+
List tags
1718
String geometryType = 'Polygon'
1819

1920
String geometryPath

0 commit comments

Comments
 (0)