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) diff --git a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy index 7cc950c7d..e01e7542c 100644 --- a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy @@ -1166,6 +1166,18 @@ 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]) + if (projectActivities?.size() > 0) { + boolean publicParticipation = true + projectActivities.each {projectActivity -> + if (projectActivity.publicAccess == false) { + publicParticipation = false + } + } + projectMap.publicParticipation = publicParticipation + 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 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())