diff --git a/grails-app/conf/application.groovy b/grails-app/conf/application.groovy index da139f946..1abd9646f 100644 --- a/grails-app/conf/application.groovy +++ b/grails-app/conf/application.groovy @@ -1490,4 +1490,4 @@ paratoo.defaultPlotLayoutViewModels = [ ] ] ] - +paratoo.species.specialCases = ["Other", "N/A"] diff --git a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy index e03b704c8..cae51de9b 100644 --- a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy @@ -479,12 +479,13 @@ class ParatooService { formVersion : activityForm.formVersion, description : "Activity submitted by monitor", projectId : collection.projectId, - publicationStatus: "published", + publicationStatus: PublicationStatus.PUBLISHED, siteId : dataSet.siteId, startDate : dataSet.startDate, endDate : dataSet.endDate, plannedStartDate : dataSet.startDate, plannedEndDate : dataSet.endDate, + progress : Activity.FINISHED, externalIds : [new ExternalId(idType: ExternalId.IdType.MONITOR_MINTED_COLLECTION_ID, externalId: dataSet.dataSetId)], userId : userId, outputs : [[ @@ -2106,9 +2107,15 @@ class ParatooService { } result.name = result.commonName ? result.scientificName ? "${result.scientificName} (${result.commonName})" : result.commonName : result.scientificName - - // record is only created if guid is present - result.guid = result.guid ?: Record.UNMATCHED_GUID + List specialCases = grailsApplication.config.getProperty("paratoo.species.specialCases", List) + // do not create record for special cases + if (specialCases.contains(name)) { + result.remove("guid") + } + else { + // record is only created if guid is present + result.guid = result.guid ?: Record.UNMATCHED_GUID + } result } } diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy index 281a6f183..d1add60c5 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy @@ -44,6 +44,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest> null 1 * speciesReMatchService.searchByName(_, false, true) >> null + + when: // Do not create record when value equals special cases. Therefore, removes guid. + result = service.transformSpeciesName("Other") + outputSpeciesId = result.remove("outputSpeciesId") + + then: + outputSpeciesId != null + result == [name: "Other", scientificName: null, commonName: "Other", taxonRank: null] + 1 * speciesReMatchService.searchByName(_) >> null + 1 * speciesReMatchService.searchByName(_, false, true) >> null + } void "buildTreeFromParentChildRelationships should build tree correctly"() {