Skip to content

Commit

Permalink
Prepare for 3.0.2
Browse files Browse the repository at this point in the history
* Update build.gradle

* updated the way to retrieve locale

* added exception handler for JSON settings parsing.

* change 'suitable for' to be multi-selection (so the value will be a json array) (#50)

* bump to 3.0.2-SNAPSHOT
* Fix for #54 (#56)
* bump to com.gorylenko.gradle-git-properties and a default for "citation.rights.template"
* "com.gorylenko.gradle-git-properties" version "2.4.0-rc2"
* added missing config - siteDefaultLanguage
* fix for deletes

Co-authored-by: alexhuang091 <[email protected]>
Co-authored-by: Nick dos Remedios <[email protected]>
  • Loading branch information
3 people authored Dec 7, 2021
1 parent c304080 commit 3b16962
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 160 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ buildscript {
}

plugins {
id "com.gorylenko.gradle-git-properties" version "2.3.1"
id "com.gorylenko.gradle-git-properties" version "2.4.0-rc2"
}

version "3.0.1"
version "3.0.2-SNAPSHOT"

group "au.org.ala"

Expand Down
5 changes: 4 additions & 1 deletion grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ rifcs:
resource.publicArchive.url.template: "https://biocache.ala.org.au/archives/gbif/@UID@/@[email protected]"
resource.gbifExport.url.template: "https://biocache.ala.org.au/archives/gbif/@UID@/@[email protected]"
citation.template: "Records provided by @entityName@, accessed through ALA website."
citation.link.template = For more information: "@link@"
citation.link.template: "For more information: @link@"
citation.rights.template: ""

siteDefaultLanguage: "en"

networkTypes:
- BCI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,12 @@ class CollectionController extends ProviderGroupController {
*/
static def entitySpecificDescriptionProcessing(collection, params) {
// special handling for collection type
if (params.collectionType) {
List collectionTypes = params.list('collectionType')
collection.collectionType = (collectionTypes as JSON).toString()
params.remove('collectionType')
}
collection.collectionType = (params.collectionType as JSON).toString()
params.remove('collectionType')

// special handling for keywords
def keywords = params.keywords.tokenize(',')
def trimmedKeywords = keywords.collect { return it.trim() }
def trimmedKeywords = keywords.collect {return it.trim()}
collection.keywords = (trimmedKeywords as JSON).toString()
params.remove('keywords')

Expand Down
67 changes: 28 additions & 39 deletions grails-app/controllers/au/org/ala/collectory/DataController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,7 @@ class DataController {
Contact.withTransaction {
c.save(flush: true)
}
if (c.hasErrors()) {
c.errors.each { log.error(it.toString()) }
}
c.errors.each { log.error(it.toString()) }
addContentLocation "/ws/contacts/${c.id}"
def cm = buildContactModel(c)
cm.id = c.id
Expand All @@ -766,9 +764,7 @@ class DataController {
Contact.withTransaction {
c.save(flush: true)
}
if (c.hasErrors()) {
c.errors.each { log.error(it.toString()) }
}
c.errors.each { log.error(it.toString()) }
addContentLocation "/ws/contacts/${c.id}"
def cm = buildContactModel(c)
cm.id = c.id
Expand Down Expand Up @@ -808,6 +804,7 @@ class DataController {
* @param uid the entity instance
*/
def contactsForEntity = {
check(params)
def contactList = params.pg.getContacts().collect { buildContactForModel(it, params.pg.urlForm()) }
addContentLocation "/ws/${params.entity}/${params.pg.uid}/contacts"
addVaryAcceptHeader()
Expand All @@ -834,6 +831,7 @@ class DataController {
* @param id the database id of the contact relationship (contactFor)
*/
def contactForEntity = {
check(params)
if (params.id) {
def cm = buildContactForModel(ContactFor.get(params.id as Long), params.pg.urlForm())
addContentLocation "/ws/${params.entity}/${params.pg.uid}/contacts/${params.id}"
Expand Down Expand Up @@ -886,7 +884,7 @@ class DataController {
map.contactName = it.primaryContact?.contact?.buildName() ?: ""
map.contactEmail = it.primaryContact?.contact?.email ?: ""
map.contactPhone = it.primaryContact?.contact?.phone ?: ""
map.uri = it.primaryContact ? "${Holders.grailsApplication.config.grails.serverURL}/ws/${ProviderGroup.urlFormFromUid(it.uid)}/${it.uid}/contacts/${it.primaryContact?.id}" : ''
map.uri = it.primaryContact ? "${Holders.grailsApplication.config.grails.serverURL}/ws/${providerGroupService.urlFormFromUid(it.uid)}/${it.uid}/contacts/${it.primaryContact?.id}" : ''

return map
}
Expand Down Expand Up @@ -914,7 +912,7 @@ class DataController {
def notifyList = {
if (params.uid) {
def contactFors = ContactFor.findAllByEntityUidAndNotify(params.uid, true).collect {
buildContactForModel(it, ProviderGroup.urlFormFromUid(params.uid))
buildContactForModel(it, providerGroupService.urlFormFromUid(params.uid))
}
render contactFors as JSON
} else {
Expand Down Expand Up @@ -966,41 +964,32 @@ class DataController {
*/
def updateContactFor = {
def ok = check(params)
if (!ok || !params.pg || !params.id || !params.pg.uid){
if (!ok){
return
}
try {
def props = params.json
props.userLastModified = session.username

def c = Contact.get(params.id)
def cf = ContactFor.findByContactAndEntityUid(c, params.pg.uid)
if (cf) {
// update
bindData(cf, props as Map, ['entityUid'])
Contact.withTransaction {
c.save(flush: true)
}
if (c.hasErrors()) {
c.errors.each { log.error("Validation error - " + it.toString()) }
}
success 'updated'
def props = params.json
props.userLastModified = session.username
//println "body = " + props
def c = Contact.get(params.id)
def cf = ContactFor.findByContactAndEntityUid(c, params.pg.uid)
if (cf) {
// update
bindData(cf, props as Map, ['entityUid'])
c.save(flush: true)
c.errors.each { log.error(it) }
success 'updated'
} else {
// create
if (c) {
params.pg.addToContacts c,
props.role ?: '',
(props.administrator ?: false) as Boolean,
(props.primaryContact ?: false) as Boolean,
props.userLastModified
created 'contactFor', params.pg.uid
} else {
// create
if (c) {
params.pg.addToContacts c,
props.role ?: '',
(props.administrator ?: false) as Boolean,
(props.primaryContact ?: false) as Boolean,
props.userLastModified
created 'contactFor', params.pg.uid
} else {
badRequest "contact doesn't exist"
}
badRequest "contact doesn't exist"
}
} catch (Exception e){
log.error(e.getMessage(), e)
badRequest "Problem processing this update"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,15 @@ abstract class ProviderGroupController {
log.info ">>${collectoryAuthService?.username()} deleting ${entityName} " + name
activityLogService.log collectoryAuthService?.username(), authService?.userInRole(grailsApplication.config.ROLE_ADMIN), pg.uid, Action.DELETE
try {
// remove contact links (does not remove the contact)
ContactFor.findAllByEntityUid(pg.uid).each {
log.info "Removing link to contact " + it.contact?.buildName()
it.delete()
Contact.withTransaction {
// remove contact links (does not remove the contact)
ContactFor.findAllByEntityUid(pg.uid).each {
log.info "Removing link to contact " + it.contact?.buildName()
it.delete()
}
// delete
pg.delete(flush: true)
}
// delete
pg.delete(flush: true)
flash.message = "${message(code: 'default.deleted.message', args: [message(code: "${entityNameLower}.label", default: entityNameLower), name])}"
redirect(action: "list")
} catch (org.springframework.dao.DataIntegrityViolationException e) {
Expand Down
Loading

0 comments on commit 3b16962

Please sign in to comment.