From 81a2cb789162b473668f10258b4a44cdf1faba30 Mon Sep 17 00:00:00 2001 From: temi Date: Wed, 22 May 2024 15:35:57 +1000 Subject: [PATCH] #958 - added a flag to switch off record creation for certain protocols --- .../au/org/ala/ecodata/ParatooService.groovy | 3 +- .../paratoo/ParatooProtocolConfig.groovy | 1 + .../org/ala/ecodata/ParatooServiceSpec.groovy | 88 +++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy index b963f4d8f..d8b3077f2 100644 --- a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy @@ -1233,8 +1233,9 @@ class ParatooService { ArrayDeque modelVisitStack = new ArrayDeque<>() documentation = deepCopy(documentation) Map components = deepCopy(getComponents(documentation)) + boolean record = config.createSpeciesRecord - Map template = [dataModel: [], viewModel: [], modelName: capitalizeModelName(protocol.attributes.name), record: true, relationships: [ecodata: [:], apiOutput: [:]]] + Map template = [dataModel: [], viewModel: [], modelName: capitalizeModelName(protocol.attributes.name), record: record, relationships: [ecodata: [:], apiOutput: [:]]] Map properties = deepCopy(findProtocolEndpointDefinition(protocol, documentation)) if (properties == null) { throw new NotFoundException("No protocol endpoint found for ${protocol.attributes.endpointPrefix}/bulk") diff --git a/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProtocolConfig.groovy b/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProtocolConfig.groovy index ff07b372d..98a02dba7 100644 --- a/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProtocolConfig.groovy +++ b/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProtocolConfig.groovy @@ -17,6 +17,7 @@ class ParatooProtocolConfig { String name String apiEndpoint boolean usesPlotLayout = true + boolean createSpeciesRecord = true List tags String geometryType = 'Polygon' diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy index 1cfd60ac1..83f2c4f5c 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy @@ -1549,6 +1549,94 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest