-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from charvolant/name-match-redesign
Release version 1.4.1
- Loading branch information
Showing
29 changed files
with
44,614 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
grails-app/controllers/au/org/ala/bie/ImportServicesController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package au.org.ala.bie | ||
|
||
import au.ala.org.ws.security.RequireApiKey | ||
import grails.converters.JSON | ||
|
||
/** | ||
* A controller for managing imoort via web service rather than UI | ||
*/ | ||
@RequireApiKey | ||
class ImportServicesController { | ||
def importService | ||
def jobService | ||
|
||
/** | ||
* Import all | ||
*/ | ||
def all() { | ||
def job = execute( | ||
"importDwca,importCollectory,deleteDanglingSynonyms,importLayers,importLocalities,importRegions,importHabitats,importHabitats," + | ||
"importWordPressPages,importOccurrences,importConsevationSpeciesLists,buildVernacularSpeciesLists,buildLinkIdentifiers" + | ||
"denormaliseTaxa,loadImages,", | ||
"admin.button.importall", | ||
{ importService.importAll() }) | ||
asJson(job.status()) | ||
} | ||
|
||
/** | ||
* Get a job status | ||
*/ | ||
def status() { | ||
def id = params.id | ||
def status = jobService.get(id)?.status() ?: notFoundStatus(id) | ||
asJson(status) | ||
} | ||
|
||
private def asJson = { model -> | ||
response.setContentType("application/json;charset=UTF-8") | ||
render (model as JSON) | ||
} | ||
|
||
private def execute(String type, String titleCode, Closure task) { | ||
def title = message(code: titleCode) | ||
def types = type.split(',') as Set | ||
def job = jobService.existing(types) | ||
if (job) { | ||
return job | ||
} | ||
job = jobService.create(types, title, task) | ||
} | ||
|
||
private def notFoundStatus(id) { | ||
return [success: false, active: false, id: id, lifecycle: 'ERROR', lastUpdated: new Date(), message: 'Not found'] | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
grails-app/controllers/au/org/ala/bie/JobController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package au.org.ala.bie | ||
|
||
import au.org.ala.web.AlaSecured | ||
import grails.converters.JSON | ||
import grails.converters.XML | ||
|
||
@AlaSecured(value = "ROLE_ADMIN", redirectUri = "/") | ||
class JobController { | ||
def jobService | ||
|
||
def index() { | ||
def jobs = jobService.list().collect { it.status() } | ||
withFormat { | ||
html jobs: jobs | ||
json { render jobs as JSON } | ||
xml { render jobs as XML } | ||
'*' jobs: jobs | ||
} | ||
} | ||
|
||
def status() { | ||
def id = params.id | ||
def status = jobService.get(id)?.status() ?: notFoundStatus(id) | ||
withFormat { | ||
html job: status | ||
json { render status as JSON } | ||
xml { render status as XML } | ||
'*' job: status | ||
} | ||
} | ||
|
||
def panel() { | ||
def id = params.id | ||
def status = jobService.get(id)?.status() ?: notFoundStatus(id) | ||
[job: status] | ||
} | ||
|
||
def cancel() { | ||
def id = params.id | ||
jobService.cancel(params.id) | ||
def status = jobService.get(id)?.status() ?: notFoundStatus(id) | ||
withFormat { | ||
html { render view: 'status', model: [job: status] } | ||
json { render status as JSON } | ||
xml { render status as XML } | ||
'*' { render view: 'status', model: [job: status] } | ||
} | ||
} | ||
|
||
def remove() { | ||
def id = params.id | ||
def removed = jobService.remove(params.id) | ||
def status = [success: removed] | ||
withFormat { | ||
html { redirect(action: 'index') } | ||
json { render status as JSON } | ||
xml { render status as XML } | ||
'*' { redirect(action: 'index') } | ||
} | ||
} | ||
|
||
private def notFoundStatus(id) { | ||
return [success: false, active: false, id: id, lifecycle: 'ERROR', lastUpdated: new Date(), message: 'Not found'] | ||
} | ||
} |
Oops, something went wrong.