1
|
/**
|
2
|
* Copyright (C) 2016 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.persistence.dto;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.List;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
16
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
17
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
18
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
19
|
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
|
20
|
|
21
|
/**
|
22
|
* @author a.kohlbecker
|
23
|
* @since Jun 13, 2016
|
24
|
*
|
25
|
*/
|
26
|
public class TaxonNodeDto extends UuidAndTitleCache<ITaxonTreeNode> {
|
27
|
|
28
|
private static final long serialVersionUID = -7169646913528213604L;
|
29
|
|
30
|
/**
|
31
|
* count of the direct taxonomic children
|
32
|
*/
|
33
|
private final int taxonomicChildrenCount;
|
34
|
|
35
|
/**
|
36
|
* The UUID of the associated secundum reference
|
37
|
*/
|
38
|
private UUID secUuid = null;
|
39
|
|
40
|
/**
|
41
|
* The uuid of the associated Taxon entity
|
42
|
*/
|
43
|
private UUID taxonUuid = null;
|
44
|
|
45
|
/**
|
46
|
* the taggedTitle of the associated TaxonName entity
|
47
|
*/
|
48
|
private List<TaggedText> taggedTitle = new ArrayList<>();
|
49
|
|
50
|
/**
|
51
|
* The unplaced flag of the Taxon entity
|
52
|
*/
|
53
|
private final boolean unplaced;
|
54
|
|
55
|
/**
|
56
|
* The excluded flag of the Taxon entity
|
57
|
*/
|
58
|
private final boolean excluded;
|
59
|
|
60
|
/**
|
61
|
* The Rank.label value of the rank to which the associated TaxonName entity is assigned to.
|
62
|
*/
|
63
|
private String rankLabel = null;
|
64
|
private Integer rankOrderIndex;
|
65
|
|
66
|
private final TaxonStatus status;
|
67
|
|
68
|
private final UUID classificationUUID;
|
69
|
private final UUID parentUUID;
|
70
|
|
71
|
private final String treeIndex;
|
72
|
private final Integer sortIndex;
|
73
|
|
74
|
/**
|
75
|
* @param taxonNode
|
76
|
*/
|
77
|
public TaxonNodeDto(TaxonNode taxonNode) {
|
78
|
this(null, taxonNode);
|
79
|
}
|
80
|
|
81
|
public TaxonNodeDto(Class type, TaxonNode taxonNode) {
|
82
|
super(type, taxonNode.getUuid(), taxonNode.getId(), null);
|
83
|
Taxon taxon = taxonNode.getTaxon();
|
84
|
if (taxon != null){
|
85
|
setTitleCache(taxon.getName() != null ? taxon.getName().getTitleCache() : taxon.getTitleCache());
|
86
|
secUuid = taxon.getSec() != null ? taxon.getSec().getUuid() : null;
|
87
|
taxonUuid = taxon.getUuid();
|
88
|
taggedTitle = taxon.getName() != null? taxon.getName().getTaggedName() : taxon.getTaggedTitle();
|
89
|
rankLabel = taxon.getNullSafeRank() != null ? taxon.getNullSafeRank().getLabel() : null;
|
90
|
this.setAbbrevTitleCache(taxon.getTitleCache());
|
91
|
rankOrderIndex =taxon.getNullSafeRank() != null ? taxon.getNullSafeRank().getOrderIndex() : null;
|
92
|
|
93
|
}else{
|
94
|
setTitleCache(taxonNode.getClassification().getTitleCache());
|
95
|
rankOrderIndex = null;
|
96
|
}
|
97
|
taxonomicChildrenCount = taxonNode.getCountChildren();
|
98
|
unplaced = taxonNode.isUnplaced();
|
99
|
excluded = taxonNode.isExcluded();
|
100
|
|
101
|
status = TaxonStatus.Accepted;
|
102
|
classificationUUID = taxonNode.getClassification().getUuid();
|
103
|
treeIndex = taxonNode.treeIndex();
|
104
|
parentUUID = taxonNode.getParent() == null? null:taxonNode.getParent().getUuid();
|
105
|
sortIndex = taxonNode.getSortIndex();
|
106
|
}
|
107
|
|
108
|
/**
|
109
|
* @param taxonNode
|
110
|
*/
|
111
|
public TaxonNodeDto(Synonym synonym, boolean isHomotypic) {
|
112
|
super(null, synonym.getName().getTitleCache());
|
113
|
|
114
|
taxonomicChildrenCount = 0;
|
115
|
secUuid = synonym.getSec().getUuid();
|
116
|
taxonUuid = synonym.getUuid();
|
117
|
// setTitleCache(synonym.getName().getTitleCache());
|
118
|
taggedTitle = synonym.getName().getTaggedName();
|
119
|
unplaced = false;
|
120
|
excluded = false;
|
121
|
rankLabel = synonym.getNullSafeRank() != null ? synonym.getNullSafeRank().getLabel() : null;
|
122
|
rankOrderIndex =synonym.getNullSafeRank() != null ? synonym.getNullSafeRank().getOrderIndex() : null;
|
123
|
status = isHomotypic ? TaxonStatus.SynonymObjective : TaxonStatus.Synonym;
|
124
|
classificationUUID = null;
|
125
|
treeIndex = null;
|
126
|
sortIndex = null;
|
127
|
parentUUID = null;
|
128
|
|
129
|
}
|
130
|
|
131
|
|
132
|
|
133
|
/**
|
134
|
* @return the taxonomicChildrenCount
|
135
|
*/
|
136
|
public int getTaxonomicChildrenCount() {
|
137
|
return taxonomicChildrenCount;
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* @return the secUuid
|
142
|
*/
|
143
|
public UUID getSecUuid() {
|
144
|
return secUuid;
|
145
|
}
|
146
|
|
147
|
/**
|
148
|
* @return the taxonUuid
|
149
|
*/
|
150
|
public UUID getTaxonUuid() {
|
151
|
return taxonUuid;
|
152
|
}
|
153
|
|
154
|
|
155
|
/**
|
156
|
* @return the taggedTitle
|
157
|
*/
|
158
|
public List<TaggedText> getTaggedTitle() {
|
159
|
return taggedTitle;
|
160
|
}
|
161
|
|
162
|
/**
|
163
|
* @return the unplaced
|
164
|
*/
|
165
|
public boolean isUnplaced() {
|
166
|
return unplaced;
|
167
|
}
|
168
|
|
169
|
/**
|
170
|
* @return the excluded
|
171
|
*/
|
172
|
public boolean isExcluded() {
|
173
|
return excluded;
|
174
|
}
|
175
|
|
176
|
/**
|
177
|
* @return the rankLabel
|
178
|
*/
|
179
|
public String getRankLabel() {
|
180
|
return rankLabel;
|
181
|
}
|
182
|
|
183
|
/**
|
184
|
* @return the status
|
185
|
*/
|
186
|
public TaxonStatus getStatus() {
|
187
|
return status;
|
188
|
}
|
189
|
|
190
|
public UUID getClassificationUUID() {
|
191
|
return classificationUUID;
|
192
|
}
|
193
|
|
194
|
public String getTreeIndex() {
|
195
|
return treeIndex;
|
196
|
}
|
197
|
|
198
|
public UUID getParentUUID() {
|
199
|
return parentUUID;
|
200
|
}
|
201
|
|
202
|
public Integer getSortIndex() {
|
203
|
return sortIndex;
|
204
|
}
|
205
|
|
206
|
public Integer getRankOrderIndex() {
|
207
|
return rankOrderIndex;
|
208
|
}
|
209
|
|
210
|
public String getTaxonTitleCache(){
|
211
|
return getAbbrevTitleCache();
|
212
|
}
|
213
|
|
214
|
public String getNameTitleCache(){
|
215
|
return getTitleCache();
|
216
|
}
|
217
|
|
218
|
|
219
|
}
|