1
|
/**
|
2
|
* Copyright (C) 2018 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.vaadin.model.name;
|
10
|
|
11
|
import java.util.HashSet;
|
12
|
import java.util.List;
|
13
|
import java.util.Set;
|
14
|
|
15
|
import org.joda.time.DateTime;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
18
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
19
|
import eu.etaxonomy.cdm.model.common.Credit;
|
20
|
import eu.etaxonomy.cdm.model.common.Extension;
|
21
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
22
|
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
|
23
|
import eu.etaxonomy.cdm.model.common.User;
|
24
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
25
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
26
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
27
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
28
|
import eu.etaxonomy.cdm.model.name.Rank;
|
29
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
30
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
31
|
import eu.etaxonomy.cdm.vaadin.model.CdmEntityDecoraterDTO;
|
32
|
|
33
|
/**
|
34
|
* @author a.kohlbecker
|
35
|
* @since Apr 23, 2018
|
36
|
*
|
37
|
*/
|
38
|
public class TaxonNameDTO extends CdmEntityDecoraterDTO<TaxonName> {
|
39
|
|
40
|
class TN extends TaxonName {
|
41
|
|
42
|
}
|
43
|
|
44
|
private static final long serialVersionUID = -8018109905949198530L;
|
45
|
|
46
|
private TaxonName name;
|
47
|
|
48
|
private Set<TaxonName> persistedBasionyms;
|
49
|
|
50
|
private Set<TaxonName> persistedReplacedSynonyms;
|
51
|
|
52
|
/**
|
53
|
* @param entity
|
54
|
*/
|
55
|
public TaxonNameDTO(TaxonName entity) {
|
56
|
super(entity);
|
57
|
name = entity;
|
58
|
}
|
59
|
|
60
|
public String getAcronym() {
|
61
|
return name.getAcronym();
|
62
|
}
|
63
|
|
64
|
public Set<Annotation> getAnnotations() {
|
65
|
return name.getAnnotations();
|
66
|
}
|
67
|
|
68
|
public String getAppendedPhrase() {
|
69
|
return name.getAppendedPhrase();
|
70
|
}
|
71
|
|
72
|
public String getAuthorshipCache() {
|
73
|
|
74
|
return name.getAuthorshipCache();
|
75
|
}
|
76
|
|
77
|
public TeamOrPersonBase<?> getBasionymAuthorship() {
|
78
|
return name.getBasionymAuthorship();
|
79
|
}
|
80
|
|
81
|
public Set<TaxonName> getBasionyms() {
|
82
|
Set<TaxonName> basionyms = name.getRelatedNames(Direction.relatedTo, NameRelationshipType.BASIONYM());
|
83
|
if(persistedBasionyms == null){
|
84
|
// remember the persisted state before starting to operate on the DTO
|
85
|
persistedBasionyms = basionyms;
|
86
|
}
|
87
|
return basionyms;
|
88
|
}
|
89
|
|
90
|
public Set<TaxonName> getReplacedSynonyms() {
|
91
|
Set<TaxonName> replacedSynonyms = name.getRelatedNames(Direction.relatedTo, NameRelationshipType.REPLACED_SYNONYM());
|
92
|
if(persistedReplacedSynonyms == null){
|
93
|
// remember the persisted state before starting to operate on the DTO
|
94
|
persistedReplacedSynonyms = replacedSynonyms;
|
95
|
}
|
96
|
return replacedSynonyms;
|
97
|
}
|
98
|
|
99
|
public void setBasionyms(Set<TaxonName> basionyms) {
|
100
|
setRelatedNames(Direction.relatedTo, NameRelationshipType.BASIONYM(), basionyms);
|
101
|
}
|
102
|
|
103
|
public void setReplacedSynonyms(Set<TaxonName> replacedSynonyms) {
|
104
|
setRelatedNames(Direction.relatedTo, NameRelationshipType.REPLACED_SYNONYM(), replacedSynonyms);
|
105
|
}
|
106
|
|
107
|
/**
|
108
|
* @param basionyms
|
109
|
* @param relType
|
110
|
* @param direction
|
111
|
*/
|
112
|
protected void setRelatedNames(Direction direction, NameRelationshipType relType, Set<TaxonName> relatedNames) {
|
113
|
Set<TaxonName> currentRelatedNames = new HashSet<>();
|
114
|
Set<TaxonName> namesSeen = new HashSet<>();
|
115
|
|
116
|
for(TaxonName tn : name.getRelatedNames(direction, relType)){
|
117
|
currentRelatedNames.add(tn);
|
118
|
}
|
119
|
for(TaxonName tn : relatedNames){
|
120
|
if(tn == null){
|
121
|
continue;
|
122
|
}
|
123
|
if(!currentRelatedNames.contains(tn)){
|
124
|
if(direction.equals(Direction.relatedTo)){
|
125
|
tn.addRelationshipToName(name, relType, null);
|
126
|
} else {
|
127
|
tn.addRelationshipFromName(name, relType, null);
|
128
|
}
|
129
|
}
|
130
|
namesSeen.add(tn);
|
131
|
}
|
132
|
for(TaxonName tn : currentRelatedNames){
|
133
|
if(!namesSeen.contains(tn)){
|
134
|
name.removeRelationWithTaxonName(tn, direction, relType);
|
135
|
}
|
136
|
}
|
137
|
}
|
138
|
|
139
|
public Set<TaxonName> persistedBasionyms(){
|
140
|
return persistedBasionyms;
|
141
|
}
|
142
|
|
143
|
public TeamOrPersonBase<?> getCombinationAuthorship() {
|
144
|
return name.getCombinationAuthorship();
|
145
|
}
|
146
|
|
147
|
public List<Credit> getCredits() {
|
148
|
return name.getCredits();
|
149
|
}
|
150
|
|
151
|
public String getCultivarName() {
|
152
|
return name.getCultivarName();
|
153
|
}
|
154
|
|
155
|
public TeamOrPersonBase<?> getExBasionymAuthorship() {
|
156
|
return name.getExBasionymAuthorship();
|
157
|
}
|
158
|
|
159
|
public TeamOrPersonBase<?> getExCombinationAuthorship() {
|
160
|
return name.getExCombinationAuthorship();
|
161
|
}
|
162
|
|
163
|
public Set<Extension> getExtensions() {
|
164
|
return name.getExtensions();
|
165
|
}
|
166
|
|
167
|
public String getFullTitleCache() {
|
168
|
return name.getFullTitleCache();
|
169
|
}
|
170
|
|
171
|
public String getGenusOrUninomial() {
|
172
|
return name.getGenusOrUninomial();
|
173
|
}
|
174
|
|
175
|
public HomotypicalGroup getHomotypicalGroup() {
|
176
|
return name.getHomotypicalGroup();
|
177
|
}
|
178
|
|
179
|
public List<Identifier> getIdentifiers() {
|
180
|
return name.getIdentifiers();
|
181
|
}
|
182
|
|
183
|
public String getInfraGenericEpithet() {
|
184
|
return name.getInfraGenericEpithet();
|
185
|
}
|
186
|
|
187
|
public String getInfraSpecificEpithet() {
|
188
|
return name.getInfraSpecificEpithet();
|
189
|
}
|
190
|
|
191
|
public String getSpecificEpithet() {
|
192
|
return name.getSpecificEpithet();
|
193
|
}
|
194
|
|
195
|
public String getNameCache() {
|
196
|
return name.getNameCache();
|
197
|
}
|
198
|
|
199
|
public String getNomenclaturalMicroReference() {
|
200
|
return name.getNomenclaturalMicroReference();
|
201
|
}
|
202
|
|
203
|
public INomenclaturalReference getNomenclaturalReference() {
|
204
|
return name.getNomenclaturalReference();
|
205
|
}
|
206
|
|
207
|
public Rank getRank() {
|
208
|
return name.getRank();
|
209
|
}
|
210
|
|
211
|
public Set<NomenclaturalStatus> getStatus() {
|
212
|
return name.getStatus();
|
213
|
}
|
214
|
|
215
|
public boolean isProtectedAuthorshipCache() {
|
216
|
return name.isProtectedAuthorshipCache();
|
217
|
}
|
218
|
|
219
|
public boolean isProtectedFullTitleCache() {
|
220
|
return name.isProtectedFullTitleCache();
|
221
|
}
|
222
|
|
223
|
public boolean isProtectedNameCache() {
|
224
|
return name.isProtectedNameCache();
|
225
|
}
|
226
|
|
227
|
public boolean isProtectedTitleCache() {
|
228
|
return name.isProtectedTitleCache();
|
229
|
}
|
230
|
|
231
|
public void setAcronym(String acronym) {
|
232
|
name.setAcronym(acronym);
|
233
|
}
|
234
|
|
235
|
public void setAppendedPhrase(String appendedPhrase) {
|
236
|
name.setAppendedPhrase(appendedPhrase);
|
237
|
}
|
238
|
|
239
|
public void setBasionymAuthorship(TeamOrPersonBase<?> basionymAuthorship) {
|
240
|
name.setBasionymAuthorship(basionymAuthorship);
|
241
|
}
|
242
|
|
243
|
public void setBinomHybrid(boolean binomHybrid) {
|
244
|
name.setBinomHybrid(binomHybrid);
|
245
|
}
|
246
|
|
247
|
public void setBreed(String breed) {
|
248
|
name.setBreed(breed);
|
249
|
}
|
250
|
|
251
|
public void setCombinationAuthorship(TeamOrPersonBase<?> combinationAuthorship) {
|
252
|
name.setCombinationAuthorship(combinationAuthorship);
|
253
|
}
|
254
|
|
255
|
public void setCultivarName(String cultivarName) {
|
256
|
name.setCultivarName(cultivarName);
|
257
|
}
|
258
|
|
259
|
public void setExBasionymAuthorship(TeamOrPersonBase<?> exBasionymAuthorship) {
|
260
|
name.setExBasionymAuthorship(exBasionymAuthorship);
|
261
|
}
|
262
|
|
263
|
public void setExCombinationAuthorship(TeamOrPersonBase<?> exCombinationAuthorship) {
|
264
|
name.setExCombinationAuthorship(exCombinationAuthorship);
|
265
|
}
|
266
|
|
267
|
public void setFullTitleCache(String fullTitleCache) {
|
268
|
name.setFullTitleCache(fullTitleCache);
|
269
|
}
|
270
|
|
271
|
public void setGenusOrUninomial(String genusOrUninomial) {
|
272
|
name.setGenusOrUninomial(genusOrUninomial);
|
273
|
}
|
274
|
|
275
|
public void setHybridFormula(boolean hybridFormula) {
|
276
|
name.setHybridFormula(hybridFormula);
|
277
|
}
|
278
|
|
279
|
public void setInfraGenericEpithet(String infraGenericEpithet) {
|
280
|
name.setInfraGenericEpithet(infraGenericEpithet);
|
281
|
}
|
282
|
|
283
|
public void setInfraSpecificEpithet(String infraSpecificEpithet) {
|
284
|
name.setInfraSpecificEpithet(infraSpecificEpithet);
|
285
|
}
|
286
|
|
287
|
public void setMonomHybrid(boolean monomHybrid) {
|
288
|
name.setMonomHybrid(monomHybrid);
|
289
|
}
|
290
|
|
291
|
public void setNameApprobation(String nameApprobation) {
|
292
|
name.setNameApprobation(nameApprobation);
|
293
|
}
|
294
|
|
295
|
public void setNameCache(String nameCache) {
|
296
|
name.setNameCache(nameCache);
|
297
|
}
|
298
|
|
299
|
public void setNameType(NomenclaturalCode nameType) {
|
300
|
name.setNameType(nameType);
|
301
|
}
|
302
|
|
303
|
public void setNomenclaturalMicroReference(String nomenclaturalMicroReference) {
|
304
|
name.setNomenclaturalMicroReference(nomenclaturalMicroReference);
|
305
|
}
|
306
|
|
307
|
public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference) {
|
308
|
name.setNomenclaturalReference(nomenclaturalReference);
|
309
|
}
|
310
|
|
311
|
public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache) {
|
312
|
name.setProtectedAuthorshipCache(protectedAuthorshipCache);
|
313
|
}
|
314
|
|
315
|
public void setProtectedFullTitleCache(boolean protectedFullTitleCache) {
|
316
|
name.setProtectedFullTitleCache(protectedFullTitleCache);
|
317
|
}
|
318
|
|
319
|
public void setProtectedNameCache(boolean protectedNameCache) {
|
320
|
name.setProtectedNameCache(protectedNameCache);
|
321
|
}
|
322
|
|
323
|
public void setProtectedTitleCache(boolean protectedTitleCache) {
|
324
|
name.setProtectedTitleCache(protectedTitleCache);
|
325
|
}
|
326
|
|
327
|
public void setRank(Rank rank) {
|
328
|
name.setRank(rank);
|
329
|
}
|
330
|
|
331
|
public void setSpecificEpithet(String specificEpithet) {
|
332
|
name.setSpecificEpithet(specificEpithet);
|
333
|
}
|
334
|
|
335
|
public void setTitleCache(String titleCache) {
|
336
|
name.setTitleCache(titleCache);
|
337
|
}
|
338
|
|
339
|
public void setTrinomHybrid(boolean trinomHybrid) {
|
340
|
name.setTrinomHybrid(trinomHybrid);
|
341
|
}
|
342
|
|
343
|
public void setUpdated(DateTime updated) {
|
344
|
name.setUpdated(updated);
|
345
|
}
|
346
|
|
347
|
public void setUpdatedBy(User updatedBy) {
|
348
|
name.setUpdatedBy(updatedBy);
|
349
|
}
|
350
|
|
351
|
}
|