ref #10322 add wfoIdentifier to webservice
[cdmlib.git] / cdmlib-api / src / main / java / eu / etaxonomy / cdm / api / dto / portal / TaxonBaseDto.java
1 /**
2 * Copyright (C) 2023 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.api.dto.portal;
10
11 import java.beans.Transient;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.UUID;
15
16 import eu.etaxonomy.cdm.api.dto.portal.TaxonPageDto.NameRelationDTO;
17 import eu.etaxonomy.cdm.api.dto.portal.TaxonPageDto.NomenclaturalStatusDTO;
18 import eu.etaxonomy.cdm.common.URI;
19 import eu.etaxonomy.cdm.strategy.cache.TaggedText;
20
21 /**
22 * @author a.mueller
23 * @date 07.01.2023
24 */
25 public class TaxonBaseDto extends IdentifiableDto {
26
27 public class TaxonNameDto extends IdentifiableDto {
28
29 //nomenclatural code
30 private String nameType;
31
32 private ContainerDto<NomenclaturalStatusDTO> status;
33
34 private ContainerDto<NameRelationDTO> relatedNames;
35
36 private List<URI> protologues;
37
38 private ContainerDto<FeatureDto> nameFacts;
39
40 //TODO maybe later this can be combined with taggedLabel (merge taxon and name taggedText)
41 private List<TaggedText> taggedName;
42
43 private boolean hasRegistration;
44
45 private boolean isInvalid;
46
47 //*********** GETTER / SETTER *******************/
48
49 public List<TaggedText> getTaggedName() {
50 return taggedName;
51 }
52 public void setTaggedName(List<TaggedText> taggedName) {
53 this.taggedName = taggedName;
54 }
55
56 public ContainerDto<FeatureDto> getNameFacts() {
57 return nameFacts;
58 }
59 public void setNameFacts(ContainerDto<FeatureDto> nameFacts) {
60 this.nameFacts = nameFacts;
61 }
62
63 public List<URI> getProtologues() {
64 return protologues;
65 }
66 public void addProtologue(URI uri) {
67 if (protologues == null) {
68 protologues = new ArrayList<>();
69 }
70 protologues.add(uri);
71 }
72
73 public ContainerDto<NameRelationDTO> getRelatedNames() {
74 return relatedNames;
75 }
76 public void addRelatedName(NameRelationDTO relatedName) {
77 if (this.relatedNames == null) {
78 this.relatedNames = new ContainerDto<>();
79 }
80 this.relatedNames.addItem(relatedName);
81 }
82 //TODO either set or add
83 public void setRelatedNames(ContainerDto<NameRelationDTO> relatedNames) {
84 this.relatedNames = relatedNames;
85 }
86
87
88 public ContainerDto<NomenclaturalStatusDTO> getStatus(){
89 return status;
90 }
91 public void addStatus(NomenclaturalStatusDTO nomenclaturalStatus) {
92 if (this.status == null) {
93 this.status = new ContainerDto<>();
94 }
95 this.status.addItem(nomenclaturalStatus);
96 }
97 //TODO either set or add
98 public void setStatus(ContainerDto<NomenclaturalStatusDTO> nomenclaturalStatuss) {
99 this.status = nomenclaturalStatuss;
100 }
101
102 public String getType() {
103 return nameType;
104 }
105 public void setType(String nameType) {
106 this.nameType = nameType;
107 }
108
109 public boolean isInvalid() {
110 return isInvalid;
111 }
112 public void setInvalid(boolean isInvalid) {
113 this.isInvalid = isInvalid;
114 }
115
116 public boolean isHasRegistration() {
117 return hasRegistration;
118 }
119 public void setHasRegistration(boolean hasRegistration) {
120 this.hasRegistration = hasRegistration;
121 }
122 }
123
124 private TaxonNameDto name;
125
126 //TODO should we distinguish data parts (e.g. on general page we do not need last updates from synonymy)
127 //lastUpdated
128
129
130 //TODO should we keep formatting client side or should we do formatting on server side? Formatting means: filter, italics, order??
131 // private List<TypedLabel> typedTaxonLabel;
132 // private List<TypedLabel> typedNameLabel;
133
134 private List<TaggedText> taggedLabel;
135
136 public String getNameLabel() {
137 return getName().getLabel();
138 }
139 public void setNameLabel(String nameLabel) {
140 getName().setLabel(nameLabel);
141 }
142
143 public UUID getNameUuid() {
144 return getName().getUuid();
145 }
146 public void setNameUuid(UUID nameUuid) {
147 getName().setUuid(nameUuid);
148 }
149
150 public String getNameType() {
151 return getName().getType();
152 }
153 public void setNameType(String nameType) {
154 getName().setType(nameType);
155 }
156
157 public List<TaggedText> getTaggedLabel() {
158 return taggedLabel;
159 }
160 public void setTaggedLabel(List<TaggedText> taggedLabel) {
161 this.taggedLabel = taggedLabel;
162 }
163
164 public List<TaggedText> getTaggedName() {
165 return getName().getTaggedName();
166 }
167 public void setTaggedName(List<TaggedText> taggedName) {
168 getName().setTaggedName(taggedName);
169 }
170
171 public ContainerDto<NameRelationDTO> getRelatedNames() {
172 return getName().getRelatedNames();
173 }
174 public void addRelatedName(NameRelationDTO relatedName) {
175 getName().addRelatedName(relatedName);
176 }
177 //TODO either set or add
178 public void setRelatedNames(ContainerDto<NameRelationDTO> relatedNames) {
179 getName().setRelatedNames(relatedNames);
180 }
181
182 public ContainerDto<NomenclaturalStatusDTO> getNomenclaturalStatus() {
183 return getName().getStatus();
184 }
185 public void addNomenclaturalStatus(NomenclaturalStatusDTO status) {
186 getName().addStatus(status);
187 }
188 //TODO either set or add
189 public void setNomenclaturalStatus(ContainerDto<NomenclaturalStatusDTO> status) {
190 getName().setStatus(status);
191 }
192
193 public ContainerDto<FeatureDto> getNameFacts() {
194 return getName().getNameFacts();
195 }
196 public void setNameFacts(ContainerDto<FeatureDto> nameFacts) {
197 getName().setNameFacts(nameFacts);
198 }
199
200 public boolean isInvalid() {
201 return getName().isInvalid();
202 }
203
204 public boolean isHasRegistration() {
205 return getName().isHasRegistration();
206 }
207
208 //protologues
209
210 public List<URI> getProtologues() {
211 return getName().getProtologues();
212 }
213 public void addProtologue(URI uri) {
214 getName().addProtologue(uri);
215 }
216
217 //TODO we shouldn't have @transient on a DTO, try to solve this in a better way
218 @Transient
219 @javax.persistence.Transient
220 public TaxonNameDto getName() {
221 if (name == null) {
222 name = new TaxonNameDto();
223 }
224 return name;
225 }
226 public void setName(TaxonNameDto name) {
227 this.name = name;
228 }
229
230 @Override
231 public ContainerDto<IdentifierDto> getIdentifiers() {
232 //TODO we also need to support taxon identifiers
233 return getName().getIdentifiers();
234 }
235
236 //TaxonBase info
237 //appendedPhras, useNameCache, doubtful, name, publish
238 // => should all be part of the typedLabel
239
240 //secsource ?? how to handle? part of bibliography
241
242 //TaxonName info
243 //rank, nameparts => all in typedLabel
244
245 //types ?? => Teil der homotypischen Gruppe, außer der Fall von Walter (für name types?)
246
247 }