Project

General

Profile

Download (8.7 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
    /**
49
     * @param entity
50
     */
51
    public TaxonNameDTO(TaxonName entity) {
52
        super(entity);
53
        name = entity;
54
    }
55

    
56
    public String getAcronym() {
57
        return name.getAcronym();
58
    }
59

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

    
64
    public String getAppendedPhrase() {
65
        return name.getAppendedPhrase();
66
    }
67

    
68
    public String getAuthorshipCache() {
69

    
70
        return name.getAuthorshipCache();
71
    }
72

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

    
77
    public Set<TaxonName> getBasionyms() {
78
        return name.getRelatedNames(Direction.relatedTo, NameRelationshipType.BASIONYM());
79
    }
80

    
81
    public void setBasionyms(Set<TaxonName> basionyms) {
82
        setRelatedTaxa(Direction.relatedTo, NameRelationshipType.BASIONYM(), basionyms);
83
    }
84

    
85
    /**
86
     * @param basionyms
87
     * @param relType
88
     * @param direction
89
     */
90
    protected void setRelatedTaxa(Direction direction, NameRelationshipType relType, Set<TaxonName> basionyms) {
91
        Set<TaxonName> currentBasionyms = new HashSet<>();
92
        Set<TaxonName> basionymsSeen = new HashSet<>();
93

    
94
        for(TaxonName tn : name.getRelatedNames(direction, relType)){
95
            currentBasionyms.add(tn);
96
        }
97
        for(TaxonName tn : basionyms){
98
            if(!currentBasionyms.contains(tn)){
99
                name.addBasionym(tn);
100
            }
101
            basionymsSeen.add(tn);
102
        }
103
        for(TaxonName tn : currentBasionyms){
104
            if(!basionymsSeen.contains(tn)){
105
                name.removeRelationWithTaxonName(tn, direction, relType);
106
            }
107
        }
108
    }
109

    
110
    public TeamOrPersonBase<?> getCombinationAuthorship() {
111
        return name.getCombinationAuthorship();
112
    }
113

    
114
    public List<Credit> getCredits() {
115
        return name.getCredits();
116
    }
117

    
118
    public String getCultivarName() {
119
        return name.getCultivarName();
120
    }
121

    
122
    public TeamOrPersonBase<?> getExBasionymAuthorship() {
123
        return name.getExBasionymAuthorship();
124
    }
125

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

    
130
    public Set<Extension> getExtensions() {
131
        return name.getExtensions();
132
    }
133

    
134
    public String getFullTitleCache() {
135
        return name.getFullTitleCache();
136
    }
137

    
138
    public String getGenusOrUninomial() {
139
        return name.getGenusOrUninomial();
140
    }
141

    
142
    public HomotypicalGroup getHomotypicalGroup() {
143
        return name.getHomotypicalGroup();
144
    }
145

    
146
    public List<Identifier> getIdentifiers() {
147
        return name.getIdentifiers();
148
    }
149

    
150
    public String getInfraGenericEpithet() {
151
        return name.getInfraGenericEpithet();
152
    }
153

    
154
    public String getInfraSpecificEpithet() {
155
        return name.getInfraSpecificEpithet();
156
    }
157

    
158
    public String getSpecificEpithet() {
159
        return name.getSpecificEpithet();
160
    }
161

    
162
    public String getNameCache() {
163
        return name.getNameCache();
164
    }
165

    
166
    public String getNomenclaturalMicroReference() {
167
        return name.getNomenclaturalMicroReference();
168
    }
169

    
170
    public INomenclaturalReference getNomenclaturalReference() {
171
        return name.getNomenclaturalReference();
172
    }
173

    
174
    public Rank getRank() {
175
        return name.getRank();
176
    }
177

    
178
    public Set<NomenclaturalStatus> getStatus() {
179
        return name.getStatus();
180
    }
181

    
182
    public boolean isProtectedAuthorshipCache() {
183
        return name.isProtectedAuthorshipCache();
184
    }
185

    
186
    public boolean isProtectedFullTitleCache() {
187
        return name.isProtectedFullTitleCache();
188
    }
189

    
190
    public boolean isProtectedNameCache() {
191
        return name.isProtectedNameCache();
192
    }
193

    
194
    public boolean isProtectedTitleCache() {
195
        return name.isProtectedTitleCache();
196
    }
197

    
198
    public void setAcronym(String acronym) {
199
        name.setAcronym(acronym);
200
    }
201

    
202
    public void setAppendedPhrase(String appendedPhrase) {
203
        name.setAppendedPhrase(appendedPhrase);
204
    }
205

    
206
    public void setBasionymAuthorship(TeamOrPersonBase<?> basionymAuthorship) {
207
        name.setBasionymAuthorship(basionymAuthorship);
208
    }
209

    
210
    public void setBinomHybrid(boolean binomHybrid) {
211
        name.setBinomHybrid(binomHybrid);
212
    }
213

    
214
    public void setBreed(String breed) {
215
        name.setBreed(breed);
216
    }
217

    
218
    public void setCombinationAuthorship(TeamOrPersonBase<?> combinationAuthorship) {
219
        name.setCombinationAuthorship(combinationAuthorship);
220
    }
221

    
222
    public void setCultivarName(String cultivarName) {
223
        name.setCultivarName(cultivarName);
224
    }
225

    
226
    public void setExBasionymAuthorship(TeamOrPersonBase<?> exBasionymAuthorship) {
227
        name.setExBasionymAuthorship(exBasionymAuthorship);
228
    }
229

    
230
    public void setExCombinationAuthorship(TeamOrPersonBase<?> exCombinationAuthorship) {
231
        name.setExCombinationAuthorship(exCombinationAuthorship);
232
    }
233

    
234
    public void setFullTitleCache(String fullTitleCache) {
235
        name.setFullTitleCache(fullTitleCache);
236
    }
237

    
238
    public void setGenusOrUninomial(String genusOrUninomial) {
239
        name.setGenusOrUninomial(genusOrUninomial);
240
    }
241

    
242
    public void setHybridFormula(boolean hybridFormula) {
243
        name.setHybridFormula(hybridFormula);
244
    }
245

    
246
    public void setInfraGenericEpithet(String infraGenericEpithet) {
247
        name.setInfraGenericEpithet(infraGenericEpithet);
248
    }
249

    
250
    public void setInfraSpecificEpithet(String infraSpecificEpithet) {
251
        name.setInfraSpecificEpithet(infraSpecificEpithet);
252
    }
253

    
254
    public void setMonomHybrid(boolean monomHybrid) {
255
        name.setMonomHybrid(monomHybrid);
256
    }
257

    
258
    public void setNameApprobation(String nameApprobation) {
259
        name.setNameApprobation(nameApprobation);
260
    }
261

    
262
    public void setNameCache(String nameCache) {
263
        name.setNameCache(nameCache);
264
    }
265

    
266
    public void setNameType(NomenclaturalCode nameType) {
267
        name.setNameType(nameType);
268
    }
269

    
270
    public void setNomenclaturalMicroReference(String nomenclaturalMicroReference) {
271
        name.setNomenclaturalMicroReference(nomenclaturalMicroReference);
272
    }
273

    
274
    public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference) {
275
        name.setNomenclaturalReference(nomenclaturalReference);
276
    }
277

    
278
    public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache) {
279
        name.setProtectedAuthorshipCache(protectedAuthorshipCache);
280
    }
281

    
282
    public void setProtectedFullTitleCache(boolean protectedFullTitleCache) {
283
        name.setProtectedFullTitleCache(protectedFullTitleCache);
284
    }
285

    
286
    public void setProtectedNameCache(boolean protectedNameCache) {
287
        name.setProtectedNameCache(protectedNameCache);
288
    }
289

    
290
    public void setProtectedTitleCache(boolean protectedTitleCache) {
291
        name.setProtectedTitleCache(protectedTitleCache);
292
    }
293

    
294
    public void setRank(Rank rank) {
295
        name.setRank(rank);
296
    }
297

    
298
    public void setSpecificEpithet(String specificEpithet) {
299
        name.setSpecificEpithet(specificEpithet);
300
    }
301

    
302
    public void setTitleCache(String titleCache) {
303
        name.setTitleCache(titleCache);
304
    }
305

    
306
    public void setTrinomHybrid(boolean trinomHybrid) {
307
        name.setTrinomHybrid(trinomHybrid);
308
    }
309

    
310
    public void setUpdated(DateTime updated) {
311
        name.setUpdated(updated);
312
    }
313

    
314
    public void setUpdatedBy(User updatedBy) {
315
        name.setUpdatedBy(updatedBy);
316
    }
317

    
318
}
    (1-1/1)