Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue1641 #1040

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions grails-app/domain/au/org/ala/ecodata/Project.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class Project {

List<OutputTarget> 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

Expand Down Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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())
Expand Down
Loading