37aca87820d4bb150cbdad23493d813ab0b04569
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / dto / DerivateHierarchyDTO.java
1 package eu.etaxonomy.cdm.api.service.dto;
2
3 import java.net.URI;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.List;
7 import java.util.Map;
8
9 import org.hibernate.envers.tools.Pair;
10
11 public class DerivateHierarchyDTO {
12
13 //Filter Flags
14 private boolean hasDna;
15 private boolean hasDetailImage;
16
17 //Row Attributes
18 private String country;
19 private String collection;
20 private String date;
21 private String herbarium;
22 private boolean hasType;
23 private boolean hasSpecimenScan;
24
25 //Detail pop-down
26 private String taxonName;
27 private String protologue;
28 private String citation;
29 private Map<String, List<String>> types;
30 private List<Pair<String, String>> specimenScans;
31 private List<MolecularData> molecularDataList;
32 private List<Pair<String, String>> detailImages;
33
34 /**
35 * @return the molecularData
36 */
37 public List<MolecularData> getMolecularDataList() {
38 return molecularDataList;
39 }
40
41 public MolecularData addProviderLink(URI uri, String linkText) {
42 if(this.molecularDataList==null){
43 molecularDataList = new ArrayList<DerivateHierarchyDTO.MolecularData>();
44 }
45 MolecularData molecularData = new MolecularData(new Link(uri, linkText));
46 this.molecularDataList.add(molecularData);
47 return molecularData;
48 }
49
50 /**
51 * @return the hasDna
52 */
53 public boolean isHasDna() {
54 return hasDna;
55 }
56 /**
57 * @param hasDna the hasDna to set
58 */
59 public void setHasDna(boolean hasDna) {
60 this.hasDna = hasDna;
61 }
62 /**
63 * @return the hasDetailImage
64 */
65 public boolean isHasDetailImage() {
66 return hasDetailImage;
67 }
68 /**
69 * @param hasDetailImage the hasDetailImage to set
70 */
71 public void setHasDetailImage(boolean hasDetailImage) {
72 this.hasDetailImage = hasDetailImage;
73 }
74 /**
75 * @return the country
76 */
77 public String getCountry() {
78 return country;
79 }
80 /**
81 * @param country the country to set
82 */
83 public void setCountry(String country) {
84 this.country = country;
85 }
86 /**
87 * @return the collection
88 */
89 public String getCollection() {
90 return collection;
91 }
92 /**
93 * @param collection the collection to set
94 */
95 public void setCollection(String collection) {
96 this.collection = collection;
97 }
98 /**
99 * @return the date
100 */
101 public String getDate() {
102 return date;
103 }
104 /**
105 * @param date the date to set
106 */
107 public void setDate(String date) {
108 this.date = date;
109 }
110 /**
111 * @return the herbarium
112 */
113 public String getHerbarium() {
114 return herbarium;
115 }
116 /**
117 * @param herbarium the herbarium to set
118 */
119 public void setHerbarium(String herbarium) {
120 this.herbarium = herbarium;
121 }
122 /**
123 * @return the hasType
124 */
125 public boolean isHasType() {
126 return hasType;
127 }
128 /**
129 * @param hasType the hasType to set
130 */
131 public void setHasType(boolean hasType) {
132 this.hasType = hasType;
133 }
134 /**
135 * @return the hasSpecimenScan
136 */
137 public boolean isHasSpecimenScan() {
138 return hasSpecimenScan;
139 }
140 /**
141 * @param hasSpecimenScan the hasSpecimenScan to set
142 */
143 public void setHasSpecimenScan(boolean hasSpecimenScan) {
144 this.hasSpecimenScan = hasSpecimenScan;
145 }
146 /**
147 * @return the taxonName
148 */
149 public String getTaxonName() {
150 return taxonName;
151 }
152 /**
153 * @param taxonName the taxonName to set
154 */
155 public void setTaxonName(String taxonName) {
156 this.taxonName = taxonName;
157 }
158 /**
159 * @return the protologue
160 */
161 public String getProtologue() {
162 return protologue;
163 }
164 /**
165 * @param protologue the protologue to set
166 */
167 public void setProtologue(String protologue) {
168 this.protologue = protologue;
169 }
170 /**
171 * @return the citation
172 */
173 public String getCitation() {
174 return citation;
175 }
176 /**
177 * @param citation the citation to set
178 */
179 public void setCitation(String citation) {
180 this.citation = citation;
181 }
182
183 /**
184 * @param types the types to set
185 */
186 public void setTypes(Map<String, List<String>> types) {
187 this.types = types;
188 }
189 /**
190 * @return the types
191 */
192 public Map<String, List<String>> getTypes() {
193 return types;
194 }
195 public void addTypes(String typeStatus, String accessionNumber){
196 if(types==null){
197 types = new HashMap<String, List<String>>();
198 }
199 List<String> list = types.get(typeStatus);
200 if(list==null){
201 list = new ArrayList<String>();
202 }
203 list.add(accessionNumber);
204 types.put(typeStatus, list);
205 }
206
207 /**
208 * @param specimenScans the specimenScans to set
209 */
210 public void setSpecimenScans(List<Pair<String, String>> specimenScans) {
211 this.specimenScans = specimenScans;
212 }
213 /**
214 * @return the specimenScans
215 */
216 public List<Pair<String, String>> getSpecimenScans() {
217 return specimenScans;
218 }
219
220 public void addSpecimenScan(String uri, String herbarium){
221 if(specimenScans==null){
222 specimenScans = new ArrayList<Pair<String,String>>();
223 }
224 specimenScans.add(new Pair<String, String>(uri, herbarium));
225 }
226
227 /**
228 * @return the detailImages
229 */
230 public List<Pair<String, String>> getDetailImages() {
231 return detailImages;
232 }
233 /**
234 * @param detailImages the detailImages to set
235 */
236 public void setDetailImages(List<Pair<String, String>> detailImages) {
237 this.detailImages = detailImages;
238 }
239
240 public void addDetailImage(String uri, String motif){
241 if(detailImages==null){
242 detailImages = new ArrayList<Pair<String,String>>();
243 }
244 detailImages.add(new Pair<String, String>(uri, motif));
245 }
246
247 public class MolecularData{
248 private final Link providerLink;
249 private List<ContigFile> contigFiles;
250
251 public MolecularData(Link providerLink) {
252 super();
253 this.providerLink = providerLink;
254 }
255
256 public ContigFile addContigFile(URI uri, String linkText){
257 if(contigFiles==null){
258 contigFiles = new ArrayList<DerivateHierarchyDTO.ContigFile>();
259 }
260 ContigFile contigFile = new ContigFile(new Link(uri, linkText));
261 contigFiles.add(contigFile);
262 return contigFile;
263 }
264
265 public synchronized Link getProviderLink() {
266 return providerLink;
267 }
268
269 public List<ContigFile> getContigFiles() {
270 return contigFiles;
271 }
272
273 }
274
275 public class ContigFile{
276 private final Link contigLink;
277 private List<Link> primerLinks;
278
279 public ContigFile(Link contigLink) {
280 this.contigLink = contigLink;
281 }
282
283 public void addPrimerLink(URI uri, String linkText){
284 if(primerLinks==null){
285 primerLinks = new ArrayList<DerivateHierarchyDTO.Link>();
286 }
287 primerLinks.add(new Link(uri, linkText));
288 }
289
290 public Link getContigLink() {
291 return contigLink;
292 }
293
294 public List<Link> getPrimerLinks() {
295 return primerLinks;
296 }
297
298 }
299
300 public class Link{
301 private String linkText;
302 private URI uri;
303
304 public Link(URI uri, String linkText) {
305 super();
306 this.linkText = linkText;
307 this.uri = uri;
308 }
309 /**
310 * @return the linkText
311 */
312 public synchronized String getLinkText() {
313 return linkText;
314 }
315 /**
316 * @param linkText the linkText to set
317 */
318 public synchronized void setLinkText(String linkText) {
319 this.linkText = linkText;
320 }
321 /**
322 * @return the uri
323 */
324 public synchronized URI getUri() {
325 return uri;
326 }
327 /**
328 * @param uri the uri to set
329 */
330 public synchronized void setUri(URI uri) {
331 this.uri = uri;
332 }
333 /* (non-Javadoc)
334 * @see java.lang.Object#hashCode()
335 */
336 @Override
337 public int hashCode() {
338 final int prime = 31;
339 int result = 1;
340 result = prime * result + ((linkText == null) ? 0 : linkText.hashCode());
341 result = prime * result + ((uri == null) ? 0 : uri.hashCode());
342 return result;
343 }
344 /* (non-Javadoc)
345 * @see java.lang.Object#equals(java.lang.Object)
346 */
347 @Override
348 public boolean equals(Object obj) {
349 if (this == obj) {
350 return true;
351 }
352 if (obj == null) {
353 return false;
354 }
355 if (getClass() != obj.getClass()) {
356 return false;
357 }
358 Link other = (Link) obj;
359 if (linkText == null) {
360 if (other.linkText != null) {
361 return false;
362 }
363 } else if (!linkText.equals(other.linkText)) {
364 return false;
365 }
366 if (uri == null) {
367 if (other.uri != null) {
368 return false;
369 }
370 } else if (!uri.equals(other.uri)) {
371 return false;
372 }
373 return true;
374 }
375 }
376
377 }