Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/4.6' into feature/issue965
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed May 30, 2024
2 parents f6023f6 + 72f2d40 commit 29212f4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion grails-app/conf/application.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1490,4 +1490,4 @@ paratoo.defaultPlotLayoutViewModels = [
]
]
]

paratoo.species.specialCases = ["Other", "N/A"]
15 changes: 11 additions & 4 deletions grails-app/services/au/org/ala/ecodata/ParatooService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 : [[
Expand Down Expand Up @@ -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
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
setupData()

grailsApplication.config.paratoo.location.excluded = ['location.vegetation-association-nvis']
grailsApplication.config.paratoo.species.specialCase = ["Other"]
service.grailsApplication = grailsApplication
service.webService = webService
service.siteService = siteService
Expand Down Expand Up @@ -740,6 +741,17 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
result == [name: "Frogs", scientificName: "", guid: "A_GUID", commonName: "Frogs", taxonRank: "Class"]
1 * speciesReMatchService.searchByName(_) >> 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"() {
Expand Down

0 comments on commit 29212f4

Please sign in to comment.