From f01c3fcadab5e8e51a77506f4932ff08addf9a6d Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Mon, 7 Jun 2021 16:22:09 +1000 Subject: [PATCH 001/103] #464 Initial work of upgrading Grails to 3.3.11. NOTE: Build is broken, still working out the event stuff. --- build.gradle | 50 ++++++------------------------ gradle.properties | 8 ++--- grails-app/conf/application.groovy | 7 +++++ 3 files changed, 20 insertions(+), 45 deletions(-) diff --git a/build.gradle b/build.gradle index 21d50fbb5..85d1c86ff 100644 --- a/build.gradle +++ b/build.gradle @@ -122,7 +122,7 @@ repositories { //} dependencies { - // Grails 3.2.11 + // Grails 3.3.11 compile "org.springframework.boot:spring-boot-starter-logging" compile "org.springframework.boot:spring-boot-autoconfigure" compile "org.grails:grails-core" @@ -130,9 +130,10 @@ dependencies { compile "org.springframework.boot:spring-boot-starter-tomcat" compile "org.grails:grails-dependencies" compile "org.grails:grails-web-boot" - compile "org.grails.plugins:cache" + compile "org.grails.plugins:cache:4.0.0" compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}" + compile "org.grails.plugins:converters" compile "org.hibernate:hibernate-core:5.1.3.Final" compile "org.hibernate:hibernate-ehcache:5.1.3.Final" console "org.grails:grails-console" @@ -140,13 +141,16 @@ dependencies { profile "org.grails.profiles:web" compile "com.bertramlabs.plugins:asset-pipeline-grails:$assetPipelineVersion" assets "com.bertramlabs.plugins:sass-asset-pipeline:$assetPipelineVersion" - testCompile "org.grails:grails-plugin-testing" + //testCompile "org.grails:grails-plugin-testing" // Moved in upgrade to Grails 3.3.11 + testCompile "org.grails:grails-test-mixins:3.3.0" // For legacy @TestMixin and @TestFor testCompile "org.grails.plugins:geb" testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" testRuntime "net.sourceforge.htmlunit:htmlunit:2.18" compile "org.grails.plugins:grails-java8" - compile "org.grails.plugins:rxjava2:2.0.0" + //compile "org.grails.plugins:rxjava2:2.0.0" + compile "org.grails:grails-events-rxjava" + compile "org.codehaus.gpars:gpars:1.2.1" // Added for the GPars dependencies. compile "org.hibernate:hibernate-java8:5.1.3.Final" // Additional Plugins @@ -163,15 +167,9 @@ dependencies { // TODO ALA Plugins: image service (is it used anywhere?) compile 'org.grails.plugins:ala-auth:3.0.5' compile 'au.org.ala:userdetails-service-client:1.4.0' // override this to for external properties changes - compile 'org.grails.plugins:cache-ehcache:2.0.0.BUILD-SNAPSHOT' - //compile 'org.grails.plugins:cache-ehcache:3.0.0.M1' + compile 'org.grails.plugins:cache-ehcache:3.0.0' // TODO Collection Event Controller? - // BOOTSTRAP, FONT-AWESOME? NPM? Yarn? webjars ? -// compile 'org.webjars:bootstrap:3.3.7-1' -// compile 'org.webjars:angularjs:1.6.1' -// compile 'org.webjars:font-awesome:4.7.0' - // Dependencies runtime "org.postgresql:postgresql:$postgresVersion" compile 'org.imgscalr:imgscalr-lib:4.2' @@ -280,33 +278,3 @@ publish { dependsOn assemble } - -//node { -// // Version of node to use. -// version = '6.9.4' -// -// // Version of npm to use. -// npmVersion = '3.10.10' -// -// // Version of Yarn to use. -// yarnVersion = '0.16.1' -// -// // Base URL for fetching node distributions (change if you have a mirror). -// distBaseUrl = 'https://nodejs.org/dist' -// -// // If true, it will download node using above parameters. -// // If false, it will try to use globally installed node. -// download = false -// -// // Set the work directory for unpacking node -// workDir = file("${project.buildDir}/nodejs") -// -// // Set the work directory for NPM -// npmWorkDir = file("${project.buildDir}/npm") -// -// // Set the work directory for Yarn -// yarnWorkDir = file("${project.buildDir}/yarn") -// -// // Set the work directory where node_modules should be located -// nodeModulesDir = file("${project.projectDir}/grails-app/assets") -//} diff --git a/gradle.properties b/gradle.properties index 221d0515f..c85aeb94e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ #Sat Jan 21 22:08:45 AEDT 2017 -grailsVersion=3.2.11 -gormVersion=6.0.12.RELEASE +grailsVersion=3.3.11 +gormVersion=6.1.12.RELEASE grailsWrapperVersion=1.0.0 -gradleWrapperVersion=3.4.1 -assetPipelineVersion=2.14.7 +gradleWrapperVersion=3.5.0 +assetPipelineVersion=2.15.1 postgresVersion=42.2.11 diff --git a/grails-app/conf/application.groovy b/grails-app/conf/application.groovy index 580ff5b40..a70005180 100644 --- a/grails-app/conf/application.groovy +++ b/grails-app/conf/application.groovy @@ -101,6 +101,13 @@ grails { } } + gorm { + 'default' { + mapping = { + autowire: true + } + } + } // gorm { // 'default' { // mapping = { From 966da2e4fee2d29da8df801de95c3f109a13d9c8 Mon Sep 17 00:00:00 2001 From: Simon Bear Date: Mon, 7 Jun 2021 17:21:08 +1000 Subject: [PATCH 002/103] Use Hibernate 5.2 --- build.gradle | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 85d1c86ff..f752b9c49 100644 --- a/build.gradle +++ b/build.gradle @@ -134,8 +134,9 @@ dependencies { compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}" compile "org.grails.plugins:converters" - compile "org.hibernate:hibernate-core:5.1.3.Final" - compile "org.hibernate:hibernate-ehcache:5.1.3.Final" + compile "org.hibernate:hibernate-core:5.2.17.Final" + compile "org.hibernate:hibernate-ehcache:5.2.17.Final" + compile "org.hibernate:hibernate-java8:5.2.17.Final" console "org.grails:grails-console" compile "com.drewnoakes:metadata-extractor:2.11.0" profile "org.grails.profiles:web" @@ -156,7 +157,7 @@ dependencies { // Additional Plugins compile 'org.grails.plugins:cache-headers:2.0.2' compile 'org.grails.plugins:csv:1.0.ALA.3' - compile 'org.grails.plugins:postgresql-extensions:5.2.0' + compile 'org.grails.plugins:postgresql-extensions:6.1.0' compile 'org.grails.plugins:mail:2.0.0.RC6' compile 'org.grails.plugins:grails-executor:0.4' // used in TaskLoadService.backgroundProcessQueue compile 'org.grails.plugins:grails-markdown:3.0.0' // may need modifications? From 050f46572c3b085da8678dd3835a88fda231c979 Mon Sep 17 00:00:00 2001 From: Simon Bear Date: Mon, 7 Jun 2021 17:24:16 +1000 Subject: [PATCH 003/103] Update @Transactional annotations --- .../org/ala/volunteer/AchievementDescriptionController.groovy | 2 +- .../au/org/ala/volunteer/FrontPageController.groovy | 3 ++- .../au/org/ala/volunteer/LandingPageAdminController.groovy | 2 +- .../au/org/ala/volunteer/LeaderBoardAdminController.groovy | 2 +- .../au/org/ala/volunteer/TemplateController.groovy | 2 +- .../controllers/au/org/ala/volunteer/UserController.groovy | 2 +- .../services/au/org/ala/volunteer/AchievementService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/AdminService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/AuditService.groovy | 2 +- .../au/org/ala/volunteer/CollectionEventService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/ExportService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/FieldService.groovy | 2 +- .../services/au/org/ala/volunteer/FieldSyncService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/ForumService.groovy | 2 +- .../services/au/org/ala/volunteer/FullTextIndexService.groovy | 4 ++-- .../services/au/org/ala/volunteer/ImageServiceService.groovy | 2 +- .../services/au/org/ala/volunteer/LeaderBoardService.groovy | 2 +- .../services/au/org/ala/volunteer/LocalityService.groovy | 2 +- .../services/au/org/ala/volunteer/MultimediaService.groovy | 2 +- .../services/au/org/ala/volunteer/PicklistService.groovy | 2 +- .../services/au/org/ala/volunteer/ProjectService.groovy | 3 ++- .../services/au/org/ala/volunteer/SettingsService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/StatsService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/TaskService.groovy | 4 ++-- .../services/au/org/ala/volunteer/TemplateFieldService.groovy | 2 +- .../services/au/org/ala/volunteer/TemplateService.groovy | 2 +- grails-app/services/au/org/ala/volunteer/UserService.groovy | 4 ++-- .../services/au/org/ala/volunteer/ValidationService.groovy | 2 +- .../au/org/ala/volunteer/VolunteerStatsService.groovy | 2 +- 29 files changed, 34 insertions(+), 32 deletions(-) diff --git a/grails-app/controllers/au/org/ala/volunteer/AchievementDescriptionController.groovy b/grails-app/controllers/au/org/ala/volunteer/AchievementDescriptionController.groovy index 43afd5fce..e720cc1e5 100644 --- a/grails-app/controllers/au/org/ala/volunteer/AchievementDescriptionController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/AchievementDescriptionController.groovy @@ -7,7 +7,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest import static grails.async.Promises.* import static org.springframework.http.HttpStatus.* -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional @AlaSecured("ROLE_VP_ADMIN") class AchievementDescriptionController { diff --git a/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy b/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy index 9d18ecaa8..b3c1fbd18 100644 --- a/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy @@ -1,6 +1,7 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.events.EventPublisher +import grails.gorm.transactions.Transactional import org.springframework.web.multipart.MultipartFile class FrontPageController { diff --git a/grails-app/controllers/au/org/ala/volunteer/LandingPageAdminController.groovy b/grails-app/controllers/au/org/ala/volunteer/LandingPageAdminController.groovy index 7ee01cb34..9cb1981d5 100644 --- a/grails-app/controllers/au/org/ala/volunteer/LandingPageAdminController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/LandingPageAdminController.groovy @@ -1,7 +1,7 @@ package au.org.ala.volunteer import au.org.ala.web.AlaSecured -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import grails.converters.JSON import static org.springframework.http.HttpStatus.CREATED import static org.springframework.http.HttpStatus.NO_CONTENT diff --git a/grails-app/controllers/au/org/ala/volunteer/LeaderBoardAdminController.groovy b/grails-app/controllers/au/org/ala/volunteer/LeaderBoardAdminController.groovy index 75a6d5454..feb54b2f3 100644 --- a/grails-app/controllers/au/org/ala/volunteer/LeaderBoardAdminController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/LeaderBoardAdminController.groovy @@ -2,7 +2,7 @@ package au.org.ala.volunteer import au.org.ala.web.AlaSecured import grails.converters.JSON -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional @AlaSecured("ROLE_VP_ADMIN") class LeaderBoardAdminController { diff --git a/grails-app/controllers/au/org/ala/volunteer/TemplateController.groovy b/grails-app/controllers/au/org/ala/volunteer/TemplateController.groovy index 9e4ed4c6b..c4434f330 100644 --- a/grails-app/controllers/au/org/ala/volunteer/TemplateController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/TemplateController.groovy @@ -2,7 +2,7 @@ package au.org.ala.volunteer import com.google.common.hash.HashCode import grails.converters.JSON -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import org.apache.commons.io.FilenameUtils import org.springframework.dao.DataIntegrityViolationException import org.springframework.web.multipart.MultipartFile diff --git a/grails-app/controllers/au/org/ala/volunteer/UserController.groovy b/grails-app/controllers/au/org/ala/volunteer/UserController.groovy index f526fd89f..45fbac2e4 100644 --- a/grails-app/controllers/au/org/ala/volunteer/UserController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/UserController.groovy @@ -2,7 +2,7 @@ package au.org.ala.volunteer import com.google.common.base.Stopwatch import grails.converters.JSON -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import org.elasticsearch.action.search.SearchResponse import org.elasticsearch.action.search.SearchType import org.springframework.dao.DataIntegrityViolationException diff --git a/grails-app/services/au/org/ala/volunteer/AchievementService.groovy b/grails-app/services/au/org/ala/volunteer/AchievementService.groovy index 51cfaa824..f87cb10a4 100644 --- a/grails-app/services/au/org/ala/volunteer/AchievementService.groovy +++ b/grails-app/services/au/org/ala/volunteer/AchievementService.groovy @@ -2,7 +2,7 @@ package au.org.ala.volunteer import com.google.common.io.Closer import grails.gorm.DetachedCriteria -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import groovy.time.TimeCategory import org.apache.commons.pool2.impl.GenericKeyedObjectPool import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig diff --git a/grails-app/services/au/org/ala/volunteer/AdminService.groovy b/grails-app/services/au/org/ala/volunteer/AdminService.groovy index c26eb78da..9b83c7872 100644 --- a/grails-app/services/au/org/ala/volunteer/AdminService.groovy +++ b/grails-app/services/au/org/ala/volunteer/AdminService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional @Transactional class AdminService { diff --git a/grails-app/services/au/org/ala/volunteer/AuditService.groovy b/grails-app/services/au/org/ala/volunteer/AuditService.groovy index 4b5eb32b2..3bb5d23a6 100644 --- a/grails-app/services/au/org/ala/volunteer/AuditService.groovy +++ b/grails-app/services/au/org/ala/volunteer/AuditService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional @Transactional class AuditService { diff --git a/grails-app/services/au/org/ala/volunteer/CollectionEventService.groovy b/grails-app/services/au/org/ala/volunteer/CollectionEventService.groovy index e88b92c0d..cadc10fec 100644 --- a/grails-app/services/au/org/ala/volunteer/CollectionEventService.groovy +++ b/grails-app/services/au/org/ala/volunteer/CollectionEventService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import java.util.regex.Pattern import org.hibernate.FlushMode diff --git a/grails-app/services/au/org/ala/volunteer/ExportService.groovy b/grails-app/services/au/org/ala/volunteer/ExportService.groovy index eda31840d..3b042389c 100644 --- a/grails-app/services/au/org/ala/volunteer/ExportService.groovy +++ b/grails-app/services/au/org/ala/volunteer/ExportService.groovy @@ -3,7 +3,7 @@ package au.org.ala.volunteer import au.com.bytecode.opencsv.CSVWriter import au.org.ala.web.UserDetails import com.google.common.base.Stopwatch -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicInteger diff --git a/grails-app/services/au/org/ala/volunteer/FieldService.groovy b/grails-app/services/au/org/ala/volunteer/FieldService.groovy index 57af51ac4..eb976a405 100644 --- a/grails-app/services/au/org/ala/volunteer/FieldService.groovy +++ b/grails-app/services/au/org/ala/volunteer/FieldService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import groovy.sql.Sql import javax.sql.DataSource diff --git a/grails-app/services/au/org/ala/volunteer/FieldSyncService.groovy b/grails-app/services/au/org/ala/volunteer/FieldSyncService.groovy index 407e7de56..2050bbb83 100644 --- a/grails-app/services/au/org/ala/volunteer/FieldSyncService.groovy +++ b/grails-app/services/au/org/ala/volunteer/FieldSyncService.groovy @@ -1,7 +1,7 @@ package au.org.ala.volunteer import grails.gorm.DetachedCriteria -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import org.apache.commons.lang3.StringUtils @Transactional diff --git a/grails-app/services/au/org/ala/volunteer/ForumService.groovy b/grails-app/services/au/org/ala/volunteer/ForumService.groovy index 6dea2f1f2..22711d3e0 100644 --- a/grails-app/services/au/org/ala/volunteer/ForumService.groovy +++ b/grails-app/services/au/org/ala/volunteer/ForumService.groovy @@ -1,7 +1,7 @@ package au.org.ala.volunteer import grails.orm.PagedResultList -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import groovy.time.TimeDuration @Transactional diff --git a/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy b/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy index fa266d4ca..75aa0587a 100644 --- a/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy +++ b/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy @@ -2,8 +2,8 @@ package au.org.ala.volunteer import grails.async.Promises import grails.converters.JSON -import grails.transaction.NotTransactional -import grails.transaction.Transactional +import grails.gorm.transactions.NotTransactional +import grails.gorm.transactions.Transactional import groovy.json.JsonSlurper import org.apache.commons.lang.NotImplementedException import org.elasticsearch.index.query.FilterBuilders diff --git a/grails-app/services/au/org/ala/volunteer/ImageServiceService.groovy b/grails-app/services/au/org/ala/volunteer/ImageServiceService.groovy index 754a369ae..27c5c8675 100644 --- a/grails-app/services/au/org/ala/volunteer/ImageServiceService.groovy +++ b/grails-app/services/au/org/ala/volunteer/ImageServiceService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import groovy.json.JsonBuilder import groovyx.net.http.ContentType import groovyx.net.http.HTTPBuilder diff --git a/grails-app/services/au/org/ala/volunteer/LeaderBoardService.groovy b/grails-app/services/au/org/ala/volunteer/LeaderBoardService.groovy index 644999913..14b16c7c6 100644 --- a/grails-app/services/au/org/ala/volunteer/LeaderBoardService.groovy +++ b/grails-app/services/au/org/ala/volunteer/LeaderBoardService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.NotTransactional +import grails.gorm.transactions.NotTransactional class LeaderBoardService { diff --git a/grails-app/services/au/org/ala/volunteer/LocalityService.groovy b/grails-app/services/au/org/ala/volunteer/LocalityService.groovy index 8d4702fbb..9790f1366 100644 --- a/grails-app/services/au/org/ala/volunteer/LocalityService.groovy +++ b/grails-app/services/au/org/ala/volunteer/LocalityService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import org.springframework.web.multipart.MultipartFile import org.hibernate.FlushMode import org.hibernate.Criteria diff --git a/grails-app/services/au/org/ala/volunteer/MultimediaService.groovy b/grails-app/services/au/org/ala/volunteer/MultimediaService.groovy index 831a32bd4..07d8d59dc 100644 --- a/grails-app/services/au/org/ala/volunteer/MultimediaService.groovy +++ b/grails-app/services/au/org/ala/volunteer/MultimediaService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import org.apache.commons.io.FileUtils import org.apache.commons.lang.StringUtils diff --git a/grails-app/services/au/org/ala/volunteer/PicklistService.groovy b/grails-app/services/au/org/ala/volunteer/PicklistService.groovy index 755a3807f..fa0e8b3d8 100644 --- a/grails-app/services/au/org/ala/volunteer/PicklistService.groovy +++ b/grails-app/services/au/org/ala/volunteer/PicklistService.groovy @@ -2,7 +2,7 @@ package au.org.ala.volunteer import au.com.bytecode.opencsv.CSVReader import grails.plugins.csv.CSVReaderUtils -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional //import org.grails.plugins.domain.DomainClassGrailsPlugin import org.hibernate.FlushMode diff --git a/grails-app/services/au/org/ala/volunteer/ProjectService.groovy b/grails-app/services/au/org/ala/volunteer/ProjectService.groovy index 57c00adf7..978dc1bc0 100644 --- a/grails-app/services/au/org/ala/volunteer/ProjectService.groovy +++ b/grails-app/services/au/org/ala/volunteer/ProjectService.groovy @@ -2,7 +2,8 @@ package au.org.ala.volunteer import au.org.ala.volunteer.jooq.tables.ProjectLabels import com.google.common.base.Stopwatch -import grails.transaction.Transactional +import grails.events.EventPublisher +import grails.gorm.transactions.Transactional import grails.web.mapping.LinkGenerator import groovy.transform.Immutable import groovy.transform.stc.ClosureParams diff --git a/grails-app/services/au/org/ala/volunteer/SettingsService.groovy b/grails-app/services/au/org/ala/volunteer/SettingsService.groovy index b1f6efd34..2afaad9c2 100644 --- a/grails-app/services/au/org/ala/volunteer/SettingsService.groovy +++ b/grails-app/services/au/org/ala/volunteer/SettingsService.groovy @@ -1,7 +1,7 @@ package au.org.ala.volunteer import grails.converters.JSON -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional @Transactional(readOnly = true) class SettingsService { diff --git a/grails-app/services/au/org/ala/volunteer/StatsService.groovy b/grails-app/services/au/org/ala/volunteer/StatsService.groovy index df5512e3c..fceee3525 100644 --- a/grails-app/services/au/org/ala/volunteer/StatsService.groovy +++ b/grails-app/services/au/org/ala/volunteer/StatsService.groovy @@ -1,7 +1,7 @@ package au.org.ala.volunteer import com.google.common.base.Stopwatch -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import groovy.sql.Sql import javax.sql.DataSource diff --git a/grails-app/services/au/org/ala/volunteer/TaskService.groovy b/grails-app/services/au/org/ala/volunteer/TaskService.groovy index a15f01ce6..37ba43ebc 100644 --- a/grails-app/services/au/org/ala/volunteer/TaskService.groovy +++ b/grails-app/services/au/org/ala/volunteer/TaskService.groovy @@ -4,8 +4,8 @@ import au.org.ala.web.UserDetails import com.google.common.base.Stopwatch import grails.plugin.cache.CacheEvict import grails.plugin.cache.Cacheable -import grails.transaction.NotTransactional -import grails.transaction.Transactional +import grails.gorm.transactions.NotTransactional +import grails.gorm.transactions.Transactional import groovy.sql.Sql import org.imgscalr.Scalr import org.jooq.DSLContext diff --git a/grails-app/services/au/org/ala/volunteer/TemplateFieldService.groovy b/grails-app/services/au/org/ala/volunteer/TemplateFieldService.groovy index d287fbcea..d6f4f3bdc 100644 --- a/grails-app/services/au/org/ala/volunteer/TemplateFieldService.groovy +++ b/grails-app/services/au/org/ala/volunteer/TemplateFieldService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import org.springframework.web.multipart.MultipartFile @Transactional(readOnly = true) diff --git a/grails-app/services/au/org/ala/volunteer/TemplateService.groovy b/grails-app/services/au/org/ala/volunteer/TemplateService.groovy index d068b5f36..89ad0c527 100644 --- a/grails-app/services/au/org/ala/volunteer/TemplateService.groovy +++ b/grails-app/services/au/org/ala/volunteer/TemplateService.groovy @@ -3,7 +3,7 @@ package au.org.ala.volunteer import com.google.common.io.Resources import grails.core.GrailsApplication import grails.converters.JSON -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import grails.util.Environment import java.util.regex.Pattern diff --git a/grails-app/services/au/org/ala/volunteer/UserService.groovy b/grails-app/services/au/org/ala/volunteer/UserService.groovy index c1d8f513a..9d4a501d0 100644 --- a/grails-app/services/au/org/ala/volunteer/UserService.groovy +++ b/grails-app/services/au/org/ala/volunteer/UserService.groovy @@ -4,8 +4,8 @@ import au.org.ala.cas.util.AuthenticationUtils import au.org.ala.userdetails.UserDetailsFromIdListResponse import au.org.ala.web.UserDetails import com.google.common.base.Stopwatch -import grails.transaction.NotTransactional -import grails.transaction.Transactional +import grails.gorm.transactions.NotTransactional +import grails.gorm.transactions.Transactional import groovy.sql.Sql import grails.web.servlet.mvc.GrailsParameterMap import org.elasticsearch.action.search.SearchResponse diff --git a/grails-app/services/au/org/ala/volunteer/ValidationService.groovy b/grails-app/services/au/org/ala/volunteer/ValidationService.groovy index 300a6c4f9..f0af9b0f8 100644 --- a/grails-app/services/au/org/ala/volunteer/ValidationService.groovy +++ b/grails-app/services/au/org/ala/volunteer/ValidationService.groovy @@ -1,6 +1,6 @@ package au.org.ala.volunteer -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional @Transactional /** diff --git a/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy b/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy index bfe26c169..1c90c5844 100644 --- a/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy +++ b/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy @@ -2,7 +2,7 @@ package au.org.ala.volunteer import com.google.common.base.Stopwatch import grails.gorm.DetachedCriteria -import grails.transaction.Transactional +import grails.gorm.transactions.Transactional import grails.plugin.cache.Cacheable import javax.annotation.PostConstruct import static java.util.concurrent.TimeUnit.MILLISECONDS From a075e72b84977a21f48323b38a5b9935d4d841e8 Mon Sep 17 00:00:00 2001 From: Simon Bear Date: Mon, 7 Jun 2021 17:25:24 +1000 Subject: [PATCH 004/103] Updates for new Grails Events plugins --- build.gradle | 9 +++++---- .../au/org/ala/volunteer/FrontPageController.groovy | 2 +- .../au/org/ala/volunteer/AchievementService.groovy | 7 ++++++- .../au/org/ala/volunteer/EventSourceService.groovy | 2 ++ .../au/org/ala/volunteer/FrontPageService.groovy | 5 ++++- .../services/au/org/ala/volunteer/ProjectService.groovy | 2 +- .../services/au/org/ala/volunteer/TaskLoadService.groovy | 3 ++- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index f752b9c49..0779c2fdd 100644 --- a/build.gradle +++ b/build.gradle @@ -148,11 +148,12 @@ dependencies { testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" testRuntime "net.sourceforge.htmlunit:htmlunit:2.18" + compile "org.grails:grails-async-gpars" + compile "org.grails:grails-events-rxjava2" compile "org.grails.plugins:grails-java8" - //compile "org.grails.plugins:rxjava2:2.0.0" - compile "org.grails:grails-events-rxjava" - compile "org.codehaus.gpars:gpars:1.2.1" // Added for the GPars dependencies. - compile "org.hibernate:hibernate-java8:5.1.3.Final" + compile "org.grails.plugins:rxjava2:2.0.0" +// compile "org.codehaus.gpars:gpars:1.2.1" // Added for the GPars dependencies. + compile "io.reactivex.rxjava2:rxjava:2.1.3" // Additional Plugins compile 'org.grails.plugins:cache-headers:2.0.2' diff --git a/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy b/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy index b3c1fbd18..3e1580dd2 100644 --- a/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/FrontPageController.groovy @@ -4,7 +4,7 @@ import grails.events.EventPublisher import grails.gorm.transactions.Transactional import org.springframework.web.multipart.MultipartFile -class FrontPageController { +class FrontPageController implements EventPublisher { def userService def fileUploadService diff --git a/grails-app/services/au/org/ala/volunteer/AchievementService.groovy b/grails-app/services/au/org/ala/volunteer/AchievementService.groovy index f87cb10a4..e820d54f6 100644 --- a/grails-app/services/au/org/ala/volunteer/AchievementService.groovy +++ b/grails-app/services/au/org/ala/volunteer/AchievementService.groovy @@ -1,6 +1,8 @@ package au.org.ala.volunteer import com.google.common.io.Closer +import grails.events.EventPublisher +import grails.events.annotation.Subscriber import grails.gorm.DetachedCriteria import grails.gorm.transactions.Transactional import groovy.time.TimeCategory @@ -26,7 +28,7 @@ import static org.hibernate.FetchMode.* @Consumer @Transactional -class AchievementService { +class AchievementService implements EventPublisher { public static final String ACHIEVEMENT_AWARDED = 'achievement.awarded' public static final String ACHIEVEMENT_VIEWED = 'achievement.viewed' @@ -296,6 +298,8 @@ class AchievementService { } + // TODO Update to @Subscriber +// @Subscriber('achievement.awarded') @Selector('achievement.awarded') void achievementAwarded(AchievementAward award) { try { @@ -306,6 +310,7 @@ class AchievementService { } } + // @Subscriber('achievement.viewed') @Selector('achievement.viewed') void achievementViewed(Map args) { try { diff --git a/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy b/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy index afd4a9171..dbe0195db 100644 --- a/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy +++ b/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy @@ -1,6 +1,7 @@ package au.org.ala.volunteer import au.org.ala.web.UserDetails +import grails.events.annotation.Subscriber import io.reactivex.Observable import io.reactivex.subjects.Subject import io.reactivex.subjects.UnicastSubject @@ -141,6 +142,7 @@ class EventSourceService { .filter { !it.to || it.to == userId } } +// @Subscriber(EventSourceService.NEW_MESSAGE) @Selector(EventSourceService.NEW_MESSAGE) void newMessage(Message.EventSourceMessage message) { for (def kv : ongoingRequests) { diff --git a/grails-app/services/au/org/ala/volunteer/FrontPageService.groovy b/grails-app/services/au/org/ala/volunteer/FrontPageService.groovy index 899a34bef..851083de0 100644 --- a/grails-app/services/au/org/ala/volunteer/FrontPageService.groovy +++ b/grails-app/services/au/org/ala/volunteer/FrontPageService.groovy @@ -1,5 +1,7 @@ package au.org.ala.volunteer +import grails.events.EventPublisher +import grails.events.annotation.Subscriber import reactor.spring.context.annotation.Consumer import reactor.spring.context.annotation.Selector @@ -7,7 +9,7 @@ import javax.annotation.PostConstruct import javax.annotation.PreDestroy @Consumer -class FrontPageService { +class FrontPageService implements EventPublisher { public static final String ALERT_MESSAGE = 'alertMessage' @@ -34,6 +36,7 @@ class FrontPageService { new Message.EventSourceMessage(event: ALERT_MESSAGE, data: message) } +// @Subscriber(FrontPageService.ALERT_MESSAGE) @Selector(FrontPageService.ALERT_MESSAGE) void alertMessage(String alert) { try { diff --git a/grails-app/services/au/org/ala/volunteer/ProjectService.groovy b/grails-app/services/au/org/ala/volunteer/ProjectService.groovy index 978dc1bc0..3b7d5684a 100644 --- a/grails-app/services/au/org/ala/volunteer/ProjectService.groovy +++ b/grails-app/services/au/org/ala/volunteer/ProjectService.groovy @@ -49,7 +49,7 @@ import static org.jooq.impl.DSL.sum as jSum import static org.jooq.impl.DSL.when as jWhen @Transactional -class ProjectService { +class ProjectService implements EventPublisher { static final String TASK_COUNT_COLUMN = 'taskCount' static final String TRANSCRIBED_COUNT_COLUMN = 'transcribedCount' diff --git a/grails-app/services/au/org/ala/volunteer/TaskLoadService.groovy b/grails-app/services/au/org/ala/volunteer/TaskLoadService.groovy index 20e5b9843..b90ad2879 100644 --- a/grails-app/services/au/org/ala/volunteer/TaskLoadService.groovy +++ b/grails-app/services/au/org/ala/volunteer/TaskLoadService.groovy @@ -7,6 +7,7 @@ import au.org.ala.volunteer.jooq.tables.records.ProjectRecord import au.org.ala.volunteer.jooq.tables.records.ShadowFileDescriptorRecord import au.org.ala.volunteer.jooq.tables.records.TaskDescriptorRecord import au.org.ala.volunteer.jooq.tables.records.TaskRecord +import grails.events.EventPublisher import groovy.transform.stc.ClosureParams import groovy.transform.stc.FirstParam import groovy.util.logging.Slf4j @@ -43,7 +44,7 @@ import static org.jooq.impl.DSL.when // Transactions will be controlled explicitly @Slf4j -class TaskLoadService { +class TaskLoadService implements EventPublisher { // explicity control transactions with jooq static transactional = false From 8c7cf4ee5d3ec232b46491d8b6d389a80a2b68c1 Mon Sep 17 00:00:00 2001 From: Simon Bear Date: Mon, 7 Jun 2021 17:26:23 +1000 Subject: [PATCH 005/103] Re-add explicit GPars dependency --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0779c2fdd..34fe4c08e 100644 --- a/build.gradle +++ b/build.gradle @@ -152,7 +152,7 @@ dependencies { compile "org.grails:grails-events-rxjava2" compile "org.grails.plugins:grails-java8" compile "org.grails.plugins:rxjava2:2.0.0" -// compile "org.codehaus.gpars:gpars:1.2.1" // Added for the GPars dependencies. + compile "org.codehaus.gpars:gpars:1.2.1" // Added for the GPars dependencies. compile "io.reactivex.rxjava2:rxjava:2.1.3" // Additional Plugins From 4f0dfbf0cceb0d13995aa5ba5137f64340b1cf12 Mon Sep 17 00:00:00 2001 From: Simon Bear Date: Mon, 7 Jun 2021 17:26:34 +1000 Subject: [PATCH 006/103] Update retrofit version --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 34fe4c08e..61f98f0b2 100644 --- a/build.gradle +++ b/build.gradle @@ -175,8 +175,8 @@ dependencies { // Dependencies runtime "org.postgresql:postgresql:$postgresVersion" compile 'org.imgscalr:imgscalr-lib:4.2' - compile 'com.squareup.retrofit2:retrofit:2.2.0' - compile 'com.squareup.retrofit2:converter-gson:2.2.0' + compile 'com.squareup.retrofit2:retrofit:2.4.0' + compile 'com.squareup.retrofit2:converter-gson:2.4.0' compile 'com.google.guava:guava:19.0' compile 'com.github.ben-manes.caffeine:caffeine:2.8.0' compile 'org.apache.commons:commons-compress:1.11' From 1f4cd4464080c8b685e5182333eda004ebbb8e73 Mon Sep 17 00:00:00 2001 From: Simon Bear Date: Mon, 7 Jun 2021 17:39:13 +1000 Subject: [PATCH 007/103] Use latest 4.0 grails cache release, force ehcache version to match cache-ehcache plugin dependency --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 61f98f0b2..ff58a666f 100644 --- a/build.gradle +++ b/build.gradle @@ -130,7 +130,7 @@ dependencies { compile "org.springframework.boot:spring-boot-starter-tomcat" compile "org.grails:grails-dependencies" compile "org.grails:grails-web-boot" - compile "org.grails.plugins:cache:4.0.0" + compile "org.grails.plugins:cache:4.0.3" compile "org.grails.plugins:scaffolding" compile "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}" compile "org.grails.plugins:converters" @@ -170,6 +170,7 @@ dependencies { compile 'org.grails.plugins:ala-auth:3.0.5' compile 'au.org.ala:userdetails-service-client:1.4.0' // override this to for external properties changes compile 'org.grails.plugins:cache-ehcache:3.0.0' + compile 'org.ehcache:ehcache:3.4.0' // Prevent cache-ehcache dependent version being overridden // TODO Collection Event Controller? // Dependencies From 78e4e7d0f6ef436a52bb84b893d9f9d17abe30cf Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Tue, 8 Jun 2021 11:46:05 +1000 Subject: [PATCH 008/103] #464 Added logging annotation --- .../au/org/ala/volunteer/AchievementsInterceptor.groovy | 2 ++ .../au/org/ala/volunteer/DigivolActivityInterceptor.groovy | 2 ++ 2 files changed, 4 insertions(+) diff --git a/grails-app/controllers/au/org/ala/volunteer/AchievementsInterceptor.groovy b/grails-app/controllers/au/org/ala/volunteer/AchievementsInterceptor.groovy index a4eb6c3a8..6401fa5cd 100644 --- a/grails-app/controllers/au/org/ala/volunteer/AchievementsInterceptor.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/AchievementsInterceptor.groovy @@ -1,8 +1,10 @@ package au.org.ala.volunteer import groovy.transform.CompileStatic +import groovy.util.logging.Slf4j @CompileStatic +@Slf4j class AchievementsInterceptor { DomainUpdateService domainUpdateService diff --git a/grails-app/controllers/au/org/ala/volunteer/DigivolActivityInterceptor.groovy b/grails-app/controllers/au/org/ala/volunteer/DigivolActivityInterceptor.groovy index 0b4846669..c5d0fe2c6 100644 --- a/grails-app/controllers/au/org/ala/volunteer/DigivolActivityInterceptor.groovy +++ b/grails-app/controllers/au/org/ala/volunteer/DigivolActivityInterceptor.groovy @@ -2,8 +2,10 @@ package au.org.ala.volunteer import au.org.ala.cas.util.AuthenticationCookieUtils import groovy.transform.CompileStatic +import groovy.util.logging.Slf4j @CompileStatic +@Slf4j class DigivolActivityInterceptor { UserService userService From 7a10f4e072e4e48db2408d84f63b073e9c51ace7 Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Tue, 8 Jun 2021 11:47:50 +1000 Subject: [PATCH 009/103] #464 Updated cache keys for new version. Also cleaned up TaskService a bit. --- .../au/org/ala/volunteer/TaskService.groovy | 95 ++++++++++--------- .../volunteer/VolunteerStatsService.groovy | 2 +- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/grails-app/services/au/org/ala/volunteer/TaskService.groovy b/grails-app/services/au/org/ala/volunteer/TaskService.groovy index 37ba43ebc..ea3dafb9f 100644 --- a/grails-app/services/au/org/ala/volunteer/TaskService.groovy +++ b/grails-app/services/au/org/ala/volunteer/TaskService.groovy @@ -57,7 +57,7 @@ class TaskService { */ Integer countValidUserTranscriptionsForProject(String userId, Project project) { String hql = "select count(distinct t.id) from Task t join t.transcriptions trans with trans.fullyTranscribedBy = :userId where t.isValid = :valid" - Map params = [userId: userId, valid:true] + def params = [userId: userId, valid:true] if (project) { hql += " and t.project = :project" params.project = project @@ -199,7 +199,7 @@ class TaskService { int matches = 0 log.debug("Processing results for user ${userId}, jump ${jump}, and lastId ${lastId}") results?.find { result -> - Task task = Task.get(result[0]) + Task task = Task.get(result[0] as long) log.debug("Checking task ${result[0]}") log.debug("Task: ${task}") @@ -260,7 +260,7 @@ class TaskService { if (results) { def taskResult = results.last() - task = Task.get(taskResult[0]) + task = Task.get(taskResult[0] as long) } task } @@ -327,7 +327,7 @@ class TaskService { Task getNextTask(String userId, Project project, Long lastId = -1) { if (!project || !userId) { - return null; + return null } // Task task = null @@ -384,7 +384,7 @@ class TaskService { Task getNextTaskForValidationForProject(String userId, Project project) { if (!project || !userId) { - return null; + return null } // We have to look for tasks whose last view was before the lock period AND hasn't already been viewed by this user @@ -404,7 +404,7 @@ class TaskService { if (tasks) { def task = tasks.last() - log.debug("getNextTaskForValidationForProject(project {}) found a task: {}", project.id, task.id) + log.debug("getNextTaskForValidationForProject(project ${project.id}) found a task: ${task.id}") return task } @@ -422,7 +422,7 @@ class TaskService { if (tasks) { def task = tasks.last() - log.debug("getNextTaskForValidationForProject(project {}) found a task: {}", project.id, task.id) + log.debug("getNextTaskForValidationForProject(project ${project.id}) found a task: ${task.id}") return task } @@ -441,7 +441,7 @@ class TaskService { c.list(params) { eq("fullyTranscribedBy", userId) isNotNull("dateFullyTranscribed") - } + } as List } /** @@ -551,10 +551,10 @@ WHERE } String select = """ -WITH -${getNotificationWithClauses(projectQuery).join(',\n')} -(SELECT * FROM updated_task_ids) UNION (SELECT * FROM validator_notes_task_ids) -""" + WITH + ${getNotificationWithClauses(projectQuery).join(',\n')} + (SELECT * FROM updated_task_ids) UNION (SELECT * FROM validator_notes_task_ids) + """.stripIndent() def sql = new Sql(dataSource) @@ -628,8 +628,8 @@ SELECT COUNT(*) FROM (SELECT * FROM updated_task_ids UNION SELECT * FROM validat log.debug("Getting recently validated tasks. ") } - def SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - def recentDate = sdf.parse(sdf.format(new Date() - NUMBER_OF_RECENT_DAYS)); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd") + def recentDate = sdf.parse(sdf.format(new Date() - NUMBER_OF_RECENT_DAYS)) def tasks = Task.createCriteria().list() { eq("fullyTranscribedBy", transcriber) @@ -638,7 +638,7 @@ SELECT COUNT(*) FROM (SELECT * FROM updated_task_ids UNION SELECT * FROM validat isNotNull("isValid") gt("dateFullyTranscribed", recentDate) order('dateLastUpdated','desc') - } + } as List if (log.isInfoEnabled()) { sw.stop() @@ -747,7 +747,7 @@ ORDER BY record_idx, name; def url = new URL(imageUrl) def filename = url.path.replaceAll(/\/.*\//, "") // get the filename portion of url if (!filename.trim()) { - filename = "image_" + taskId; + filename = "image_${taskId}" } filename = URLDecoder.decode(filename, "utf-8") def conn = url.openConnection() @@ -759,7 +759,7 @@ ORDER BY record_idx, name; } try { - def dir = new File(grailsApplication.config.images.home + '/' + projectId + '/' + taskId + "/" + multimediaId) + def dir = new File("${grailsApplication.config.images.home}/${projectId}/${taskId}/${multimediaId}") if (!dir.exists()) { log.debug "Creating dir ${dir.absolutePath}" dir.mkdirs() @@ -790,7 +790,7 @@ ORDER BY record_idx, name; def sizes = ['thumb': 300, 'small': 600, 'medium': 1280, 'large': 2000] sizes.each{ fileMap[it.key] = fileMap.raw.replaceFirst(/\.(.{3,4})$/,'_' + it.key +'.$1') // add _small to filename - BufferedImage scaledImage = srcImage; + BufferedImage scaledImage = srcImage if (srcImage.width > it.value /* || srcImage.height > it.value */) { scaledImage = Scalr.resize(srcImage, it.value) } @@ -802,14 +802,14 @@ ORDER BY record_idx, name; static BufferedImage ensureOpaque(BufferedImage bi) { if (bi.getTransparency() == BufferedImage.OPAQUE) - return bi; - int w = bi.getWidth(); - int h = bi.getHeight(); - int[] pixels = new int[w * h]; - bi.getRGB(0, 0, w, h, pixels, 0, w); - BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); - bi2.setRGB(0, 0, w, h, pixels, 0, w); - return bi2; + return bi + int w = bi.getWidth() + int h = bi.getHeight() + int[] pixels = new int[w * h] + bi.getRGB(0, 0, w, h, pixels, 0, w) + BufferedImage bi2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB) + bi2.setRGB(0, 0, w, h, pixels, 0, w) + return bi2 } /** Attempt to rollback any changes made during @link copyImageToStore or @link createImageThumbs */ @@ -846,13 +846,13 @@ ORDER BY record_idx, name; def results = [] - def sql = new Sql(dataSource: dataSource) + def sql = new Sql(dataSource) sql.eachRow(select, [userid: userid, projectId: projectId, labelTextFilter: '%' + labelTextFilter + '%']) { row -> def taskRow = [id: row.id, lastEdit: row.lastEdit, isValid: row.isValid, project: row.project ] results.add(taskRow) } - return results; + return results } @@ -897,20 +897,20 @@ ORDER BY record_idx, name; Task findByProjectAndFieldValue(Project project, String fieldName, String fieldValue) { def select = """ WITH task_ids AS (SELECT id from task where project_id = :projectId) - SELECT f.task_id as id from field f WHERE f.task_id in (SELECT id FROM task_ids) and f.superceded = false and f.name = :fieldName and value = :fieldValue; + SELECT f.task_id as id from field f WHERE f.task_id in (SELECT id FROM task_ids) and f.superceded = false and f.name = :fieldName and value = :fieldValue """ - def sql = new Sql(dataSource: dataSource) - int taskId = -1; + def sql = new Sql(dataSource) + int taskId = -1 def row = sql.firstRow(select, [projectId: project.id, fieldName: fieldName, fieldValue: fieldValue]) if (row) { - taskId = row[0] + taskId = row[0] as int } return Task.findById(taskId) } - public Map getImageMetaData(Task taskInstance) { + Map getImageMetaData(Task taskInstance) { def imageMetaData = [:] taskInstance.multimedia.each { multimedia -> @@ -920,7 +920,7 @@ ORDER BY record_idx, name; return imageMetaData } - @Cacheable(value='getImageMetaData', key="(#multimedia?.id?:0) + '-' + (#rotate?:0)") + @Cacheable(value='getImageMetaData', key = { (multimedia?.id?:0) + '-' + (rotate?:0) }) ImageMetaData getImageMetaData(Multimedia multimedia, int rotate = 0) { def path = multimedia?.filePath if (path) { @@ -940,14 +940,14 @@ ORDER BY record_idx, name; return null } - @Cacheable(value='getImageMetaDataFromFile', key="(#resource?.URI ?: #resource?.filename ?: '') + '-' + (#imageUrl ?: '') + '-' + (#rotate)") + @Cacheable(value='getImageMetaDataFromFile', key = { "${(resource?.URI ?: resource?.filename ?: '')}" + "-" + "${(imageUrl ?: '')}" + "-" + rotate }) ImageMetaData getImageMetaDataFromFile(Resource resource, String imageUrl, int rotate) { BufferedImage image try { image = ImageIO.read(resource.inputStream) } catch (Exception ex) { - log.error("Exception trying to read image path: {}, {}", resource, ex.message) // don't print whoel stack trace + log.error("Exception trying to read image path: ${resource}, ${ex.message}") // don't print whoel stack trace } if (image) { @@ -1028,26 +1028,27 @@ ORDER BY record_idx, name; task.dateFullyValidated = null } - @CacheEvict(value = 'findMaxSequenceNumber', key='#projectId') + @CacheEvict(value = 'findMaxSequenceNumber', key = { projectId }) void clearMaxSequenceNumber(long projectId) { - log.debug('max sequence number cleared for project {}', projectId) + log.debug('max sequence number cleared for project ${projectId}') } - @Cacheable(value = 'findMaxSequenceNumber', key='#project?.id?:-1') + @Cacheable(value = 'findMaxSequenceNumber', key = { project?.id ?: -1 }) Integer findMaxSequenceNumber(Project project) { def select =""" WITH task_ids AS (SELECT id FROM task WHERE project_id = ${project.id}) - SELECT MAX(CASE WHEN f.value~E'^\\\\d+\$' THEN f.value::integer ELSE 0 END) FROM FIELD f WHERE f.task_id IN (SELECT id FROM task_ids) AND f.name = 'sequenceNumber'; - """ - - def sql = new Sql(dataSource: dataSource) + SELECT MAX(CASE WHEN f.value~E'^\\\\d+\$' THEN f.value::integer ELSE 0 END) + FROM FIELD f + WHERE f.task_id IN (SELECT id FROM task_ids) + AND f.name = 'sequenceNumber'; """ + def sql = new Sql(dataSource) def row = sql.firstRow(select) - row ? row[0] : null + row ? row[0] as Integer : null } - public Map getAdjacentTasksBySequence(Task task) { + Map getAdjacentTasksBySequence(Task task) { def results = [:] if (!task) { return results @@ -1057,7 +1058,7 @@ ORDER BY record_idx, name; def field = fieldService.getFieldForTask(task, "sequenceNumber") if (field?.value && field.value.isInteger()) { - def sequenceNumber = Integer.parseInt(field.value); + def sequenceNumber = Integer.parseInt(field.value) def padSize = 0 if (field.value.startsWith("0")) { // remember to left pad the resulting sequence numbers with 0 @@ -1339,7 +1340,7 @@ ORDER BY record_idx, name; // add additional info for notifications tab if (selectedTab == 0 && results.viewList) { - def ids = results.viewList.collect { it.id } + def ids = results.viewList.collect { it.id } as List def unreadIds = getLastViewedBeforeValidation(project, user.userId, ids) results.viewList.each { it.unread = unreadIds.contains(it.id) } diff --git a/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy b/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy index 1c90c5844..3d4251b18 100644 --- a/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy +++ b/grails-app/services/au/org/ala/volunteer/VolunteerStatsService.groovy @@ -19,7 +19,7 @@ class VolunteerStatsService { LinkGenerator grailsLinkGenerator - @Cacheable(value = 'MainVolunteerContribution', key = "(#institutionId?.toString()?:'-1') + (#projectId?.toString()?:'-1') + (#projectTypeName?:'') + (#tags?.toString()?:'[]') + (#maxContributors.toString()) + (#disableStats.toString()) + (#disableHonourBoard.toString())") + @Cacheable(value = 'MainVolunteerContribution', key = { "(#institutionId?.toString()?:'-1') + (#projectId?.toString()?:'-1') + (#projectTypeName?:'') + (#tags?.toString()?:'[]') + (#maxContributors.toString()) + (#disableStats.toString()) + (#disableHonourBoard.toString())" }) def generateStats(long institutionId, long projectId, String projectTypeName, List tags, int maxContributors, boolean disableStats, boolean disableHonourBoard) { Institution institution = (institutionId == -1l) ? null : Institution.get(institutionId) Project projectInstance = (projectId == -1l) ? null : Project.get(projectId) From b5b42bfd573720c262a22baecd0b1dd7df5ecb3a Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Tue, 8 Jun 2021 15:13:17 +1000 Subject: [PATCH 010/103] #464 More logging annotations. --- .../services/au/org/ala/volunteer/FullTextIndexService.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy b/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy index 75aa0587a..bb89aa908 100644 --- a/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy +++ b/grails-app/services/au/org/ala/volunteer/FullTextIndexService.groovy @@ -5,6 +5,7 @@ import grails.converters.JSON import grails.gorm.transactions.NotTransactional import grails.gorm.transactions.Transactional import groovy.json.JsonSlurper +import groovy.util.logging.Slf4j import org.apache.commons.lang.NotImplementedException import org.elasticsearch.index.query.FilterBuilders import org.elasticsearch.index.query.QueryBuilders @@ -34,7 +35,7 @@ import javax.annotation.PreDestroy import static au.org.ala.volunteer.BenchmarkUtils.benchmark import static org.elasticsearch.node.NodeBuilder.nodeBuilder - +@Slf4j @Transactional(readOnly = true) class FullTextIndexService { From 5800816ea0d915ff385d59ad0993d9efc125a59d Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Tue, 8 Jun 2021 15:46:58 +1000 Subject: [PATCH 011/103] #464 More logging --- .../services/au/org/ala/volunteer/EventSourceService.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy b/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy index dbe0195db..e23fe610e 100644 --- a/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy +++ b/grails-app/services/au/org/ala/volunteer/EventSourceService.groovy @@ -2,6 +2,7 @@ package au.org.ala.volunteer import au.org.ala.web.UserDetails import grails.events.annotation.Subscriber +import groovy.util.logging.Slf4j import io.reactivex.Observable import io.reactivex.subjects.Subject import io.reactivex.subjects.UnicastSubject @@ -15,6 +16,7 @@ import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.ConcurrentMap import java.util.concurrent.TimeUnit +@Slf4j @Consumer class EventSourceService { From 35ce62f539b20e4bab9a1bd4a31a863efcb56375 Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Tue, 8 Jun 2021 15:51:48 +1000 Subject: [PATCH 012/103] #464 Updated ehcache config for new version --- src/main/resources/digivol-ehcache-v2.xml | 374 ++++++++++++++++++ src/main/resources/digivol-ehcache.xml | 458 +++++----------------- 2 files changed, 465 insertions(+), 367 deletions(-) create mode 100644 src/main/resources/digivol-ehcache-v2.xml diff --git a/src/main/resources/digivol-ehcache-v2.xml b/src/main/resources/digivol-ehcache-v2.xml new file mode 100644 index 000000000..1026e92b3 --- /dev/null +++ b/src/main/resources/digivol-ehcache-v2.xml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/digivol-ehcache.xml b/src/main/resources/digivol-ehcache.xml index 1026e92b3..e05ecb6f5 100644 --- a/src/main/resources/digivol-ehcache.xml +++ b/src/main/resources/digivol-ehcache.xml @@ -1,374 +1,98 @@ - - - - - - - - - - - - - - - - - - - + + + + + java.io.Serializable + java.io.Serializable + + 120 + + + 10000 + + + + + java.io.Serializable + java.io.Serializable + + 30 + + + 1000 + + - + + java.io.Serializable + java.io.Serializable + + 30 + + + 100 + - + + + java.io.Serializable + java.io.Serializable + + 1 + + + 1000 + - + + + java.io.Serializable + java.io.Serializable + + 10 + + + 1000 + - + + + java.io.Serializable + java.io.Serializable + + 2 + + + 1000 + - + + + java.io.Serializable + java.io.Serializable + + 5 + + + 1000 + - + + + java.io.Serializable + java.io.Serializable + + 1 + + + 1000 + - - \ No newline at end of file + + From 17bcb3eb2d95716f157e972ba551d9e678e29203 Mon Sep 17 00:00:00 2001 From: Chris Dunstall Date: Fri, 3 Jun 2022 17:03:11 +1000 Subject: [PATCH 013/103] Updated ehcache config file from latest develop branch --- src/main/resources/digivol-ehcache-v2.xml | 83 ++++++++++++++++++++--- src/main/resources/digivol-ehcache.xml | 55 +++++++++++++++ 2 files changed, 130 insertions(+), 8 deletions(-) diff --git a/src/main/resources/digivol-ehcache-v2.xml b/src/main/resources/digivol-ehcache-v2.xml index 1026e92b3..66e3f8a38 100644 --- a/src/main/resources/digivol-ehcache-v2.xml +++ b/src/main/resources/digivol-ehcache-v2.xml @@ -1,5 +1,5 @@ + name="digivol-cache-manager">