From b4840430cb32a0a582ee89bdd1ecdecf23d07555 Mon Sep 17 00:00:00 2001 From: sal153 Date: Wed, 16 Oct 2024 17:29:35 +1100 Subject: [PATCH 1/4] commit new fields for biocollect #1641 --- grails-app/domain/au/org/ala/ecodata/Project.groovy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grails-app/domain/au/org/ala/ecodata/Project.groovy b/grails-app/domain/au/org/ala/ecodata/Project.groovy index 6041ba1d1..a0d53a48a 100644 --- a/grails-app/domain/au/org/ala/ecodata/Project.groovy +++ b/grails-app/domain/au/org/ala/ecodata/Project.groovy @@ -120,6 +120,11 @@ class Project { List outputTargets + //New fields to be used bt new search page (initiator=ala response of /ws/project/search) + String numberOfRecords + String publicParticipation + String fundingOrganisation + /** Container to allow program config overrides for an individual Project */ Map config @@ -247,6 +252,9 @@ class Project { geographicInfo nullable:true portfolio nullable: true comment nullable: true + numberOfRecords nullable: true + publicParticipation nullable: true + fundingOrganisation nullable: true projLifecycleStatus nullable: true, inList: [PublicationStatus.PUBLISHED, PublicationStatus.DRAFT] hubId nullable: true, validator: { String hubId, Project project, Errors errors -> GormMongoUtil.validateWriteOnceProperty(project, 'projectId', 'hubId', errors) From 6d04e1b160adc4df47c83b29817b9615a8581b1a Mon Sep 17 00:00:00 2001 From: sal153 Date: Thu, 7 Nov 2024 15:34:45 +1100 Subject: [PATCH 2/4] commit new fields for biocollect #1641 --- .../au/org/ala/ecodata/ElasticSearchService.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy index 7cc950c7d..9f1fda73c 100644 --- a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy @@ -1166,6 +1166,17 @@ class ElasticSearchService { // todo: Check if BioCollect requires all sites in `sites` property. If no, merge `projectArea` with `sites`. projectMap.projectArea = siteService.getSimpleProjectArea(projectMap.projectSiteId) projectMap.containsActivity = activityService.searchAndListActivityDomainObjects([projectId: projectMap.projectId], null, null, null, [max: 1, offset: 0])?.totalCount > 0 + + List projectActivities = projectActivityService.search([projectId: projectMap.projectId]) + boolean publicAccess = true + projectActivities.each {projectActivity -> + if (projectActivity.publicAccess == false) { + publicAccess = false + } + } + projectMap.publicParticipation = publicAccess + projectMap.numberOfRecords = projectActivities.size() + } projectMap.sites?.each { site -> // Not useful for the search index and there is a bug right now that can result in invalid POI From bee6bcb3f1a73638664b5fd2fa037e1d55c610b9 Mon Sep 17 00:00:00 2001 From: sal153 Date: Tue, 12 Nov 2024 12:55:33 +1100 Subject: [PATCH 3/4] commit test fix #1641 --- .../services/au/org/ala/ecodata/ElasticSearchService.groovy | 4 ++-- .../au/org/ala/ecodata/ElasticSearchIndexServiceSpec.groovy | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy index 9f1fda73c..cf4300d43 100644 --- a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy @@ -1167,7 +1167,7 @@ class ElasticSearchService { projectMap.projectArea = siteService.getSimpleProjectArea(projectMap.projectSiteId) projectMap.containsActivity = activityService.searchAndListActivityDomainObjects([projectId: projectMap.projectId], null, null, null, [max: 1, offset: 0])?.totalCount > 0 - List projectActivities = projectActivityService.search([projectId: projectMap.projectId]) + List projectActivities = projectActivityService.search([projectId: projectMap?.projectId]) boolean publicAccess = true projectActivities.each {projectActivity -> if (projectActivity.publicAccess == false) { @@ -1175,7 +1175,7 @@ class ElasticSearchService { } } projectMap.publicParticipation = publicAccess - projectMap.numberOfRecords = projectActivities.size() + projectMap.numberOfRecords = projectActivities?.size() } projectMap.sites?.each { site -> diff --git a/src/test/groovy/au/org/ala/ecodata/ElasticSearchIndexServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ElasticSearchIndexServiceSpec.groovy index 3d03f6b74..8ea7763b0 100644 --- a/src/test/groovy/au/org/ala/ecodata/ElasticSearchIndexServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ElasticSearchIndexServiceSpec.groovy @@ -27,6 +27,7 @@ class ElasticSearchIndexServiceSpec extends MongoSpec implements ServiceUnitTest SiteService siteService = Mock(SiteService) ActivityService activityService = Mock(ActivityService) DocumentService documentService = Mock(DocumentService) + ProjectActivityService projectActivityService = Mock(ProjectActivityService) CacheService cacheService = new CacheService() def setup() { @@ -38,6 +39,7 @@ class ElasticSearchIndexServiceSpec extends MongoSpec implements ServiceUnitTest service.siteService = siteService service.activityService = activityService service.documentService = documentService + service.projectActivityService = projectActivityService JSON.registerObjectMarshaller(new MapMarshaller()) JSON.registerObjectMarshaller(new CollectionMarshaller()) From 9693aba27f35c5ed225de592f5036ccadaa0f61d Mon Sep 17 00:00:00 2001 From: sal153 Date: Tue, 12 Nov 2024 14:53:16 +1100 Subject: [PATCH 4/4] commit updates #1641 --- .../org/ala/ecodata/ElasticSearchService.groovy | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy index cf4300d43..e01e7542c 100644 --- a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy @@ -1168,15 +1168,16 @@ class ElasticSearchService { projectMap.containsActivity = activityService.searchAndListActivityDomainObjects([projectId: projectMap.projectId], null, null, null, [max: 1, offset: 0])?.totalCount > 0 List projectActivities = projectActivityService.search([projectId: projectMap?.projectId]) - boolean publicAccess = true - projectActivities.each {projectActivity -> - if (projectActivity.publicAccess == false) { - publicAccess = false + if (projectActivities?.size() > 0) { + boolean publicParticipation = true + projectActivities.each {projectActivity -> + if (projectActivity.publicAccess == false) { + publicParticipation = false + } } + projectMap.publicParticipation = publicParticipation + projectMap.numberOfRecords = projectActivities.size() } - projectMap.publicParticipation = publicAccess - projectMap.numberOfRecords = projectActivities?.size() - } projectMap.sites?.each { site -> // Not useful for the search index and there is a bug right now that can result in invalid POI