diff --git a/grails-app/domain/au/org/ala/ecodata/ExternalId.groovy b/grails-app/domain/au/org/ala/ecodata/ExternalId.groovy index 3257e5320..8ab58aed6 100644 --- a/grails-app/domain/au/org/ala/ecodata/ExternalId.groovy +++ b/grails-app/domain/au/org/ala/ecodata/ExternalId.groovy @@ -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 = { } diff --git a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy index c21beacd9..48d14c548 100644 --- a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy @@ -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 plotSelections = sites.findAll{it.type == Site.TYPE_SURVEY_AREA && it.extent?.geometry?.type == 'Point'} + List plotSelections = sites.findAll{it.externalIds?.find{externalId -> externalId.idType == ExternalId.IdType.MONITOR_PLOT_SELECTION_GUID}} Map attributes = [ id:project.projectId, @@ -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) @@ -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 @@ -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)) { diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy index 3272f699d..9200d6428 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy @@ -239,7 +239,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest> [projectArea, plot]