Skip to content

Commit

Permalink
openapi and new admin functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Collins committed Aug 4, 2023
1 parent f7feff3 commit 29cdddf
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 23 deletions.
4 changes: 2 additions & 2 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ skin:
useLegacyAuto: false
import:
sequence: collectory,taxonomy-all,vernacular,denormalise,layers,regions,localities,conservation-lists,wordpress,knowledgebase,favourites,weights,link-identifiers,images,occurrences,hidden-images,wiki-urls,suggest-index,swap
sequenceDaily: conservation-lists,wordpress,knowledgebase,favourites,images,occurrences,hidden-images,wiki-urls,suggest-index,swap
sequenceWeekly: layers,regions,localities,suggest-index,swap
sequenceDaily: conservation-lists,wordpress,knowledgebase,favourites,suggest-index,swap
sequenceWeekly: images,hidden-images,wiki-urls,occurrences,layers,regions,localities,suggest-index,swap
# run daily sequence on this hour
dailyRunHour: 2
# run weekly sequence on this day (6 == Saturday)
Expand Down
13 changes: 13 additions & 0 deletions grails-app/controllers/au/org/ala/bie/ImportController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ class ImportController {

}

def importWikiUrls(){
boolean online = params.getBoolean('online', false)
def job = execute("buildWikiUrls", "admin.button.importlistwiki", { importService.loadWikiUrls(online) })
asJson (job.status())
}

def importHiddenImages(){
boolean online = params.getBoolean('online', false)
def job = execute("buildHiddenImages", "admin.button.importlisthiddenimages", { importService.loadHiddenImages(online) })
asJson (job.status())

}

// Documented in openapi.yml
def buildLinkIdentifiers() {
def online = params.getBoolean('online', false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ImportServicesController {
"importWordPressPages,importOccurrences,importConsevationSpeciesLists,buildVernacularSpeciesLists,buildLinkIdentifiers" +
"denormaliseTaxa,loadImages,",
"admin.button.importall",
{ importService.importAll() })
{ importService.importAll(importService.importSequence, false) })
asJson(job.status())
}

Expand Down
2 changes: 2 additions & 0 deletions grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ admin.button.importdwca=Import DwCA
admin.button.importlayer=Import layer information
admin.button.importlistconservation=Import conservation species lists
admin.button.importlistvernacular=Import vernacular name species lists
admin.button.importlistwiki=Import wiki url species lists
admin.button.importlisthiddenimages=Import hidden image species lists
admin.button.importlocalities=Import localities information
admin.button.importregions=Import regions information
admin.button.jobStatus=Status
Expand Down
3 changes: 3 additions & 0 deletions grails-app/views/admin/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
<div>
<button id="start-import-swap" onclick="javascript:loadInfo('${createLink(controller:'import', action:'swap')}')" class="btn btn-primary import-button"><g:message code="admin.button.swap"/></button>
</div>
<div>
<g:render template="../import/status" model="${[showTitle: true, showJob: true, showLog: true, startLog: false]}"/>
</div>

</body>
</html>
6 changes: 6 additions & 0 deletions grails-app/views/import/specieslist.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
<div>
<button id="start-vernacular-import" onclick="javascript:loadInfo('${createLink(controller:'import', action:'importVernacularSpeciesLists')}?online=' + $('#use-online').is(':checked'))" class="btn btn-primary import-button"><g:message code="admin.button.importlistvernacular"/></button>
</div>
<div>
<button id="start-hidden-images-import" onclick="javascript:loadInfo('${createLink(controller:'import', action:'importHiddenImages')}?online=' + $('#use-online').is(':checked'))" class="btn btn-primary import-button"><g:message code="admin.button.importlisthiddenimages"/></button>
</div>
<div>
<button id="start-wiki-import" onclick="javascript:loadInfo('${createLink(controller:'import', action:'importWikiUrls')}?online=' + $('#use-online').is(':checked'))" class="btn btn-primary import-button"><g:message code="admin.button.importlistwiki"/></button>
</div>
<div>
<input type="checkbox" id="use-online" name="use-online"/> <g:message code="admin.label.useonline"/>
</div>
Expand Down
76 changes: 56 additions & 20 deletions src/main/resources/public/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ paths:
required: false
responses:
200:
description: 'Search results'
description: 'Search results'
content:
application/json:
schema:
Expand Down Expand Up @@ -134,12 +134,12 @@ paths:
schema:
type: string
required: true
description: Numeric ID of the taxon
description: Numeric ID of the taxon
responses:
404:
description: The identifier was not found
200:
description: 'Species info in JSON'
description: 'Species info in JSON'
content:
application/json:
schema:
Expand Down Expand Up @@ -221,7 +221,7 @@ paths:
type: array
description: Alternative sources for the base taxon concept (including itself)
items:
$ref: '#/components/schemas/TaxonConcept'
$ref: '#/components/schemas/TaxonConcept'
tags:
- lookup
/species/{id}:
Expand All @@ -236,7 +236,7 @@ paths:
404:
description: The identifier was not found
200:
description: 'Species info in JSON'
description: 'Species info in JSON'
content:
application/json:
schema:
Expand Down Expand Up @@ -331,7 +331,7 @@ paths:
404:
description: The identifier was not found
200:
description: 'Classification info in JSON'
description: 'Classification info in JSON'
content:
application/json:
schema:
Expand Down Expand Up @@ -374,7 +374,7 @@ paths:
404:
description: The identifier was not found
200:
description: 'Child concepts list in JSON'
description: 'Child concepts list in JSON'
content:
application/json:
schema:
Expand Down Expand Up @@ -423,7 +423,7 @@ paths:
type: string
responses:
200:
description: 'Image seearch list in JSON'
description: 'Image seearch list in JSON'
content:
application/json:
schema:
Expand Down Expand Up @@ -570,7 +570,7 @@ paths:
type: string
responses:
200:
description: List of short profile for taxa
description: List of short profile for taxa
content:
application/json:
schema:
Expand Down Expand Up @@ -600,7 +600,7 @@ paths:
404:
description: If a guid is not found
200:
description: List of short profile for taxa
description: List of short profile for taxa
content:
application/json:
schema:
Expand Down Expand Up @@ -685,7 +685,7 @@ paths:
400:
description: On an invalid request
200:
description: List of long profiles for taxa
description: List of long profiles for taxa
content:
application/json:
schema:
Expand All @@ -712,7 +712,7 @@ paths:
required: false
responses:
200:
description: Zipped file containing CSV
description: Zipped file containing CSV
content:
text/csv:
schema:
Expand Down Expand Up @@ -766,7 +766,7 @@ paths:
500:
description: If unable to connect to the solr index
200:
description: List of indexed fields in JSON
description: List of indexed fields in JSON
content:
application/json:
schema:
Expand Down Expand Up @@ -842,7 +842,7 @@ paths:
500:
description: If unable to connect to the solr index
200:
description: A list of habitats in JSON
description: A list of habitats in JSON
content:
application/json:
schema:
Expand All @@ -863,7 +863,7 @@ paths:
500:
description: If unable to connect to the solr index
200:
description: A tree structure of habitats in JSON
description: A tree structure of habitats in JSON
content:
application/json:
schema:
Expand All @@ -879,7 +879,7 @@ paths:
tags:
- metadata
parameters:
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/idParam'
responses:
500:
description: If unable to connect to the solr index
Expand All @@ -902,7 +902,7 @@ paths:
tags:
- metadata
parameters:
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/idParam'
responses:
500:
description: If unable to connect to the solr index
Expand Down Expand Up @@ -1189,6 +1189,42 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/JobStatus'
/admin/import/importWikiUrls:
get:
summary: Import wikipedia URLs from species lists
description: >
Remove wiki urls removed from lists and import URLs from lists
tags:
- admin
parameters:
- $ref: '#/components/parameters/onlineParam'
security:
- cas: [ ]
responses:
200:
description: JSON response indicating job status
content:
application/json:
schema:
$ref: '#/components/schemas/JobStatus'
/admin/import/importHiddenImages:
get:
summary: Import hidden images from species lists
description: >
Remove images no longer hidden and import lists of hidden images for taxa
tags:
- admin
parameters:
- $ref: '#/components/parameters/onlineParam'
security:
- cas: [ ]
responses:
200:
description: JSON response indicating job status
content:
application/json:
schema:
$ref: '#/components/schemas/JobStatus'
/admin/import/buildLinkIdentifiers:
get:
summary: Build link identifiers for unique taxa
Expand Down Expand Up @@ -1353,7 +1389,7 @@ paths:
tags:
- admin
parameters:
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/formatParam'
security:
- cas: []
Expand All @@ -1373,7 +1409,7 @@ paths:
tags:
- admin
parameters:
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/formatParam'
security:
- cas: []
Expand All @@ -1393,7 +1429,7 @@ paths:
tags:
- admin
parameters:
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/idParam'
- $ref: '#/components/parameters/formatParam'
security:
- cas: []
Expand Down

0 comments on commit 29cdddf

Please sign in to comment.