Skip to content

Commit

Permalink
Tag surveys based on config #823
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Feb 26, 2024
1 parent 401ac4c commit a1d5a0b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions grails-app/domain/au/org/ala/ecodata/ActivityForm.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import org.bson.types.ObjectId
*/
class ActivityForm {

static String SURVEY_TAG = "survey"
static String INTERVENTION_TAG = "intervention"
static String SITE_TAG = "site"

static graphql = ActivityFormGraphQLMapper.graphqlMapping()

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

/** Currently only used to describe whether this form is collecting survey data (and hence a data set summary will be created) */
List tags = []

boolean isPublished() {
return publicationStatus == PublicationStatus.PUBLISHED
}
Expand Down
9 changes: 7 additions & 2 deletions grails-app/services/au/org/ala/ecodata/ParatooService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ class ParatooService {
result
}



private static Map mapActivity(Map surveyData, Map activity, ParatooProtocolConfig config) {
activity.startDate = config.getStartDate(surveyData)
activity.endDate = config.getEndDate(surveyData)
Expand Down Expand Up @@ -282,6 +284,7 @@ class ParatooService {
String guid = protocol.attributes.identifier
guids << guid
String name = protocol.attributes.name
ParatooProtocolConfig protocolConfig = getProtocolConfig(id)
ActivityForm form = ActivityForm.findByExternalId(guid)
if (!form) {
form = new ActivityForm()
Expand Down Expand Up @@ -312,7 +315,8 @@ class ParatooService {

}

mapProtocolToActivityForm(protocol, form)
List tags = protocolConfig?.tags ?: [ActivityForm.SURVEY_TAG]
mapProtocolToActivityForm(protocol, form, tags)
form.save()

if (form.hasErrors()) {
Expand Down Expand Up @@ -358,14 +362,15 @@ class ParatooService {
syncParatooProtocols(response?.data)
}

private static void mapProtocolToActivityForm(Map protocol, ActivityForm form) {
private static void mapProtocolToActivityForm(Map protocol, ActivityForm form, List tags) {
form.name = protocol.attributes.name
form.formVersion = protocol.attributes.version
form.type = PARATOO_PROTOCOL_FORM_TYPE
form.category = protocol.attributes.module
form.external = true
form.publicationStatus = PublicationStatus.PUBLISHED
form.description = protocol.attributes.description
form.tags = tags
}

private ParatooProject mapProject(Project project, AccessLevel accessLevel, List<Site> sites) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ParatooProtocolConfig {

String apiEndpoint
boolean usesPlotLayout = true
List tags
String geometryType = 'Polygon'

String geometryPath
Expand Down

0 comments on commit a1d5a0b

Please sign in to comment.