diff --git a/.travis.yml b/.travis.yml index 14e3a1f..f4c3fe5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: groovy jdk: -- openjdk8 +- openjdk11 sudo: false branches: only: - master - dev - - grails3 + - oidc-grails4 before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ @@ -21,6 +21,7 @@ after_success: - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && travis_retry ./gradlew publish' env: global: + - JAVA_TOOL_OPTIONS=-Dhttps.protocols=TLSv1.2 - secure: PhZOxgYEeHTiKBX91OQK66Wuby1N7uJ+6QuqfpP/D/CaYANznICxepHxWyv3j1aQqOM13n+6sIHp+5BW/LMFK6NqxKt0TtNi/zEZfetsYBlrfZoClZPxQIkby5OlONxhFhpRQYd4LIhup04XNZayc0nvPSNjoQJhryA8ahvG5PQ= - secure: Ns1bV2qlVX5hMhUoPg4HcIcQ59i2zznecy2hSfjwp6KTAdzUXLswNROv+iL8uXLsIlEZlkglKsfAYRpta0FLPSsrFay5h7nZuD9L4rMM7nrVRnDW+dBK/RmWUTx8mKNntA4wkvlChuaY7v/vF8K9HvSRUM8UjIdqAtwq9ZaFB1M= diff --git a/build.gradle b/build.gradle index de9c201..812b0ec 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,14 @@ buildscript { repositories { - //mavenLocal() + mavenLocal() maven { url "https://nexus.ala.org.au/content/groups/public/" } maven { url "https://repo.grails.org/grails/core" } } dependencies { classpath "org.grails:grails-gradle-plugin:$grailsVersion" - classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.1" + classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0" + classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.2.4" + classpath 'org.grails.plugins:quartz:2.0.13' } } plugins { @@ -23,23 +25,26 @@ apply plugin:"eclipse" apply plugin:"idea" apply plugin:"war" apply plugin:"org.grails.grails-web" +apply plugin:"com.github.erdi.webdriver-binaries" apply plugin:"org.grails.grails-gsp" -apply plugin:"asset-pipeline" -apply from: 'https://raw.githubusercontent.com/AtlasOfLivingAustralia/travis-build-configuration/master/travis_grails_publish.gradle' +apply plugin:"com.bertramlabs.asset-pipeline" + +apply from: "${project.projectDir}/gradle/publish.gradle" repositories { - // mavenLocal() + mavenLocal() maven { url "https://nexus.ala.org.au/content/groups/public/" } maven { url "https://repo.grails.org/grails/core" } } -/*grails { - plugins { - compile project(':ala-bootstrap3') +configurations { + developmentOnly + runtimeClasspath { + extendsFrom developmentOnly } -} */ - +} dependencies { + developmentOnly("org.springframework.boot:spring-boot-devtools") compile "org.springframework.boot:spring-boot-starter-logging" compile "org.springframework.boot:spring-boot-autoconfigure" compile "org.grails:grails-core" @@ -47,17 +52,24 @@ dependencies { compile "org.springframework.boot:spring-boot-starter-tomcat" compile "org.grails:grails-dependencies" compile "org.grails:grails-web-boot" + compile "org.grails:grails-logging" compile "org.grails.plugins:cache" compile "org.grails.plugins:scaffolding" console "org.grails:grails-console" profile "org.grails.profiles:web" - runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.1" - testCompile "org.grails:grails-plugin-testing" + compile "org.codehaus.groovy:groovy-dateutil" + runtime "com.bertramlabs.plugins:asset-pipeline-grails:3.2.4" testCompile "org.grails.plugins:geb" - testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" - testRuntime "net.sourceforge.htmlunit:htmlunit:2.18" + testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion" + testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion" + testRuntime "org.seleniumhq.selenium:selenium-safari-driver:$seleniumSafariDriverVersion" - compile 'org.grails.plugins:external-config:1.1.1' + testCompile "org.seleniumhq.selenium:selenium-remote-driver:$seleniumVersion" + testCompile "org.seleniumhq.selenium:selenium-api:$seleniumVersion" + testCompile "org.seleniumhq.selenium:selenium-support:$seleniumVersion" + testCompile "org.grails:grails-web-testing-support" + + compile 'org.grails.plugins:external-config:2.0.0' runtime 'org.apache.ant:ant:1.7.1' //you can also use runtime runtime 'org.apache.ant:ant-launcher:1.7.1' // compile 'net.sf.opencsv:opencsv:2.3' @@ -72,19 +84,30 @@ dependencies { // compile 'org.grails.grails-plugin-rest:2.3.0.M2' compile 'org.codehaus.groovy:groovy-ant:2.0.0' - compile "org.grails.plugins:ala-bootstrap3:3.2.3" + compile "org.grails.plugins:ala-bootstrap3:4.1.0" compile "org.grails.plugins:grails-google-visualization:2.0" - compile "org.grails.plugins:ala-admin-plugin:2.0" - runtime "org.grails.plugins:ala-auth:3.1.3" - compile 'org.grails.plugins:quartz:2.0.12' -// compile "org.spockframework:spock-core:1.0-groovy-2.4" + compile "org.grails.plugins:ala-admin-plugin:2.3.0" + runtime "org.grails.plugins:ala-auth:5.1.1" + compile 'org.grails.plugins:quartz:2.0.13' + + implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.0' } bootRun { jvmArgs('-Dspring.output.ansi.enabled=always') - // jvmArgs('-Dlocal.config.location=grails-app/conf/application.yml') - addResources = true -// systemProperty 'management.info.git.mode', 'FULL' + sourceResources sourceSets.main +} + +webdriverBinaries { + chromedriver '2.45.0' + geckodriver '0.24.0' +} + +tasks.withType(Test) { + systemProperty "geb.env", System.getProperty('geb.env') + systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest") + systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver') + systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver') } assets { diff --git a/gradle.properties b/gradle.properties index 2ec2ead..d6d0bb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,8 @@ -grailsVersion=3.2.11 -gormVersion=6.0.12.RELEASE -gradleWrapperVersion=3.4.1 +grailsVersion=4.1.1 +gormVersion=7.0.9 +gradleWrapperVersion=5.0 +gebVersion=2.3 +seleniumVersion=3.14.0 +webdriverBinariesVersion=2.0 +hibernateCoreVersion=5.1.5.Final +seleniumSafariDriverVersion=3.14.0 diff --git a/gradle/publish.gradle b/gradle/publish.gradle new file mode 100644 index 0000000..7357282 --- /dev/null +++ b/gradle/publish.gradle @@ -0,0 +1,32 @@ +apply plugin:"maven-publish" + +publishing { + repositories { + maven { + name 'Nexus' + url "https://nexus.ala.org.au/content/repositories/${project.version.endsWith('-SNAPSHOT') ? 'snapshots' : 'releases' }" + credentials { + username = System.getenv('TRAVIS_DEPLOY_USERNAME') + password = System.getenv('TRAVIS_DEPLOY_PASSWORD') + } + } + } + publications { + mavenJar(MavenPublication) { + pom.withXml { + def pomNode = asNode() + pomNode.dependencyManagement.replaceNode {} + + // simply remove dependencies without a version + // version-less dependencies are handled with dependencyManagement + // see https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/8 for more complete solutions + pomNode.dependencies.dependency.findAll { + it.version.text().isEmpty() + }.each { + it.replaceNode {} + } + } + from components.web + } + } +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 36d5b90..5c2d1cf 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1277437..75b8c7c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Thu Aug 10 10:51:23 AEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-bin.zip diff --git a/gradlew b/gradlew index 9d82f78..83f2acf 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,20 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## ## @@ -6,20 +22,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +64,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +75,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +105,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -105,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -150,11 +170,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..24467a1 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,84 +1,100 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/grails-app/conf/application.yml b/grails-app/conf/application.yml index a566220..068e9fe 100644 --- a/grails-app/conf/application.yml +++ b/grails-app/conf/application.yml @@ -11,8 +11,6 @@ grails: spring: transactionManagement: proxies: false - servlet: - version: 3.0 gorm: # Whether to autowire entities. # Disabled by default for performance reasons. @@ -33,13 +31,17 @@ spring: groovy: template: check-template-location: false - -# Spring Actuator Endpoints are Disabled by Default -endpoints: - enabled: true jmx: - enabled: true - + unique-names: true + devtools: + restart: + exclude: + - grails-app/views/** + - grails-app/i18n/** + - grails-app/conf/** +management: + endpoints: + enabled-by-default: true --- grails: cors: @@ -109,8 +111,15 @@ privacyPolicy: "https://www.ala.org.au/about/terms-of-use/privacy-policy/" --- security: cas: - uriFilterPattern: "/alaAdmin.*" - uriExclusionFilterPattern: "/images.*,/css.*,/js.*,/less.*" + uriFilterPattern: "/alaAdmin/*" + uriExclusionFilterPattern: "/images.*,/css.*,/js.*,/less.*" + enabled: false + oidc: + enabled: true + discovery-uri: 'https://auth-test.ala.org.au/cas/oidc/.well-known' + clientId: 'change me' + secret: 'change me' + scope: 'openid profile roles' environments: development: diff --git a/grails-app/controllers/au/org/ala/dashboard/DashboardController.groovy b/grails-app/controllers/au/org/ala/dashboard/DashboardController.groovy index 33660f9..2d2002a 100644 --- a/grails-app/controllers/au/org/ala/dashboard/DashboardController.groovy +++ b/grails-app/controllers/au/org/ala/dashboard/DashboardController.groovy @@ -15,8 +15,8 @@ package au.org.ala.dashboard -import au.com.bytecode.opencsv.CSVWriter import grails.converters.JSON +import com.opencsv.CSVWriter class DashboardController { @@ -178,12 +178,6 @@ class DashboardController { render view: 'panels/empty' } - def downloadsBySourcePanel = { - if (metadataService.getLoggerSourceBreakdown()) - render view: 'panels/downloadsBySourcePanel', model: [loggerSourceBreakdown: metadataService.getLoggerSourceBreakdown()] - else - render view: 'panels/empty' - } def downloadsByUserTypePanel = { if (metadataService.getLoggerEmailBreakdown()) @@ -376,9 +370,8 @@ class DashboardController { typeCounts: metadataService.getTypeStats(), taxaCounts: metadataService.getTaxaCounts(), bhlCounts: metadataService.getBHLCounts(), - volunteerPortalCounts: metadataService.getVolunteerStats(), +// volunteerPortalCounts: metadataService.getVolunteerStats(), occurrenceDownloadByReason: metadataService.getLoggerReasonBreakdown().collect {["Download Reason": it[0], "Events": it[1].trim(), "Records": it[2].trim()]}] - //volunteerPortalCounts: metadataService.get('volunteerPortalCounts'), //identifyLifeCounts: metadataService.getIdentifyLifeCounts()] ['All','Plants','Mammals','Reptiles','Birds','Animals','Arthropods', 'Fishes','Insects','Amphibians','Bacteria','Fungi'].each { diff --git a/grails-app/services/au/org/ala/dashboard/MetadataService.groovy b/grails-app/services/au/org/ala/dashboard/MetadataService.groovy index 924a8f0..33afe4e 100644 --- a/grails-app/services/au/org/ala/dashboard/MetadataService.groovy +++ b/grails-app/services/au/org/ala/dashboard/MetadataService.groovy @@ -54,7 +54,6 @@ class MetadataService { stateConservation : getSpeciesByConservationStatus(), loggerTotals : getLoggerTotals(), loggerReasonBreakdown : getLoggerReasonBreakdown(), -// loggerSourceBreakdown : getLoggerSourceBreakdown(), loggerEmailBreakdown : getLoggerEmailBreakdown(), loggerTemporalBreakdown : getLoggerReasonTemporalBreakdown(), imagesBreakdown : getImagesBreakdown(), @@ -124,13 +123,6 @@ class MetadataService { }) } - def getVolunteerStats() { - cacheService.get('volunteerStats', { - // earliest record - webService.getJson("${VOLUNTEER_URL}${Constants.WebServices.PARTIAL_URL_VOLUNTEER_STATS}") - }) - } - /** * Get cached data for the oldest and newest records and counts of * records by century. @@ -548,56 +540,6 @@ class MetadataService { }) } - def getLoggerSourceBreakdown() { - cacheService.get('loggerSourceBreakdown', { - def results = [] - - // this number includes testing - we need to remove this - def allTimeSourceBreakdown = webService.getJson("${LOGGER_URL}${Constants.WebServices.PARTIAL_URL_LOGGER_SOURCE_BREAKDOWN}").all - - //order by counts - def sortedBreakdowns = allTimeSourceBreakdown.sourceBreakdown.sort { -it.value["events"] } - - //but then place "Other", "Unclassified", "Testing" at the bottom & combined - def other = sortedBreakdowns.get("other") - if (!other) other = [events: 0, records:0] - - def unclassifiedCount = sortedBreakdowns.get("unclassified") - def testingCount = sortedBreakdowns.get("testing") - - if (unclassifiedCount) { - other["events"] = other["events"] + unclassifiedCount["events"] - other["records"] = other["records"] + unclassifiedCount["records"] - } - - //testing events - def testingEvents = 0 - def testingRecords = 0 - - if (testingCount) { - testingEvents = testingCount["events"] as long - testingRecords = testingCount["records"] as long - } - - sortedBreakdowns.remove("other") - sortedBreakdowns.remove("unclassified") - sortedBreakdowns.remove("testing") - sortedBreakdowns.put("other", other) - - for (k in sortedBreakdowns.keySet()) { - def keyMap = sortedBreakdowns[k] - results.add([StringUtils.capitalize(k), format(keyMap["events"] as long), format(keyMap["records"] as long)]) - } - - results.add(["TOTAL", - format((allTimeSourceBreakdown.events as long) - testingEvents), - format((allTimeSourceBreakdown.records as long) - testingRecords)] - ) - - return results - }) - } - def getLoggerReasonTemporalBreakdown() { cacheService.get('loggerReasonBreakdown', { def results = [] @@ -819,6 +761,10 @@ class MetadataService { return cacheService.get(key, { cacheService.loadStaticCacheFromFile(key) }) } + def getVolunteerStats() { + return get('volunteerPortalCounts') + } + def getCollectionsByCategory() { return get('collections') } diff --git a/grails-app/views/dashboard/index.gsp b/grails-app/views/dashboard/index.gsp index 837cb11..5c7d421 100644 --- a/grails-app/views/dashboard/index.gsp +++ b/grails-app/views/dashboard/index.gsp @@ -78,8 +78,6 @@ - - diff --git a/grails-app/views/dashboard/panels/downloadsBySourcePanel.gsp b/grails-app/views/dashboard/panels/downloadsBySourcePanel.gsp deleted file mode 100644 index e1170e0..0000000 --- a/grails-app/views/dashboard/panels/downloadsBySourcePanel.gsp +++ /dev/null @@ -1,23 +0,0 @@ -
-
-
-
Occurrence downloads by source
-
-
-
- - - - - - - - -
${r[0]}${r[1]} events${r[2]} records
- -

More

-
-
-
-
\ No newline at end of file diff --git a/grails-app/views/dashboard/panels/volunteerPortalPanel.gsp b/grails-app/views/dashboard/panels/volunteerPortalPanel.gsp index e950882..85f681f 100644 --- a/grails-app/views/dashboard/panels/volunteerPortalPanel.gsp +++ b/grails-app/views/dashboard/panels/volunteerPortalPanel.gsp @@ -40,24 +40,3 @@ - - -
-
- -
- - - - - - -
${volunteer[0]}
-
-
-
-
diff --git a/src/integration-test/groovy/MetadataServiceSpec.groovy b/src/integration-test/groovy/au/org/ala/dashboard/MetadataServiceSpec.groovy similarity index 85% rename from src/integration-test/groovy/MetadataServiceSpec.groovy rename to src/integration-test/groovy/au/org/ala/dashboard/MetadataServiceSpec.groovy index 7ca6355..2dc9336 100644 --- a/src/integration-test/groovy/MetadataServiceSpec.groovy +++ b/src/integration-test/groovy/au/org/ala/dashboard/MetadataServiceSpec.groovy @@ -1,20 +1,15 @@ package au.org.ala.dashboard -//import grails.test.spock.IntegrationSpec -import grails.test.mixin.integration.Integration +import grails.testing.mixin.integration.Integration +import grails.testing.services.ServiceUnitTest import org.springframework.beans.factory.annotation.Autowired -import spock.lang.Shared -import grails.test.mixin.TestFor import spock.lang.Specification @Integration -@TestFor(MetadataService) -class MetadataServiceSpec extends Specification { +class MetadataServiceSpec extends Specification implements ServiceUnitTest { - // @Shared def metadataService @Autowired MetadataService metadataService - def grailsApplication // def cacheService def "test retrieval of states and territories records"() { diff --git a/src/integration-test/resources/GebConfig.groovy b/src/integration-test/resources/GebConfig.groovy new file mode 100644 index 0000000..0d97e35 --- /dev/null +++ b/src/integration-test/resources/GebConfig.groovy @@ -0,0 +1,25 @@ +import org.openqa.selenium.chrome.ChromeDriver +import org.openqa.selenium.chrome.ChromeOptions +import org.openqa.selenium.firefox.FirefoxDriver + +environments { + + // run via “./gradlew -Dgeb.env=chrome iT” + chrome { + driver = { new ChromeDriver() } + } + + // run via “./gradlew -Dgeb.env=chromeHeadless iT” + chromeHeadless { + driver = { + ChromeOptions o = new ChromeOptions() + o.addArguments('headless') + new ChromeDriver(o) + } + } + + // run via “./gradlew -Dgeb.env=firefox iT” + firefox { + driver = { new FirefoxDriver() } + } +} diff --git a/src/test/groovy/au/org/ala/dashboard/CacheServiceSpec.groovy b/src/test/groovy/au/org/ala/dashboard/CacheServiceSpec.groovy index 205cbed..68219ab 100644 --- a/src/test/groovy/au/org/ala/dashboard/CacheServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/dashboard/CacheServiceSpec.groovy @@ -1,11 +1,11 @@ package au.org.ala.dashboard -import grails.test.mixin.TestFor +import grails.testing.services.ServiceUnitTest import groovy.time.TimeCategory import spock.lang.Specification -@TestFor(CacheService) -class CacheServiceSpec extends Specification{ + +class CacheServiceSpec extends Specification implements ServiceUnitTest { def setup() { //Initialize cache before each test @@ -60,11 +60,11 @@ class CacheServiceSpec extends Specification{ def value = service.get('mykey', {null}) - - assert value == null + // The new value is refreshed asynchronously so the first attempt will always retrieve the old value + assert value == 'value' // We wait for the refresher thread to finish Thread.sleep(2000) - // We retrieve the updated value which is current and won't expired for at leas a day + // We retrieve the updated value which is current and won't expired for at least a day value = service.get('mykey', {null}) then: value == null