Skip to content

Commit

Permalink
Merge pull request #63 from AtlasOfLivingAustralia/release/3.0.3
Browse files Browse the repository at this point in the history
Release/3.0.3
  • Loading branch information
nickdos authored Jan 6, 2022
2 parents 5d74f81 + 79c3e41 commit 4e3d99c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 30 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
id "com.gorylenko.gradle-git-properties" version "2.4.0-rc2"
}

version "3.0.2"
version "3.0.3"

group "au.org.ala"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ class CollectionController extends ProviderGroupController {
*/
static def entitySpecificDescriptionProcessing(collection, params) {
// special handling for collection type
collection.collectionType = (params.collectionType as JSON).toString()
if (params.collectionType instanceof String){
collection.collectionType = params.collectionType
} else {
collection.collectionType = (params.collectionType as JSON).toString()
}

params.remove('collectionType')

// special handling for keywords
Expand Down
42 changes: 25 additions & 17 deletions grails-app/controllers/au/org/ala/collectory/DataController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ class DataController {
addVaryAcceptHeader()
def cm = buildContactModel(c)
withFormat {
json {render cm as JSON}
csv {render (contentType: 'text/csv', text: CONTACT_HEADER + mapToCsv(cm))}
xml {render (contentType: 'text/xml', text: objToXml(cm, 'contact'))}
json {render cm as JSON}
}
} else {
badRequest ' no such id'
Expand All @@ -690,10 +690,10 @@ class DataController {
addContentLocation "/ws/contacts"
addVaryAcceptHeader()
withFormat {
json {render Contact.list().collect { buildContactModel(it) } as JSON}
csv {render (contentType: 'text/csv',
text: CONTACT_HEADER + Contact.list().collect { mapToCsv(buildContactModel(it)) }.join(''))}
xml {render (contentType: 'text/xml', text: objToXml(Contact.list().collect { buildContactModel(it) }, 'contacts'))}
json {render Contact.list().collect { buildContactModel(it) } as JSON}
}
}
}
Expand Down Expand Up @@ -809,6 +809,7 @@ class DataController {
addContentLocation "/ws/${params.entity}/${params.pg.uid}/contacts"
addVaryAcceptHeader()
withFormat {
json {render contactList as JSON}
csv {
def out = new StringWriter()
out << "name, role, primary contact, editor, notify, email, phone\n"
Expand All @@ -819,7 +820,6 @@ class DataController {
render out.toString()
}
xml {render (contentType: 'text/xml', text: objToXml(contactList, 'contactFors'))}
json {render contactList as JSON}
}
}

Expand All @@ -832,19 +832,27 @@ class DataController {
*/
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}"
addVaryAcceptHeader()
withFormat {
csv {
def out = new StringWriter()
out << "title, first name, last name, role, primary contact, editor, notify, email, phone, fax, mobile\n"
out << "\"${cm.contact.title?:""}\",\"${cm.contact.firstName?:""}\",\"${cm.contact.lastName?:""}\",\"${cm.role}\",${cm.primaryContact},${cm.editor},${cm.notify},${cm.contact.email?:""},${cm.contact.phone?:""},${cm.contact.fax?:""},${cm.contact.mobile?:""}\n"
render (contentType: 'text/csv', text: out.toString())
Contact contact = Contact.get(params.id)
ContactFor contactFor = ContactFor.findByContact(contact)

if (contact && contactFor) {
def cm = buildContactForModel(contactFor, params.pg.urlForm())
addContentLocation "/ws/${params.entity}/${params.pg.uid}/contacts/${params.id}"
addVaryAcceptHeader()
withFormat {
json { render cm as JSON }
csv {
def out = new StringWriter()
out << "title, first name, last name, role, primary contact, editor, notify, email, phone, fax, mobile\n"
out << "\"${cm.contact.title ?: ""}\",\"${cm.contact.firstName ?: ""}\",\"${cm.contact.lastName ?: ""}\",\"${cm.role}\",${cm.primaryContact},${cm.editor},${cm.notify},${cm.contact.email ?: ""},${cm.contact.phone ?: ""},${cm.contact.fax ?: ""},${cm.contact.mobile ?: ""}\n"
render(contentType: 'text/csv', text: out.toString())
}
xml { render(contentType: 'text/xml', text: objToXml(cm, 'contactFor')) }
}
xml {render (contentType: 'text/xml', text: objToXml(cm, 'contactFor'))}
json {render cm as JSON}
} else {
forward(action:'contactsForEntity')
}
} else {
forward(action:'contactsForEntity')
Expand All @@ -864,14 +872,14 @@ class DataController {
addContentLocation "/ws/${params.entity}/contacts"
addVaryAcceptHeader()
withFormat {
json {
render model as JSON
}
csv {
render (contentType: 'text/csv',
text: SHORT_CONTACTS_HEADER + listToCsv(model))
}
xml {render (contentType: 'text/xml', text: objToXml(model, 'contacts'))}
json {
render model as JSON
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ class LookupController {
def nm = ''
def prefix = uid.startsWith('drt') ? 'drt' : uid[0..1]
switch (prefix) {
case 'co': nm = Collection.executeQuery("select c.name from Collection c where c.uid = ?",[uid]); break
case 'in': nm = Collection.executeQuery("select c.name from Institution as c where c.uid = ?",[uid]); break
case 'dp': nm = Collection.executeQuery("select c.name from DataProvider as c where c.uid = ?",[uid]); break
case 'dr': nm = Collection.executeQuery("select c.name from DataResource as c where c.uid = ?",[uid]); break
case 'drt': nm = Collection.executeQuery("select c.name from TempDataResource as c where c.uid = ?",[uid]); break
case 'dh': nm = Collection.executeQuery("select c.name from DataHub as c where c.uid = ?",[uid]); break
case 'co': nm = Collection.executeQuery("select c.name from Collection c where c.uid = ?0",[uid]); break
case 'in': nm = Collection.executeQuery("select c.name from Institution as c where c.uid = ?0",[uid]); break
case 'dp': nm = Collection.executeQuery("select c.name from DataProvider as c where c.uid = ?0",[uid]); break
case 'dr': nm = Collection.executeQuery("select c.name from DataResource as c where c.uid = ?0",[uid]); break
case 'drt': nm = Collection.executeQuery("select c.name from TempDataResource as c where c.uid = ?0",[uid]); break
case 'dh': nm = Collection.executeQuery("select c.name from DataHub as c where c.uid = ?0",[uid]); break
}
if (nm) {
result = [name: nm[0]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ abstract class ProviderGroupController {
return param.join(' ')
}

def auditLog(ProviderGroup pg, String eventName, String property, String oldValue, String newValue, Object persistedObject) {
protected void auditLog(ProviderGroup pg, String eventName, String property, String oldValue, String newValue, Object persistedObject) {
def audit = new AuditLogEvent(
actor: username(),
uri: pg.uid, /* MEW repurposing of uri */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class UrlMappings {
"/ws/contacts/$id/authorised(.$format)?"(controller: 'data', action: 'authorisedForContact')

// entity contacts
"/ws/$entity/$uid/contacts/$id?" {
"/ws/$entity/$uid/contacts/$id?(.$format)?" {
controller = 'data'
action = [GET: 'contactForEntity', PUT: 'updateContactFor', POST: 'updateContactFor', DELETE: 'deleteContactFor']
constraints {
Expand Down
8 changes: 5 additions & 3 deletions grails-app/domain/au/org/ala/collectory/DataHub.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class DataHub implements ProviderGroup, Serializable {
def listMemberInstitutions() {
if (!memberInstitutions) { return []}
JSON.parse(memberInstitutions).collect {
def pg = findByUid(it)
def pg = Institution.findByUid(it)
if (pg) {
[uid: it, name: pg?.name, uri: pg.buildUri()]
} else {
Expand All @@ -105,7 +105,9 @@ class DataHub implements ProviderGroup, Serializable {
def listMemberCollections() {
if (!memberCollections) { return []}
JSON.parse(memberCollections).collect {
def pg = findByUid(it)
log.info "it = ${it}"
def pg = Collection.findByUid(it)
log.info "pg = ${pg}"
if (pg) {
[uid: it, name: pg?.name, uri: pg.buildUri()]
} else {
Expand All @@ -117,7 +119,7 @@ class DataHub implements ProviderGroup, Serializable {
def listMemberDataResources() {
if (!memberDataResources) { return []}
JSON.parse(memberDataResources).collect {
def pg = DataHub.findByUid(it)
def pg = DataResource.findByUid(it)
if (pg) {
[uid: it, name: pg?.name, uri: pg.buildUri()]
} else {
Expand Down

0 comments on commit 4e3d99c

Please sign in to comment.