2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.vaadin
.model
.name
;
11 import java
.util
.HashSet
;
12 import java
.util
.List
;
15 import org
.joda
.time
.DateTime
;
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
;
34 * @author a.kohlbecker
38 public class TaxonNameDTO
extends CdmEntityDecoraterDTO
<TaxonName
> {
40 class TN
extends TaxonName
{
44 private static final long serialVersionUID
= -8018109905949198530L;
46 private TaxonName name
;
48 private Set
<TaxonName
> persistedBasionyms
;
50 private Set
<TaxonName
> persistedReplacedSynonyms
;
55 public TaxonNameDTO(TaxonName entity
) {
60 public String
getAcronym() {
61 return name
.getAcronym();
64 public Set
<Annotation
> getAnnotations() {
65 return name
.getAnnotations();
68 public String
getAppendedPhrase() {
69 return name
.getAppendedPhrase();
72 public String
getAuthorshipCache() {
74 return name
.getAuthorshipCache();
77 public TeamOrPersonBase
<?
> getBasionymAuthorship() {
78 return name
.getBasionymAuthorship();
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
;
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
;
96 return replacedSynonyms
;
99 public void setBasionyms(Set
<TaxonName
> basionyms
) {
100 setRelatedNames(Direction
.relatedTo
, NameRelationshipType
.BASIONYM(), basionyms
);
103 public void setReplacedSynonyms(Set
<TaxonName
> replacedSynonyms
) {
104 setRelatedNames(Direction
.relatedTo
, NameRelationshipType
.REPLACED_SYNONYM(), replacedSynonyms
);
112 protected void setRelatedNames(Direction direction
, NameRelationshipType relType
, Set
<TaxonName
> relatedNames
) {
113 Set
<TaxonName
> currentRelatedNames
= new HashSet
<>();
114 Set
<TaxonName
> namesSeen
= new HashSet
<>();
116 for(TaxonName tn
: name
.getRelatedNames(direction
, relType
)){
117 currentRelatedNames
.add(tn
);
119 for(TaxonName tn
: relatedNames
){
123 if(!currentRelatedNames
.contains(tn
)){
124 if(direction
.equals(Direction
.relatedTo
)){
125 tn
.addRelationshipToName(name
, relType
, null);
127 tn
.addRelationshipFromName(name
, relType
, null);
132 for(TaxonName tn
: currentRelatedNames
){
133 if(!namesSeen
.contains(tn
)){
134 name
.removeRelationWithTaxonName(tn
, direction
, relType
);
139 public Set
<TaxonName
> persistedBasionyms(){
140 return persistedBasionyms
;
143 public TeamOrPersonBase
<?
> getCombinationAuthorship() {
144 return name
.getCombinationAuthorship();
147 public List
<Credit
> getCredits() {
148 return name
.getCredits();
151 public String
getCultivarName() {
152 return name
.getCultivarName();
155 public TeamOrPersonBase
<?
> getExBasionymAuthorship() {
156 return name
.getExBasionymAuthorship();
159 public TeamOrPersonBase
<?
> getExCombinationAuthorship() {
160 return name
.getExCombinationAuthorship();
163 public Set
<Extension
> getExtensions() {
164 return name
.getExtensions();
167 public String
getFullTitleCache() {
168 return name
.getFullTitleCache();
171 public String
getGenusOrUninomial() {
172 return name
.getGenusOrUninomial();
175 public HomotypicalGroup
getHomotypicalGroup() {
176 return name
.getHomotypicalGroup();
179 public List
<Identifier
> getIdentifiers() {
180 return name
.getIdentifiers();
183 public String
getInfraGenericEpithet() {
184 return name
.getInfraGenericEpithet();
187 public String
getInfraSpecificEpithet() {
188 return name
.getInfraSpecificEpithet();
191 public String
getSpecificEpithet() {
192 return name
.getSpecificEpithet();
195 public String
getNameCache() {
196 return name
.getNameCache();
199 public String
getNomenclaturalMicroReference() {
200 return name
.getNomenclaturalMicroReference();
203 public INomenclaturalReference
getNomenclaturalReference() {
204 return name
.getNomenclaturalReference();
207 public Rank
getRank() {
208 return name
.getRank();
211 public Set
<NomenclaturalStatus
> getStatus() {
212 return name
.getStatus();
215 public boolean isProtectedAuthorshipCache() {
216 return name
.isProtectedAuthorshipCache();
219 public boolean isProtectedFullTitleCache() {
220 return name
.isProtectedFullTitleCache();
223 public boolean isProtectedNameCache() {
224 return name
.isProtectedNameCache();
227 public boolean isProtectedTitleCache() {
228 return name
.isProtectedTitleCache();
231 public void setAcronym(String acronym
) {
232 name
.setAcronym(acronym
);
235 public void setAppendedPhrase(String appendedPhrase
) {
236 name
.setAppendedPhrase(appendedPhrase
);
239 public void setBasionymAuthorship(TeamOrPersonBase
<?
> basionymAuthorship
) {
240 name
.setBasionymAuthorship(basionymAuthorship
);
243 public void setBinomHybrid(boolean binomHybrid
) {
244 name
.setBinomHybrid(binomHybrid
);
247 public void setBreed(String breed
) {
248 name
.setBreed(breed
);
251 public void setCombinationAuthorship(TeamOrPersonBase
<?
> combinationAuthorship
) {
252 name
.setCombinationAuthorship(combinationAuthorship
);
255 public void setCultivarName(String cultivarName
) {
256 name
.setCultivarName(cultivarName
);
259 public void setExBasionymAuthorship(TeamOrPersonBase
<?
> exBasionymAuthorship
) {
260 name
.setExBasionymAuthorship(exBasionymAuthorship
);
263 public void setExCombinationAuthorship(TeamOrPersonBase
<?
> exCombinationAuthorship
) {
264 name
.setExCombinationAuthorship(exCombinationAuthorship
);
267 public void setFullTitleCache(String fullTitleCache
) {
268 name
.setFullTitleCache(fullTitleCache
);
271 public void setGenusOrUninomial(String genusOrUninomial
) {
272 name
.setGenusOrUninomial(genusOrUninomial
);
275 public void setHybridFormula(boolean hybridFormula
) {
276 name
.setHybridFormula(hybridFormula
);
279 public void setInfraGenericEpithet(String infraGenericEpithet
) {
280 name
.setInfraGenericEpithet(infraGenericEpithet
);
283 public void setInfraSpecificEpithet(String infraSpecificEpithet
) {
284 name
.setInfraSpecificEpithet(infraSpecificEpithet
);
287 public void setMonomHybrid(boolean monomHybrid
) {
288 name
.setMonomHybrid(monomHybrid
);
291 public void setNameApprobation(String nameApprobation
) {
292 name
.setNameApprobation(nameApprobation
);
295 public void setNameCache(String nameCache
) {
296 name
.setNameCache(nameCache
);
299 public void setNameType(NomenclaturalCode nameType
) {
300 name
.setNameType(nameType
);
303 public void setNomenclaturalMicroReference(String nomenclaturalMicroReference
) {
304 name
.setNomenclaturalMicroReference(nomenclaturalMicroReference
);
307 public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference
) {
308 name
.setNomenclaturalReference(nomenclaturalReference
);
311 public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache
) {
312 name
.setProtectedAuthorshipCache(protectedAuthorshipCache
);
315 public void setProtectedFullTitleCache(boolean protectedFullTitleCache
) {
316 name
.setProtectedFullTitleCache(protectedFullTitleCache
);
319 public void setProtectedNameCache(boolean protectedNameCache
) {
320 name
.setProtectedNameCache(protectedNameCache
);
323 public void setProtectedTitleCache(boolean protectedTitleCache
) {
324 name
.setProtectedTitleCache(protectedTitleCache
);
327 public void setRank(Rank rank
) {
331 public void setSpecificEpithet(String specificEpithet
) {
332 name
.setSpecificEpithet(specificEpithet
);
335 public void setTitleCache(String titleCache
) {
336 name
.setTitleCache(titleCache
);
339 public void setTrinomHybrid(boolean trinomHybrid
) {
340 name
.setTrinomHybrid(trinomHybrid
);
343 public void setUpdated(DateTime updated
) {
344 name
.setUpdated(updated
);
347 public void setUpdatedBy(User updatedBy
) {
348 name
.setUpdatedBy(updatedBy
);