Skip to content

Commit

Permalink
Merge pull request #71 from AtlasOfLivingAustralia/develop
Browse files Browse the repository at this point in the history
Fixes for a 1.0.7 release
  • Loading branch information
djtfmartin authored Sep 4, 2019
2 parents b513b00 + a7ea059 commit 6384ab2
Show file tree
Hide file tree
Showing 20 changed files with 652 additions and 350 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
out
.gradle

build
.slcache
/target
/.idea
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}


version "1.0.6"
version "1.0.7-SNAPSHOT"


group "au.org.ala"
Expand Down Expand Up @@ -64,7 +64,7 @@ dependencies {
compile group: 'org.grails.plugins', name: 'ala-bootstrap3', version: '3.2.1', changing: true
compile group: 'org.grails.plugins', name: 'ala-admin-plugin', version: '2.1', changing: true
compile group: 'org.grails.plugins', name: 'ala-auth', version: '3.2.2', changing: true
compile group: 'au.org.ala.plugins.grails', name:'images-client-plugin', version: '1.0.1-SNAPSHOT', changing: true
compile group: 'au.org.ala.plugins.grails', name:'images-client-plugin', version: '1.1', changing: true

// Added dependencies
compile 'org.grails.plugins:external-config:1.2.2'
Expand All @@ -81,7 +81,7 @@ dependencies {
compile ('au.org.ala:image-utils:1.8.6'){
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}
compile 'org.grails.plugins:ala-ws-security-plugin:2.0'
compile 'org.grails.plugins:ala-ws-security-plugin:2.0.1'

// Swagger
compile 'org.grails.plugins:swagger:1.0.1'
Expand Down
35 changes: 24 additions & 11 deletions db-upgrade-0_9_to_1_0.sql
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
alter table image add date_deleted timestamp;
alter table image add recognised_license_id bigint;
alter table image add occurrence_id character varying(255);
alter table image add calibrated_by_user character varying(255);

CREATE TABLE public.license (
id bigint NOT NULL,
version bigint NOT NULL,
url character varying(255) NOT NULL,
name character varying(255) NOT NULL,
image_url character varying(255),
acronym character varying(255) NOT NULL
id bigint NOT NULL,
version bigint NOT NULL,
url character varying(255) NOT NULL,
name character varying(255) NOT NULL,
image_url character varying(255),
acronym character varying(255) NOT NULL
);
ALTER TABLE ONLY public.license
ADD CONSTRAINT license_pkey PRIMARY KEY (id);
CREATE TABLE public.license_mapping (
id bigint NOT NULL,
version bigint NOT NULL,
value character varying(255) NOT NULL,
license_id bigint NOT NULL
id bigint NOT NULL,
version bigint NOT NULL,
value character varying(255) NOT NULL,
license_id bigint NOT NULL
);
ALTER TABLE ONLY public.license_mapping
ADD CONSTRAINT license_mapping_pkey PRIMARY KEY (id);
ALTER TABLE ONLY public.license_mapping
ADD CONSTRAINT fktetx2lihs6cq4swvdhaqeco7s FOREIGN KEY (license_id) REFERENCES public.license(id);


update image set mime_type = 'audio/mpeg' where original_filename like '%.mp3';
update image set mime_type = 'audio/mpeg' where original_filename like '%.mp3';


/* Add the occurrence_id to top level table */
CREATE TEMP TABLE temp_image_occurrence as select image_id, value as occurrence_id from image_meta_data_item imdi where imdi.name='occurrenceId';
UPDATE image
SET occurrence_id = subquery.occurrence_id
FROM (SELECT io.image_id, io.occurrence_id from temp_image_occurrence io) AS subquery
WHERE image.id = subquery.image_id;

DROP TABLE temp_image_occurrence;
8 changes: 5 additions & 3 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ dataSource:

environments:
development:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
# hibernate:
# dialect: org.hibernate.dialect.PostgreSQLDialect
dataSource:
dbCreate: update
# driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost/images?autoReconnect=true&connectTimeout=0&useUnicode=true&characterEncoding=UTF-8
username: "images"
password: "images"
Expand Down Expand Up @@ -136,6 +137,7 @@ environments:
dialect: org.hibernate.dialect.PostgreSQLDialect
dataSource:
dbCreate: update
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost/images?autoReconnect=true&connectTimeout=0&useUnicode=true&characterEncoding=UTF-8
properties:
jmxEnabled: true
Expand All @@ -159,7 +161,7 @@ security:
cas:
appServerName: 'http://dev.ala.org.au:8080'
uriFilterPattern: '/admin/.*,/admin,/admin/,/image/deleteImage/.*'
authenticateOnlyIfLoggedInPattern: ''
authenticateOnlyIfLoggedInPattern: '/ws/createSubimage'
bypass: false
disableCAS: false

Expand Down
1 change: 1 addition & 0 deletions grails-app/controllers/UrlMappings.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class UrlMappings {
"/ws"(controller: 'webService', action: 'swagger')

// legacy URLS
"/image/imageTooltipFragment"(controller: "image", action: "imageTooltipFragment")
"/image/proxyImageThumbnail"(controller: "image", action: "proxyImageThumbnail")
"/image/proxyImageThumbnailLarge"(controller: "image", action: "proxyImageThumbnailLarge")
"/image/proxyImageTile"(controller: "image", action: "proxyImageTile")
Expand Down
38 changes: 24 additions & 14 deletions grails-app/controllers/au/org/ala/images/AdminController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AdminController {
if (storeResult.image) {
imageService.schedulePostIngestTasks(storeResult.image.id, storeResult.image.imageIdentifier, storeResult.image.originalFilename, userId)
} else {
imageService.scheduleNonImagePostIngestTasks(storeResult.image.id, storeResult.image.imageIdentifier, storeResult.image.originalFilename, userId)
imageService.scheduleNonImagePostIngestTasks(storeResult.image.id)
}
flash.message = "Image uploaded with identifier: ${storeResult.image?.imageIdentifier}"
redirect(action:'upload')
Expand All @@ -112,23 +112,27 @@ class AdminController {
def headers = []
def batch = []

file.inputStream.eachCsvLine { tokens ->
if (lineCount == 0) {
headers = tokens
} else {
def m = [:]
for (int i = 0; i < headers.size(); ++i) {
m[headers[i]] = tokens[i]
try {
file.inputStream.eachCsvLine { tokens ->
if (lineCount == 0) {
headers = tokens
} else {
def m = [:]
for (int i = 0; i < headers.size(); ++i) {
m[headers[i]] = tokens[i]
}
batch << m
}
batch << m
lineCount++
}
lineCount++
scheduleImagesUpload(batch, authService.getUserId())
renderResults([success: true, message:'Image upload started'])
} catch (Exception e){
log.error(e.getMessage(), e)
renderResults([success: false, message: "Problem reading CSV file. Please check contents."])
}

scheduleImagesUpload(batch, '-2')
renderResults([success: true, message:'Image upload started'])
} else {
renderResults([success: false, message: "Expected multipart request containing 'csvfile' file parameter"])
renderResults([success: false, message: "Problem reading CSV file from upload."])
}
}

Expand All @@ -145,6 +149,12 @@ class AdminController {
}
}

def scheduleDeletedImagesPurge(){
imageService.scheduleBackgroundTask(new DeletedImagesPurgeBackgroundTask(imageService))
flash.message = "Deleted images purge started. Refresh dashboard for progress."
redirect(action:'dashboard')
}

def licences(){}

def updateStoredLicences(){
Expand Down
62 changes: 39 additions & 23 deletions grails-app/controllers/au/org/ala/images/ImageController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -365,35 +365,45 @@ class ImageController {
flash.errorMessage = "Could not find image with id ${params.int("id") ?: params.imageId }!"
redirect(action:'list', controller: 'search')
} else {
def subimages = Subimage.findAllByParentImage(image)*.subimage
def sizeOnDisk = imageStoreService.getConsumedSpaceOnDisk(image.imageIdentifier)

//accessible from cookie
def userEmail = AuthenticationUtils.getEmailAddress(request)
def userDetails = authService.getUserForEmailAddress(userEmail, true)
def userId = userDetails ? userDetails.id : ""

def isAdmin = false
if (userDetails){
if (userDetails.getRoles().contains("ROLE_ADMIN"))
isAdmin = true
}
getImageModel(image)
}
}
}

def thumbUrls = imageService.getAllThumbnailUrls(image.imageIdentifier)
private def getImageModel(Image image){
def subimages = Subimage.findAllByParentImage(image)*.subimage
def sizeOnDisk = imageStoreService.getConsumedSpaceOnDisk(image.imageIdentifier)

boolean isImage = imageService.isImageType(image)
//accessible from cookie
def userEmail = AuthenticationUtils.getEmailAddress(request)
def userDetails = authService.getUserForEmailAddress(userEmail, true)
def userId = userDetails ? userDetails.id : ""

//add additional metadata
def resourceLevel = collectoryService.getResourceLevelMetadata(image.dataResourceUid)
def isAdmin = false
if (userDetails){
if (userDetails.getRoles().contains("ROLE_ADMIN"))
isAdmin = true
}

if (grailsApplication.config.analytics.trackDetailedView.toBoolean()) {
sendAnalytics(image, 'imagedetailedview')
}
if (!userId){
userId = authService.getUserId()
}

[imageInstance: image, subimages: subimages, sizeOnDisk: sizeOnDisk,
squareThumbs: thumbUrls, isImage: isImage, resourceLevel: resourceLevel, isAdmin:isAdmin, userId:userId]
}
def thumbUrls = imageService.getAllThumbnailUrls(image.imageIdentifier)

boolean isImage = imageService.isImageType(image)

//add additional metadata
def resourceLevel = collectoryService.getResourceLevelMetadata(image.dataResourceUid)

if (grailsApplication.config.analytics.trackDetailedView.toBoolean()) {
sendAnalytics(image, 'imagedetailedview')
}

[imageInstance: image, subimages: subimages,
parentImage: image.parent,
sizeOnDisk: sizeOnDisk,
squareThumbs: thumbUrls, isImage: isImage, resourceLevel: resourceLevel, isAdmin:isAdmin, userId:userId]
}

def view() {
Expand Down Expand Up @@ -450,6 +460,12 @@ class ImageController {
[imageInstance: imageInstance, metaData: metaData?.sort { it.name }, source: source]
}

def coreImageMetadataTableFragment() {
def imageInstance = imageService.getImageFromParams(params)

render(view: '_coreImageMetadataFragment', model: getImageModel(imageInstance))
}

def imageTooltipFragment() {
def imageInstance = imageService.getImageFromParams(params)
[imageInstance: imageInstance]
Expand Down
Loading

0 comments on commit 6384ab2

Please sign in to comment.