diff --git a/build.gradle b/build.gradle index 13fd2a512..78371a620 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ plugins { id 'com.craigburke.client-dependencies' version '1.4.0' } -version "3.3.1" +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/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/grails-app/domain/au/org/ala/ecodata/Document.groovy b/grails-app/domain/au/org/ala/ecodata/Document.groovy index 0473b30ac..d3df8cf45 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 @@ -169,6 +171,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 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/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`); 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