Skip to content

Commit

Permalink
Use different id type for plot selections #942
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed May 30, 2024
1 parent b3dfa8c commit 5e4d110
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion grails-app/domain/au/org/ala/ecodata/ExternalId.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExternalId implements Comparable {
enum IdType {
INTERNAL_ORDER_NUMBER, TECH_ONE_CODE, WORK_ORDER, GRANT_AWARD, GRANT_OPPORTUNITY, RELATED_PROJECT,
MONITOR_PROTOCOL_INTERNAL_ID, MONITOR_PROTOCOL_GUID, TECH_ONE_CONTRACT_NUMBER, MONITOR_PLOT_GUID,
MONITOR_MINTED_COLLECTION_ID, UNSPECIFIED }
MONITOR_PLOT_SELECTION_GUID, MONITOR_MINTED_COLLECTION_ID, UNSPECIFIED }

static constraints = {
}
Expand Down
8 changes: 4 additions & 4 deletions grails-app/services/au/org/ala/ecodata/ParatooService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ class ParatooService {
// Monitor has users selecting a point as an approximate survey location then
// laying out the plot using GPS when at the site. We only want to return the approximate planning
// sites from this call
List<Site> plotSelections = sites.findAll{it.type == Site.TYPE_SURVEY_AREA && it.extent?.geometry?.type == 'Point'}
List<Site> plotSelections = sites.findAll{it.externalIds?.find{externalId -> externalId.idType == ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID}}

Map attributes = [
id:project.projectId,
Expand Down Expand Up @@ -875,7 +875,7 @@ class ParatooService {
// The project/s for the site will be specified by a subsequent call to /projects
siteData.projects = []

Site site = Site.findByExternalId(ExternalId.IdType.MONITOR_PLOT_GUID, siteData.externalId)
Site site = Site.findByExternalId(ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID, siteData.externalId)
Map result
if (site) {
result = siteService.update(siteData, site.siteId)
Expand All @@ -892,7 +892,7 @@ class ParatooService {
site.projects = []
// get all projects for the user I suppose - not sure why this isn't in the payload as it's in the UI...
site.type = Site.TYPE_SURVEY_AREA
site.externalIds = [new ExternalId(idType: ExternalId.IdType.MONITOR_PLOT_GUID, externalId: geoJson.properties.externalId)]
site.externalIds = [new ExternalId(idType: ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID, externalId: geoJson.properties.externalId)]
site.publicationStatus = PublicationStatus.PUBLISHED
// Mark the plot as read only as it is managed by the Monitor app

Expand All @@ -919,7 +919,7 @@ class ParatooService {

siteExternalIds.each { String siteExternalId ->

Site site = Site.findByExternalId(ExternalId.IdType.MONITOR_PLOT_GUID, siteExternalId)
Site site = Site.findByExternalId(ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID, siteExternalId)
if (site) {
site.projects = site.projects ?: []
if (!site.projects.contains(project.id)) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer
"uuid" : "lmpisy5p9g896lad4ut",
"comments" : "Test"]

Map expected = ['name': 'CTMAUA2222', 'description': 'CTMAUA2222', publicationStatus: 'published', 'externalIds': [new ExternalId(externalId: 'lmpisy5p9g896lad4ut', idType: ExternalId.IdType.MONITOR_PLOT_GUID)], 'notes': 'Test', 'extent': ['geometry': ['type': 'Point', 'coordinates': [149.0651439, -35.2592424], 'decimalLatitude': -35.2592424, 'decimalLongitude': 149.0651439], 'source': 'point'], 'projects': [], 'type': 'surveyArea']
Map expected = ['name': 'CTMAUA2222', 'description': 'CTMAUA2222', publicationStatus: 'published', 'externalIds': [new ExternalId(externalId: 'lmpisy5p9g896lad4ut', idType: ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID)], 'notes': 'Test', 'extent': ['geometry': ['type': 'Point', 'coordinates': [149.0651439, -35.2592424], 'decimalLatitude': -35.2592424, 'decimalLongitude': 149.0651439], 'source': 'point'], 'projects': [], 'type': 'surveyArea']

String userId = 'u1'

Expand Down Expand Up @@ -532,7 +532,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest<ParatooSer

Site projectArea = new Site(siteId: 's1', name: 'Site 1', type: Site.TYPE_PROJECT_AREA, extent: [geometry: DUMMY_POLYGON])
projectArea.save(failOnError: true, flush: true)
Site plot = new Site(siteId: 's2', name: "Site 2", type: Site.TYPE_SURVEY_AREA, extent: [geometry: DUMMY_PLOT], projects: ['p1'])
Site plot = new Site(siteId: 's2', name: "Site 2", type: Site.TYPE_SURVEY_AREA, extent: [geometry: DUMMY_PLOT], projects: ['p1'], externalIds:[new ExternalId(externalId: "2", idType: ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID)])
plot.save(failOnError: true, flush: true)
siteService.sitesForProjectWithTypes('p1', [Site.TYPE_PROJECT_AREA, Site.TYPE_SURVEY_AREA]) >> [projectArea, plot]

Expand Down

0 comments on commit 5e4d110

Please sign in to comment.