From b80d3a288ace477a5a48477bc5ec5ff1048d5a64 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 7 Feb 2022 13:21:25 +1100 Subject: [PATCH 1/5] Updated version to 3.4-SNAPSHOT --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 196fac0a5..0f44f97f1 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ plugins { id 'com.craigburke.client-dependencies' version '1.4.0' } -version "3.3" +version "3.4-SNAPSHOT" group "au.org.ala" description "Ecodata" From ffc99f37d95243ea2ba3e098ccd5116e9c5aea7f Mon Sep 17 00:00:00 2001 From: per305 Date: Tue, 15 Feb 2022 16:46:25 +1100 Subject: [PATCH 2/5] Added new fields citation and doiLink --- grails-app/domain/au/org/ala/ecodata/Document.groovy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grails-app/domain/au/org/ala/ecodata/Document.groovy b/grails-app/domain/au/org/ala/ecodata/Document.groovy index f5c1e1ead..edc28ed2e 100644 --- a/grails-app/domain/au/org/ala/ecodata/Document.groovy +++ b/grails-app/domain/au/org/ala/ecodata/Document.groovy @@ -48,6 +48,8 @@ class Document { String type // image, document, sound, etc String role // eg primary, carousel, photoPoint List labels = [] // allow for searching on custom attributes + String citation + String doiLink String status = ACTIVE String projectId @@ -168,6 +170,8 @@ class Document { externalUrl nullable: true projectActivityId nullable: true labels nullable: true + citation nullable: true + doiLink nullable: true isSciStarter nullable: true hosted nullable: true identifier nullable: true From 95db4bf5ebab5c66e941166e6037042936ee527f Mon Sep 17 00:00:00 2001 From: temi Date: Wed, 2 Mar 2022 16:09:01 +1100 Subject: [PATCH 3/5] AtlasOfLivingAustralia/biocollect#1349 added project logo's original url to index --- build.gradle | 2 +- grails-app/conf/application.yml | 1 + .../au/org/ala/ecodata/DocumentService.groovy | 10 ++++-- .../ala/ecodata/ElasticSearchService.groovy | 6 ++-- .../ala/ecodata/DocumentServiceSpec.groovy | 34 +++++++++++++++++-- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 0f44f97f1..78371a620 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ plugins { id 'com.craigburke.client-dependencies' version '1.4.0' } -version "3.4-SNAPSHOT" +version "3.4-biocollect-6.0-SNAPSHOT" group "au.org.ala" description "Ecodata" diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index 7842e7a2a..cb49ca3f5 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -29,6 +29,7 @@ app: - 'url' - 'imageUrl' - 'logoUrl' + - 'fullSizeImageUrl' allowedHostName: 'ala.org.au' info: diff --git a/grails-app/services/au/org/ala/ecodata/DocumentService.groovy b/grails-app/services/au/org/ala/ecodata/DocumentService.groovy index 443df3198..f3f326530 100644 --- a/grails-app/services/au/org/ala/ecodata/DocumentService.groovy +++ b/grails-app/services/au/org/ala/ecodata/DocumentService.groovy @@ -166,11 +166,17 @@ class DocumentService { Document.findAllByProjectActivityIdAndStatus(id, ACTIVE).collect { toMap(it, levelOfDetail) } } - String findImageUrlForProjectId(id, levelOfDetail = []){ + String findImageUrlForProjectId(id, boolean isThumbnail = true){ Document primaryImageDoc; Document logoDoc = Document.findByProjectIdAndRoleAndStatus(id, LOGO, ACTIVE); String urlImage; - urlImage = logoDoc?.url ? logoDoc.getThumbnailUrl() : '' + urlImage = logoDoc?.url + if (urlImage) { + if (isThumbnail) { + urlImage = logoDoc.getThumbnailUrl() + } + } + if(!urlImage){ primaryImageDoc = Document.findByProjectIdAndIsPrimaryProjectImage(id, true) urlImage = primaryImageDoc?.url; diff --git a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy index e864be7c6..998be145b 100644 --- a/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ElasticSearchService.groovy @@ -15,7 +15,7 @@ package au.org.ala.ecodata -import com.vividsolutions.jts.geom.Coordinate + import grails.converters.JSON import grails.core.GrailsApplication import grails.util.Environment @@ -27,8 +27,6 @@ import org.apache.http.client.CredentialsProvider import org.apache.http.impl.client.BasicCredentialsProvider import org.apache.http.impl.nio.client.HttpAsyncClientBuilder import org.elasticsearch.ElasticsearchException -import org.elasticsearch.action.DocWriteResponse -import org.elasticsearch.action.bulk.BulkItemResponse import org.elasticsearch.action.bulk.BulkProcessor import org.elasticsearch.action.bulk.BulkRequest import org.elasticsearch.action.bulk.BulkResponse @@ -70,7 +68,6 @@ import static au.org.ala.ecodata.ElasticIndex.* import static au.org.ala.ecodata.Status.DELETED import static grails.async.Promises.task import static org.elasticsearch.index.query.QueryBuilders.* - /** * ElasticSearch service. This service is responsible for indexing documents as well as handling searches (queries). * @@ -953,6 +950,7 @@ class ElasticSearchService { projectMap.links = documentService.findAllLinksForProjectId(project.projectId) projectMap.isMobileApp = documentService.isMobileAppForProject(projectMap); projectMap.imageUrl = documentService.findImageUrlForProjectId(project.projectId); + projectMap.fullSizeImageUrl = documentService.findImageUrlForProjectId(project.projectId, false) projectMap.logoAttribution = documentService.getLogoAttributionForProjectId(project.projectId) projectMap.admins = permissionService.getAllAdminsForProject(project.projectId)?.collect { it.userId diff --git a/src/test/groovy/au/org/ala/ecodata/DocumentServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/DocumentServiceSpec.groovy index 117e63882..190575c61 100644 --- a/src/test/groovy/au/org/ala/ecodata/DocumentServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/DocumentServiceSpec.groovy @@ -1,7 +1,9 @@ package au.org.ala.ecodata +import grails.test.mongodb.MongoSpec +import grails.testing.gorm.DomainUnitTest import grails.testing.services.ServiceUnitTest -import spock.lang.Specification +import grails.util.Holders /** * Tests the DocumentService. @@ -9,7 +11,7 @@ import spock.lang.Specification * The test landscape image is by Pierre Bouillot. * The test portrait image is by John Salvino. */ -class DocumentServiceSpec extends Specification implements ServiceUnitTest { +class DocumentServiceSpec extends MongoSpec implements ServiceUnitTest, DomainUnitTest { DocumentService service = new DocumentService() File tempUploadDir @@ -24,8 +26,9 @@ class DocumentServiceSpec extends Specification implements ServiceUnitTest Date: Tue, 29 Mar 2022 14:55:15 +1100 Subject: [PATCH 4/5] AtlasOfLivingAustralia/biocollect#1349 fixed issue with creating comments added a migration script --- .../org/ala/ecodata/CommentController.groovy | 6 ++-- .../data_migration/migrateHubsToBS4Config.js | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 scripts/data_migration/migrateHubsToBS4Config.js diff --git a/grails-app/controllers/au/org/ala/ecodata/CommentController.groovy b/grails-app/controllers/au/org/ala/ecodata/CommentController.groovy index 7fe3109b3..91efc9c5b 100644 --- a/grails-app/controllers/au/org/ala/ecodata/CommentController.groovy +++ b/grails-app/controllers/au/org/ala/ecodata/CommentController.groovy @@ -74,7 +74,7 @@ class CommentController { response.addHeader("location", grailsApplication.config.grails.serverURL + "/comment/" + comment.getId().toString()) response.addHeader("entityId", comment.getId().toString()) response.setContentType("application/json") - render model as JSON + render new JSON(model) } else { response.sendError(SC_INTERNAL_SERVER_ERROR, 'Failed saving data to database'); } @@ -105,7 +105,7 @@ class CommentController { result.success = true; } - render(text: result as JSON, contentType: 'application/json'); + render(text: new JSON(result), contentType: 'application/json'); } else { response.sendError(SC_UNAUTHORIZED, 'Only comment owner can update this comment.'); } @@ -146,7 +146,7 @@ class CommentController { Comment c = Comment.get(params.id); if (c) { Map mapOfProperties = commentService.getCommentProperties(c) - render text: mapOfProperties as JSON, contentType: 'application/json' + render text: new JSON(mapOfProperties), contentType: 'application/json' } else { response.sendError(SC_NOT_FOUND, "Comment not found"); } diff --git a/scripts/data_migration/migrateHubsToBS4Config.js b/scripts/data_migration/migrateHubsToBS4Config.js new file mode 100644 index 000000000..d80a4fddb --- /dev/null +++ b/scripts/data_migration/migrateHubsToBS4Config.js @@ -0,0 +1,33 @@ +var updated = 0; +var hubs = db.hub.find({}); +print(`Count ${hubs.count()}`) +while (hubs.hasNext()) { + var hub = hubs.next(); + var updateProps = {}, + type, update = false; + + print(`Hub - ${hub.urlPath}`); + + if (hub.urlPath == 'merit') + continue; + + if (hub.skin != 'bs4') { + updateProps.skin = 'bs4'; + update = true; + print(`Hub ${hub.urlPath} - ${hub.hubId} - has skin ${hub.skin}`); + } + + type = hub.templateConfiguration && hub.templateConfiguration.header && hub.templateConfiguration.header.type; + if (type === 'biocollect') { + updateProps["templateConfiguration.header.type"] = 'custom' + update = true; + print(`Hub ${hub.urlPath} - ${hub.hubId} - has header ${type}`); + } + + if (update) { + db.hub.update({hubId: hub.hubId}, {$set: updateProps}); + updated++; + } +} + +print(`Updated ${updated} hubs`); \ No newline at end of file From 99f84ab0e5efaf292bcc5ad29cb738d531f157dc Mon Sep 17 00:00:00 2001 From: temi Date: Tue, 10 May 2022 11:20:33 +1000 Subject: [PATCH 5/5] updated bs4 migration script --- .../data_migration/migrateHubsToBS4Config.js | 33 ------------ .../biocollect-6.0/migrateHubsToBS4Config.js | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 33 deletions(-) delete mode 100644 scripts/data_migration/migrateHubsToBS4Config.js create mode 100644 scripts/releases/biocollect-6.0/migrateHubsToBS4Config.js diff --git a/scripts/data_migration/migrateHubsToBS4Config.js b/scripts/data_migration/migrateHubsToBS4Config.js deleted file mode 100644 index d80a4fddb..000000000 --- a/scripts/data_migration/migrateHubsToBS4Config.js +++ /dev/null @@ -1,33 +0,0 @@ -var updated = 0; -var hubs = db.hub.find({}); -print(`Count ${hubs.count()}`) -while (hubs.hasNext()) { - var hub = hubs.next(); - var updateProps = {}, - type, update = false; - - print(`Hub - ${hub.urlPath}`); - - if (hub.urlPath == 'merit') - continue; - - if (hub.skin != 'bs4') { - updateProps.skin = 'bs4'; - update = true; - print(`Hub ${hub.urlPath} - ${hub.hubId} - has skin ${hub.skin}`); - } - - type = hub.templateConfiguration && hub.templateConfiguration.header && hub.templateConfiguration.header.type; - if (type === 'biocollect') { - updateProps["templateConfiguration.header.type"] = 'custom' - update = true; - print(`Hub ${hub.urlPath} - ${hub.hubId} - has header ${type}`); - } - - if (update) { - db.hub.update({hubId: hub.hubId}, {$set: updateProps}); - updated++; - } -} - -print(`Updated ${updated} hubs`); \ No newline at end of file diff --git a/scripts/releases/biocollect-6.0/migrateHubsToBS4Config.js b/scripts/releases/biocollect-6.0/migrateHubsToBS4Config.js new file mode 100644 index 000000000..fe22202dc --- /dev/null +++ b/scripts/releases/biocollect-6.0/migrateHubsToBS4Config.js @@ -0,0 +1,54 @@ +var updated = 0; +var hubs = db.hub.find({}); +print(`Count ${hubs.count()}`) +while (hubs.hasNext()) { + var hub = hubs.next(); + var updateProps = {}, + type; + + print(`Hub - ${hub.urlPath}`); + + if (hub.urlPath === 'merit' || hub.urlPath === undefined) + continue; + + if (hub.skin !== 'bs4') { + updateProps.skin = 'bs4'; + print(`Hub ${hub.urlPath} - ${hub.hubId} - has skin ${hub.skin}`); + } + + type = hub.templateConfiguration && hub.templateConfiguration.header && hub.templateConfiguration.header.type; + if (type === 'biocollect' || type === "") { + updateProps["templateConfiguration.header.type"] = 'custom' + print(`Hub ${hub.urlPath} - ${hub.hubId} - has header ${type}`); + } + + copyStyleSheet(hub, updateProps); + + if (Object.keys(updateProps).length) { + db.hub.update({hubId: hub.hubId}, {$set: updateProps}); + updated++; + } +} + +function copyStyleSheet (hub, updateProps) { + var config = hub.templateConfiguration; + var styles = config.styles; + + if(!styles.homepageButtonBackgroundColor && styles.navBackgroundColor){ + updateProps["templateConfiguration.styles.homepageButtonBackgroundColor"] = styles.navBackgroundColor; + } + + if(!styles.homepageButtonTextColor && styles.navTextColor){ + updateProps["templateConfiguration.styles.homepageButtonTextColor"] = styles.navTextColor; + } + + if(!styles.primaryDarkColor && styles.primaryButtonBackgroundColor) { + updateProps["templateConfiguration.styles.primaryDarkColor"] = styles.primaryButtonBackgroundColor; + updateProps["templateConfiguration.styles.primaryColor"] = styles.primaryButtonBackgroundColor; + } + + if (!styles.darkColor && styles.defaultButtonBackgroundColor) + updateProps["templateConfiguration.styles.darkColor"] = styles.defaultButtonBackgroundColor; +} + +print(`Updated ${updated} hubs`);