Project

General

Profile

Download (9.25 KB) Statistics
| Branch: | Tag: | Revision:
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
    /**
51
     * @param entity
52
     */
53
    public TaxonNameDTO(TaxonName entity) {
54
        super(entity);
55
        name = entity;
56
    }
57

    
58
    public String getAcronym() {
59
        return name.getAcronym();
60
    }
61

    
62
    public Set<Annotation> getAnnotations() {
63
        return name.getAnnotations();
64
    }
65

    
66
    public String getAppendedPhrase() {
67
        return name.getAppendedPhrase();
68
    }
69

    
70
    public String getAuthorshipCache() {
71

    
72
        return name.getAuthorshipCache();
73
    }
74

    
75
    public TeamOrPersonBase<?> getBasionymAuthorship() {
76
        return name.getBasionymAuthorship();
77
    }
78

    
79
    public Set<TaxonName> getBasionyms() {
80
        Set<TaxonName> basionyms = name.getRelatedNames(Direction.relatedTo, NameRelationshipType.BASIONYM());
81
        if(persistedBasionyms == null){
82
            // remember the persisted state before starting to operate on the DTO
83
            persistedBasionyms = basionyms;
84
        }
85
        return basionyms;
86
    }
87

    
88
    public void setBasionyms(Set<TaxonName> basionyms) {
89
        setRelatedNames(Direction.relatedTo, NameRelationshipType.BASIONYM(), basionyms);
90
    }
91

    
92
    /**
93
     * @param basionyms
94
     * @param relType
95
     * @param direction
96
     */
97
    protected void setRelatedNames(Direction direction, NameRelationshipType relType, Set<TaxonName> relatedNames) {
98
        Set<TaxonName> currentRelatedNames = new HashSet<>();
99
        Set<TaxonName> namesSeen = new HashSet<>();
100

    
101
        for(TaxonName tn : name.getRelatedNames(direction, relType)){
102
            currentRelatedNames.add(tn);
103
        }
104
        for(TaxonName tn : relatedNames){
105
            if(!currentRelatedNames.contains(tn)){
106
                if(direction.equals(Direction.relatedTo)){
107
                    tn.addRelationshipToName(name, relType, null);
108
                } else {
109
                    tn.addRelationshipFromName(name, relType, null);
110
                }
111
            }
112
            namesSeen.add(tn);
113
        }
114
        for(TaxonName tn : currentRelatedNames){
115
            if(!namesSeen.contains(tn)){
116
                name.removeRelationWithTaxonName(tn, direction, relType);
117
            }
118
        }
119
    }
120

    
121
    public Set<TaxonName> persistedBasionyms(){
122
        return persistedBasionyms;
123
    }
124

    
125
    public TeamOrPersonBase<?> getCombinationAuthorship() {
126
        return name.getCombinationAuthorship();
127
    }
128

    
129
    public List<Credit> getCredits() {
130
        return name.getCredits();
131
    }
132

    
133
    public String getCultivarName() {
134
        return name.getCultivarName();
135
    }
136

    
137
    public TeamOrPersonBase<?> getExBasionymAuthorship() {
138
        return name.getExBasionymAuthorship();
139
    }
140

    
141
    public TeamOrPersonBase<?> getExCombinationAuthorship() {
142
        return name.getExCombinationAuthorship();
143
    }
144

    
145
    public Set<Extension> getExtensions() {
146
        return name.getExtensions();
147
    }
148

    
149
    public String getFullTitleCache() {
150
        return name.getFullTitleCache();
151
    }
152

    
153
    public String getGenusOrUninomial() {
154
        return name.getGenusOrUninomial();
155
    }
156

    
157
    public HomotypicalGroup getHomotypicalGroup() {
158
        return name.getHomotypicalGroup();
159
    }
160

    
161
    public List<Identifier> getIdentifiers() {
162
        return name.getIdentifiers();
163
    }
164

    
165
    public String getInfraGenericEpithet() {
166
        return name.getInfraGenericEpithet();
167
    }
168

    
169
    public String getInfraSpecificEpithet() {
170
        return name.getInfraSpecificEpithet();
171
    }
172

    
173
    public String getSpecificEpithet() {
174
        return name.getSpecificEpithet();
175
    }
176

    
177
    public String getNameCache() {
178
        return name.getNameCache();
179
    }
180

    
181
    public String getNomenclaturalMicroReference() {
182
        return name.getNomenclaturalMicroReference();
183
    }
184

    
185
    public INomenclaturalReference getNomenclaturalReference() {
186
        return name.getNomenclaturalReference();
187
    }
188

    
189
    public Rank getRank() {
190
        return name.getRank();
191
    }
192

    
193
    public Set<NomenclaturalStatus> getStatus() {
194
        return name.getStatus();
195
    }
196

    
197
    public boolean isProtectedAuthorshipCache() {
198
        return name.isProtectedAuthorshipCache();
199
    }
200

    
201
    public boolean isProtectedFullTitleCache() {
202
        return name.isProtectedFullTitleCache();
203
    }
204

    
205
    public boolean isProtectedNameCache() {
206
        return name.isProtectedNameCache();
207
    }
208

    
209
    public boolean isProtectedTitleCache() {
210
        return name.isProtectedTitleCache();
211
    }
212

    
213
    public void setAcronym(String acronym) {
214
        name.setAcronym(acronym);
215
    }
216

    
217
    public void setAppendedPhrase(String appendedPhrase) {
218
        name.setAppendedPhrase(appendedPhrase);
219
    }
220

    
221
    public void setBasionymAuthorship(TeamOrPersonBase<?> basionymAuthorship) {
222
        name.setBasionymAuthorship(basionymAuthorship);
223
    }
224

    
225
    public void setBinomHybrid(boolean binomHybrid) {
226
        name.setBinomHybrid(binomHybrid);
227
    }
228

    
229
    public void setBreed(String breed) {
230
        name.setBreed(breed);
231
    }
232

    
233
    public void setCombinationAuthorship(TeamOrPersonBase<?> combinationAuthorship) {
234
        name.setCombinationAuthorship(combinationAuthorship);
235
    }
236

    
237
    public void setCultivarName(String cultivarName) {
238
        name.setCultivarName(cultivarName);
239
    }
240

    
241
    public void setExBasionymAuthorship(TeamOrPersonBase<?> exBasionymAuthorship) {
242
        name.setExBasionymAuthorship(exBasionymAuthorship);
243
    }
244

    
245
    public void setExCombinationAuthorship(TeamOrPersonBase<?> exCombinationAuthorship) {
246
        name.setExCombinationAuthorship(exCombinationAuthorship);
247
    }
248

    
249
    public void setFullTitleCache(String fullTitleCache) {
250
        name.setFullTitleCache(fullTitleCache);
251
    }
252

    
253
    public void setGenusOrUninomial(String genusOrUninomial) {
254
        name.setGenusOrUninomial(genusOrUninomial);
255
    }
256

    
257
    public void setHybridFormula(boolean hybridFormula) {
258
        name.setHybridFormula(hybridFormula);
259
    }
260

    
261
    public void setInfraGenericEpithet(String infraGenericEpithet) {
262
        name.setInfraGenericEpithet(infraGenericEpithet);
263
    }
264

    
265
    public void setInfraSpecificEpithet(String infraSpecificEpithet) {
266
        name.setInfraSpecificEpithet(infraSpecificEpithet);
267
    }
268

    
269
    public void setMonomHybrid(boolean monomHybrid) {
270
        name.setMonomHybrid(monomHybrid);
271
    }
272

    
273
    public void setNameApprobation(String nameApprobation) {
274
        name.setNameApprobation(nameApprobation);
275
    }
276

    
277
    public void setNameCache(String nameCache) {
278
        name.setNameCache(nameCache);
279
    }
280

    
281
    public void setNameType(NomenclaturalCode nameType) {
282
        name.setNameType(nameType);
283
    }
284

    
285
    public void setNomenclaturalMicroReference(String nomenclaturalMicroReference) {
286
        name.setNomenclaturalMicroReference(nomenclaturalMicroReference);
287
    }
288

    
289
    public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference) {
290
        name.setNomenclaturalReference(nomenclaturalReference);
291
    }
292

    
293
    public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache) {
294
        name.setProtectedAuthorshipCache(protectedAuthorshipCache);
295
    }
296

    
297
    public void setProtectedFullTitleCache(boolean protectedFullTitleCache) {
298
        name.setProtectedFullTitleCache(protectedFullTitleCache);
299
    }
300

    
301
    public void setProtectedNameCache(boolean protectedNameCache) {
302
        name.setProtectedNameCache(protectedNameCache);
303
    }
304

    
305
    public void setProtectedTitleCache(boolean protectedTitleCache) {
306
        name.setProtectedTitleCache(protectedTitleCache);
307
    }
308

    
309
    public void setRank(Rank rank) {
310
        name.setRank(rank);
311
    }
312

    
313
    public void setSpecificEpithet(String specificEpithet) {
314
        name.setSpecificEpithet(specificEpithet);
315
    }
316

    
317
    public void setTitleCache(String titleCache) {
318
        name.setTitleCache(titleCache);
319
    }
320

    
321
    public void setTrinomHybrid(boolean trinomHybrid) {
322
        name.setTrinomHybrid(trinomHybrid);
323
    }
324

    
325
    public void setUpdated(DateTime updated) {
326
        name.setUpdated(updated);
327
    }
328

    
329
    public void setUpdatedBy(User updatedBy) {
330
        name.setUpdatedBy(updatedBy);
331
    }
332

    
333
}
    (1-1/1)