forked from AtlasOfLivingAustralia/specieslist-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpeciesList.groovy
98 lines (90 loc) · 2.98 KB
/
SpeciesList.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (C) 2022 Atlas of Living Australia
* All Rights Reserved.
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*/
package au.org.ala.specieslist
import au.org.ala.names.ws.api.SearchStyle
class SpeciesList {
def authService
String listName
String firstName
String surname
String username
String userId
String dataResourceUid
String description
String url
String wkt
Date dateCreated
Date lastUpdated
Date lastUploaded
ListType listType
Boolean isPrivate
Boolean isSDS
Boolean isBIE
Boolean isAuthoritative
Boolean isInvasive
Boolean isThreatened
Long itemsCount = 0
String region
String authority
String generalisation
String category
String sdsType
Boolean looseSearch // if undefined use the server default
SearchStyle searchStyle // if undefined use the server default
String ownerFullName // derived by concatenating the firstName and surname fields
static transients = [ "fullName" ]
static hasMany = [items: SpeciesListItem, editors: String]
static constraints = {
url(nullable:true)
description(nullable: true)
wkt(nullable: true)
listType nullable: true, index: 'idx_listtype'
isPrivate nullable:true, index: 'idx_listprivate'
isSDS nullable:true
isBIE nullable:true
isAuthoritative nullable: true
isInvasive nullable: true
isThreatened nullable: true
firstName nullable: true
surname nullable: true
editors nullable: true
region(nullable: true)
category nullable: true
generalisation(nullable: true)
authority(nullable: true)
sdsType nullable: true
looseSearch nullable: true
searchStyle nullable: true
lastUploaded nullable: true
userId nullable: true
ownerFullName nullable: true // derived
}
static mapping = {
dataResourceUid index: 'idx_data_resource_uid'
items cascade: "all-delete-orphan"
listType index: 'idx_listtype'
username index: 'idx_username'
isBIE index: 'idx_listbie'
isSDS index: 'idx_listsds'
wkt type: 'text'
description type: 'text'
itemsCount formula: "(select count(*) from species_list_item sli where sli.list_id = id)"
ownerFullName formula: "concat(first_name, ' ', surname)" // derived to allow easier sorting by owner name
}
def String getFullName(){
def user = authService?.getUserForUserId(username)
user?.displayName
}
}