Skip to content

Commit f11108a

Browse files
committed
Bump 4.5.0
#279 Fixing missing supplied fields #288 Track rematching process
2 parents ccf928d + ddd805b commit f11108a

23 files changed

+929
-168
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ branches:
77
- master
88
- develop
99
- feature/grails5
10-
- bug/issue-225
1110
- review-isprivate
11+
- 279_missing_taxon
1212

1313
before_install:
1414
- rm -fr $HOME/.gradle/caches

build.gradle

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ plugins {
1616
id "com.gorylenko.gradle-git-properties" version "2.4.1"
1717
}
1818

19-
20-
version "4.4.0"
21-
19+
version "4.5.0"
2220
group "au.org.ala"
2321

2422
apply plugin:"eclipse"
@@ -130,7 +128,7 @@ dependencies {
130128
implementation "org.grails.plugins:ala-auth:$alaSecurityLibsVersion"
131129
implementation "org.grails.plugins:ala-ws-security-plugin:$alaSecurityLibsVersion"
132130
implementation "org.grails.plugins:ala-ws-plugin:$alaSecurityLibsVersion"
133-
runtimeOnly "org.grails.plugins:ala-bootstrap3:4.1.0"
131+
runtimeOnly "org.grails.plugins:ala-bootstrap3:4.3.0"
134132
implementation "au.org.ala:userdetails-service-client:$alaSecurityLibsVersion"
135133
runtimeOnly ("org.grails.plugins:ala-admin-plugin:2.3.0") {
136134
exclude module: "cache"

changelogs.txt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
21 Sep 2023
2+
Qifeng.bai@csiro.au
3+
* database change:
4+
5+
Add a new table: matchedSpecies with fields: taxonConceptID, scientificName, scientificNameAuthorship, vernacularName, kingdom, phylum, taxonClass, taxonOrder, taxonRank, family, genus
6+
7+
CREATE TABLE `matched_species` (
8+
`id` int NOT NULL AUTO_INCREMENT,
9+
`taxon_concept_id` varchar(255) DEFAULT NULL,
10+
`scientific_name` varchar(255) NOT NULL,
11+
`scientific_name_authorship` varchar(255) DEFAULT NULL,
12+
`vernacular_name` varchar(255) DEFAULT NULL,
13+
`kingdom` varchar(255) DEFAULT NULL,
14+
`phylum` varchar(255) DEFAULT NULL,
15+
`taxon_class` varchar(255) DEFAULT NULL,
16+
`taxon_order` varchar(255) DEFAULT NULL,
17+
`family` varchar(255) DEFAULT NULL,
18+
`genus` varchar(255) DEFAULT NULL,
19+
`taxon_rank` varchar(255) DEFAULT NULL,
20+
`version` BIGINT NOT NULL DEFAULT 0,
21+
UNIQUE KEY `id_UNIQUE` (`id`)
22+
)
23+
24+
Create an index for:
25+
ALTER TABLE `specieslist`.`matched_species`
26+
Add index `idx_concept_id` (`taxon_concept_id`);
27+
ALTER TABLE `specieslist`.`matched_species`
28+
Add index `idx_scientific_name` (`scientific_name`);
29+
Link the new created matchedSpecies table to speciesListItem table:
30+
ALTER TABLE `specieslist`.`species_list_item`
31+
ADD COLUMN `matched_species_id` INT DEFAULT NULL
32+

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ groovyVersion=3.0.11
44
org.gradle.daemon=true
55
org.gradle.parallel=true
66
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx1024M
7-
alaSecurityLibsVersion=6.0.4
7+
alaSecurityLibsVersion=6.1.0

grails-app/conf/application.yml

+3
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,6 @@ genusColumns: 'genus,genericEpithet,generic epithet'
261261
rankColumns: 'taxonrank,rank,taxon rank,taxonomicrank,taxonomic rank,linnaean rank'
262262
#determnines whether a list owner's email is visible on list info panel.
263263
ownerVisibleToEditor: false
264+
265+
biocacheService:
266+
baseURL: https://biocache-ws.ala.org.au/ws

grails-app/controllers/au/org/ala/specieslist/AdminController.groovy

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ class AdminController {
5757
// retrieve qualified SpeciesListItems for performance reason
5858
def itemsIds = queryService.getFilterSpeciesListItemsIds(params)
5959
def lists = queryService.getFilterListResult(params, false, itemsIds)
60+
def rematchLogs = helperService.queryRematchingProcess()
6061
def model = [lists:lists,
6162
total:lists.totalCount,
6263
typeFacets: (params.listType) ? null : queryService.getTypeFacetCounts(params, false, itemsIds),
6364
tagFacets: queryService.getTagFacetCounts(params, itemsIds),
64-
selectedFacets:queryService.getSelectedFacets(params)]
65+
selectedFacets:queryService.getSelectedFacets(params),
66+
rematchLogs: rematchLogs
67+
]
6568
if (searchTerm) {
6669
params.q = searchTerm
6770
model.errors = "Error: Search terms must contain at least 3 characters"

grails-app/controllers/au/org/ala/specieslist/EditorController.groovy

+2-5
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,14 @@ class EditorController {
213213
if (params.rawScientificName.trim() != sli.rawScientificName.trim()) {
214214
log.debug "rawScientificName is different: " + params.rawScientificName + " VS " + sli.rawScientificName
215215
sli.rawScientificName = params.rawScientificName
216-
changed = true
217216
// lookup guid
218217
helperService.matchNameToSpeciesListItem(sli.rawScientificName, sli, sli.mylist)
219218
//sli.guid = helperService.findAcceptedLsidByScientificName(sli.rawScientificName)?: helperService.findAcceptedLsidByCommonName(sli.rawScientificName)
220-
}
221-
if (changed) {
222-
log.debug "re-matching name for ${params.rawScientificName}"
223-
helperService.matchNameToSpeciesListItem(sli.rawScientificName, sli, sli.mylist)
219+
helperService.getCommonNamesAndUpdateRecords([sli],[sli.guid])
224220
sl.lastMatched = new Date()
225221
}
226222

223+
227224
if (!sli.validate()) {
228225
def message = "Could not update SpeciesListItem: ${sli.rawScientificName} - " + sli.errors.allErrors
229226
log.error message

grails-app/controllers/au/org/ala/specieslist/PublicController.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PublicController {
3939
searchTerm = params.q
4040
params.q = ""
4141
}
42-
params.max = Math.min(params.max ? params.int('max') : 25, 1000)
42+
params.max = Math.min((params.max ? params.int('max') : 25) ?: 25, 1000)
4343
params.sort = params.sort ?: "listName"
4444
if (params.isSDS){
4545
//to ensure backwards compatibility for a commonly used URL

grails-app/controllers/au/org/ala/specieslist/SpeciesListController.groovy

+14-62
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,24 @@ class SpeciesListController {
507507
/**
508508
* Rematches the scientific names in the supplied list
509509
*/
510-
@Transactional
511510
def rematch() {
511+
long beforeId = 0
512512
if (params.id && !params.id.startsWith("dr")) {
513513
params.id = SpeciesList.get(params.id)?.dataResourceUid
514514
log.info("Rematching for " + params.id)
515515
} else {
516-
log.error("Rematching for ALL")
516+
String msg = "Rematching for ALL"
517+
if (params.beforeId) {
518+
try {
519+
beforeId = Long.parseLong(params.beforeId)
520+
if ( beforeId > 0) {
521+
msg = "Continue to rematch the rest of species before id: " + beforeId
522+
}
523+
}catch(Exception e){
524+
}
525+
}
526+
527+
log.warn(msg)
517528
}
518529
Integer totalRows, offset = 0;
519530
String id = params.id
@@ -523,66 +534,7 @@ class SpeciesListController {
523534
return
524535
}
525536

526-
if (id) {
527-
totalRows = SpeciesListItem.countByDataResourceUid(id)
528-
} else {
529-
totalRows = SpeciesListItem.count();
530-
}
531-
532-
while (offset < totalRows) {
533-
List items
534-
List guidBatch = [], sliBatch = []
535-
Map<SpeciesList, List<SpeciesListItem>> batches = new HashMap<>()
536-
List<SpeciesListItem> searchBatch = new ArrayList<SpeciesListItem>()
537-
if (id) {
538-
items = SpeciesListItem.findAllByDataResourceUid(id, [max: BATCH_SIZE, offset: offset])
539-
} else {
540-
items = SpeciesListItem.list(max: BATCH_SIZE, offset: offset)
541-
}
542-
543-
SpeciesListItem.withSession { session ->
544-
items.eachWithIndex { SpeciesListItem item, Integer i ->
545-
SpeciesList speciesList = item.mylist
546-
List<SpeciesListItem> batch = batches.get(speciesList)
547-
if (batch == null) {
548-
batch = new ArrayList<>();
549-
batches.put(speciesList, batch)
550-
}
551-
String rawName = item.rawScientificName
552-
log.debug i + ". Rematching: " + rawName + "/" + speciesList.dataResourceUid
553-
if (rawName && rawName.length() > 0) {
554-
batch.add(item)
555-
} else {
556-
item.guid = null
557-
if (!item.save(flush: true)) {
558-
log.error "Error saving item (" + rawName + "): " + item.errors()
559-
}
560-
}
561-
}
562-
batches.each { list, batch ->
563-
helperService.matchAll(batch, list)
564-
batch.each {SpeciesListItem item ->
565-
if (item.guid) {
566-
guidBatch.push(item.guid)
567-
sliBatch.push(item)
568-
}
569-
}
570-
}
571-
572-
if (!guidBatch.isEmpty()) {
573-
helperService.getCommonNamesAndUpdateRecords(sliBatch, guidBatch)
574-
}
575-
576-
session.flush()
577-
session.clear()
578-
}
579-
580-
offset += BATCH_SIZE;
581-
log.info("Rematched ${offset} of ${totalRows} - ${Math.round(offset * 100 / totalRows)}% complete")
582-
if (offset > totalRows) {
583-
log.error("Rematched ${offset} of ${totalRows} - ${Math.round(offset * 100 / totalRows)}% complete")
584-
}
585-
}
537+
helperService.rematch(id,beforeId)
586538

587539
render(text: "${message(code: 'admin.lists.page.button.rematch.messages', default: 'Rematch complete')}")
588540
}

grails-app/controllers/au/org/ala/specieslist/SpeciesListItemController.groovy

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package au.org.ala.specieslist
1818

1919
import com.opencsv.CSVWriter
2020
import grails.converters.JSON
21+
import groovy.json.JsonBuilder
22+
import groovy.json.JsonOutput
2123

2224
class SpeciesListItemController {
2325

@@ -110,7 +112,7 @@ class SpeciesListItemController {
110112
} else {
111113
if (requestParams.message)
112114
flash.message = requestParams.message
113-
requestParams.max = Math.min(requestParams.max ? requestParams.int('max') : 10, 100)
115+
requestParams.max = Math.min(requestParams.max ? requestParams.int('max') : 100, 1000)
114116
requestParams.sort = requestParams.sort ?: "itemOrder"
115117
requestParams.offset = requestParams.int('offset') ?: 0
116118
requestParams.fetch = [kvpValues: 'select']
@@ -133,10 +135,13 @@ class SpeciesListItemController {
133135

134136
log.debug("Checking speciesList: " + speciesList)
135137
log.debug("Checking editors: " + speciesList.editors)
138+
def speciesListItems = queryService.getSpeciesListItemsByParams(requestParams, baseQueryAndParamsForListingSLI)
139+
140+
136141
render(view: 'list', model: [
137142
speciesList: speciesList,
138143
params: requestParams,
139-
results: queryService.getSpeciesListItemsByParams(requestParams, baseQueryAndParamsForListingSLI),
144+
results: speciesListItems,
140145
totalCount: queryService.getTotalCountByParams(requestParams, baseQueryAndParams),
141146
noMatchCount: noMatchCount,
142147
distinctCount: queryService.getDistinctCountByParams(requestParams, baseQueryAndParams),

grails-app/controllers/au/org/ala/specieslist/UrlMappings.groovy

+6
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ class UrlMappings {
3737
action = [GET:'getListItemDetails']
3838
}
3939

40+
"/ws/createItem" (controller: 'webService', action: 'createItem')
41+
42+
"/ws/deleteItem" (controller: 'webService', action: 'deleteItem')
43+
4044
"/ws/queryListItemOrKVP" (controller: 'webService'){
4145
action = [GET:'queryListItemOrKVP']
4246
}
4347

4448
//"/ws/speciesListItems" (controller: "webService", action: "getListItemDetails")
49+
"/ws/findSpeciesByName" (controller: "webService", action: "findSpeciesByName")
4550
"/ws/speciesListItems/keys" (controller: "webService", action: "listKeys")
4651
"/ws/speciesListItems/byKeys" (controller: "webService", action: "listItemsByKeys")
4752

@@ -66,6 +71,7 @@ class UrlMappings {
6671
action = [GET: 'getSpeciesListItemKvp']
6772
}
6873

74+
"/ws/rematchStatus" (controller: "webService", action: "rematchStatus")
6975
"/"(controller: 'public' ,action: 'index')
7076
"500"(view:'/error')
7177
"404"(view:'/404')

0 commit comments

Comments
 (0)