1
|
package eu.etaxonomy.cdm.remote.dto.occurrencecatalogue;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
import java.util.Set;
|
6
|
|
7
|
import org.apache.commons.lang.StringUtils;
|
8
|
import org.apache.log4j.Logger;
|
9
|
|
10
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
|
11
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
12
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
13
|
import eu.etaxonomy.cdm.model.location.Point;
|
14
|
import eu.etaxonomy.cdm.model.media.Rights;
|
15
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
16
|
import eu.etaxonomy.cdm.remote.controller.BaseListController;
|
17
|
import eu.etaxonomy.cdm.remote.dto.common.RemoteResponse;
|
18
|
|
19
|
/**
|
20
|
* The class representing the response from the CDM Remote Web Service API to a single UUID search query.
|
21
|
* All information contained in this class originates from a call to {@link SpecimenOrObservationBase}
|
22
|
* <P>
|
23
|
*
|
24
|
* @author p.kelbert
|
25
|
* @version 1.0
|
26
|
* @created march 10 2014
|
27
|
*/
|
28
|
|
29
|
|
30
|
public class OccurrenceSearch implements RemoteResponse {
|
31
|
|
32
|
private OccurrenceSearchRequest request;
|
33
|
private final List<OccurrenceSearchResponse> response;
|
34
|
|
35
|
public static final Logger logger = Logger.getLogger(BaseListController.class);
|
36
|
|
37
|
public OccurrenceSearch() {
|
38
|
this.response = new ArrayList<OccurrenceSearchResponse>();
|
39
|
}
|
40
|
|
41
|
public void setRequest(String q) {
|
42
|
request = new OccurrenceSearchRequest();
|
43
|
request.setQuery(q);
|
44
|
}
|
45
|
|
46
|
public OccurrenceSearchRequest getRequest() {
|
47
|
return this.request;
|
48
|
}
|
49
|
|
50
|
public class OccurrenceSearchRequest {
|
51
|
private String taxonUuid;
|
52
|
public OccurrenceSearchRequest() {
|
53
|
this.taxonUuid = "";
|
54
|
}
|
55
|
|
56
|
public void setQuery(String q) {
|
57
|
this.taxonUuid = q;
|
58
|
}
|
59
|
|
60
|
public String getQuery() {
|
61
|
return this.taxonUuid;
|
62
|
}
|
63
|
}
|
64
|
|
65
|
public void addToResponse(String acceptedTaxon,
|
66
|
String acceptedTaxonUuid,
|
67
|
DerivedUnitFacade duf) {
|
68
|
|
69
|
OccurrenceSearch.OccurrenceSearchResponse osr =
|
70
|
new OccurrenceSearch.OccurrenceSearchResponse();
|
71
|
|
72
|
osr.setAcceptedTaxon(acceptedTaxon);
|
73
|
osr.setAcceptedTaxonUuid(acceptedTaxonUuid);
|
74
|
|
75
|
if(duf.getCollector() != null) {
|
76
|
osr.setCollector(duf.getCollector().getTitleCache());
|
77
|
}
|
78
|
if(duf.getCollection() != null) {
|
79
|
osr.setCollection(duf.getCollection().getName());
|
80
|
if(duf.getCollection().getInstitute() != null) {
|
81
|
osr.setInstitution(duf.getCollection().getInstitute().getName());
|
82
|
}
|
83
|
}
|
84
|
|
85
|
osr.setFieldNotes(duf.getFieldNotes());
|
86
|
if(duf.getType() != null) {
|
87
|
osr.setType(duf.getType().name());
|
88
|
}
|
89
|
osr.setUnitCount(duf.getIndividualCount());
|
90
|
|
91
|
if(duf.getKindOfUnit() != null) {
|
92
|
osr.setKindOfUnit(duf.getKindOfUnit().getLabel());
|
93
|
}
|
94
|
|
95
|
osr.setElevation(duf.getAbsoluteElevation());
|
96
|
osr.setMaxElevation(duf.getAbsoluteElevationMaximum());
|
97
|
|
98
|
osr.setDepth(duf.getDistanceToGround());
|
99
|
osr.setMaxDepth(duf.getDistanceToGroundMax());
|
100
|
|
101
|
if(duf.getGatheringPeriod() != null) {
|
102
|
TimePeriod tp = duf.getGatheringPeriod();
|
103
|
if(tp.getStart() != null) {
|
104
|
osr.setStartGatheringDate(tp.getStart().toString());
|
105
|
}
|
106
|
if(tp.getEnd() != null) {
|
107
|
osr.setEndGatheringDate(tp.getEnd().toString());
|
108
|
}
|
109
|
}
|
110
|
|
111
|
|
112
|
OccurrenceSearch.OccurrenceSearchResponse.Location loc =
|
113
|
osr.getLocation();
|
114
|
|
115
|
Point exactLocation = duf.getExactLocation();
|
116
|
if(exactLocation != null) {
|
117
|
loc.setDecimalLatitude(exactLocation.getLatitude());
|
118
|
loc.setDecimalLongitude(exactLocation.getLongitude());
|
119
|
loc.setErrorRadius(exactLocation.getErrorRadius());
|
120
|
if(exactLocation.getReferenceSystem() != null) {
|
121
|
loc.setReferenceSystem(exactLocation.getReferenceSystem().getTitleCache());
|
122
|
}
|
123
|
|
124
|
}
|
125
|
if(duf.getCountry() != null) {
|
126
|
loc.setCountry(duf.getCountry().getTitleCache());
|
127
|
}
|
128
|
|
129
|
if(duf.getLocality() != null) {
|
130
|
loc.setLocality(duf.getLocality().getText());
|
131
|
}
|
132
|
|
133
|
osr.setFieldNumber(duf.getFieldNumber());
|
134
|
osr.setAccessionNumber(duf.getAccessionNumber());
|
135
|
osr.setCatalogNumber(duf.getCatalogNumber());
|
136
|
|
137
|
Set<IdentifiableSource> sources = duf.getSources();
|
138
|
boolean dateFound = false;
|
139
|
String datePublishedString = null;
|
140
|
List<String> sourceTitleList = new ArrayList<String>();
|
141
|
for (IdentifiableSource source:sources) {
|
142
|
String citation = source.getCitation().getTitleCache();
|
143
|
|
144
|
datePublishedString = source.getCitation().getDatePublishedString();
|
145
|
if (!dateFound && !StringUtils.isEmpty(datePublishedString)){
|
146
|
osr.setPublicationDate(datePublishedString);
|
147
|
dateFound=true;
|
148
|
}
|
149
|
String micro = source.getCitationMicroReference();
|
150
|
|
151
|
if(citation == null) {
|
152
|
citation = "";
|
153
|
}
|
154
|
if(micro == null) {
|
155
|
micro = "";
|
156
|
}
|
157
|
sourceTitleList.add(citation + " " + micro);
|
158
|
}
|
159
|
osr.setSources(sourceTitleList);
|
160
|
|
161
|
osr.setPublicationDate(datePublishedString);
|
162
|
|
163
|
List<String> rightsTextList = new ArrayList<String>();
|
164
|
Set<Rights> rightsSet = duf.innerDerivedUnit().getRights();
|
165
|
for(Rights rights : rightsSet) {
|
166
|
if(rights.getAbbreviatedText() != null) {
|
167
|
rightsTextList.add(rights.getAbbreviatedText());
|
168
|
}
|
169
|
}
|
170
|
osr.setRights(rightsTextList);
|
171
|
response.add(osr);
|
172
|
}
|
173
|
|
174
|
public List<OccurrenceSearchResponse> getResponse() {
|
175
|
return this.response;
|
176
|
}
|
177
|
|
178
|
|
179
|
public OccurrenceSearchResponse createResponse(DerivedUnitFacade duFacade) {
|
180
|
OccurrenceSearch.OccurrenceSearchResponse osResponse =
|
181
|
new OccurrenceSearch.OccurrenceSearchResponse();
|
182
|
|
183
|
return osResponse;
|
184
|
}
|
185
|
|
186
|
public class OccurrenceSearchResponse {
|
187
|
|
188
|
private String acceptedTaxon;
|
189
|
private String acceptedTaxonUuid;
|
190
|
|
191
|
private String collector;
|
192
|
private String collection;
|
193
|
private String institution;
|
194
|
|
195
|
private String fieldNotes;
|
196
|
|
197
|
//
|
198
|
private String type;
|
199
|
private Object unitCount;
|
200
|
private String kindOfUnit;
|
201
|
|
202
|
//ELEVATION
|
203
|
private Object elevation;
|
204
|
private Object maxElevation;
|
205
|
|
206
|
//DEPTH
|
207
|
private Object depth;
|
208
|
private Object maxDepth;
|
209
|
|
210
|
private String startGatherinDate;
|
211
|
private String endGatheringDate;
|
212
|
|
213
|
private Location location;
|
214
|
|
215
|
private String fieldNumber;
|
216
|
private String accessionNumber;
|
217
|
private String catalogNumber;
|
218
|
private String barcode;
|
219
|
private String publicationDate;
|
220
|
|
221
|
|
222
|
private List<String> rights;
|
223
|
private List<String> sources;
|
224
|
|
225
|
//FIXME: Ignoring the fields below for the moment
|
226
|
// Will come back to them when requested and
|
227
|
// when the model allows it properly
|
228
|
|
229
|
// private String citation;
|
230
|
|
231
|
public OccurrenceSearchResponse() {
|
232
|
location = new Location();
|
233
|
rights = new ArrayList<String>();
|
234
|
sources = new ArrayList<String>();
|
235
|
|
236
|
}
|
237
|
|
238
|
/**
|
239
|
* @return the specimenOrObservationType
|
240
|
*/
|
241
|
public String getType() {
|
242
|
return type;
|
243
|
}
|
244
|
|
245
|
/**
|
246
|
* @param specimenOrObservationType the specimenOrObservationType to set
|
247
|
*/
|
248
|
public void setType(String type) {
|
249
|
this.type = type;
|
250
|
}
|
251
|
|
252
|
/**
|
253
|
* @return the acceptedTaxon
|
254
|
*/
|
255
|
public String getAcceptedTaxon() {
|
256
|
return acceptedTaxon;
|
257
|
}
|
258
|
|
259
|
/**
|
260
|
* @param acceptedTaxon the acceptedTaxon to set
|
261
|
*/
|
262
|
public void setAcceptedTaxon(String acceptedTaxon) {
|
263
|
if (acceptedTaxon !=null) {
|
264
|
this.acceptedTaxon = acceptedTaxon.split(" sec.")[0];
|
265
|
} else {
|
266
|
this.acceptedTaxon = acceptedTaxon;
|
267
|
}
|
268
|
}
|
269
|
|
270
|
|
271
|
/**
|
272
|
* @return the collector
|
273
|
*/
|
274
|
public String getCollector() {
|
275
|
return collector;
|
276
|
}
|
277
|
|
278
|
/**
|
279
|
* @param collector the collector to set
|
280
|
*/
|
281
|
public void setCollector(String collector) {
|
282
|
this.collector = collector;
|
283
|
}
|
284
|
|
285
|
|
286
|
/**
|
287
|
* @param acceptedTaxonUuid the acceptedTaxonUuid to set
|
288
|
*/
|
289
|
public void setAcceptedTaxonUuid(String acceptedTaxonUuid) {
|
290
|
this.acceptedTaxonUuid = acceptedTaxonUuid;
|
291
|
}
|
292
|
|
293
|
|
294
|
/**
|
295
|
* @return the nameUuid
|
296
|
*/
|
297
|
public String getAcceptedTaxonUuid() {
|
298
|
return acceptedTaxonUuid;
|
299
|
}
|
300
|
|
301
|
|
302
|
/**
|
303
|
* @return the accessionNumber
|
304
|
*/
|
305
|
|
306
|
public String getAccessionNumber() {
|
307
|
return accessionNumber;
|
308
|
}
|
309
|
|
310
|
/**
|
311
|
* @param accessionNumber the accessionNumber to set
|
312
|
*/
|
313
|
|
314
|
public void setAccessionNumber(String accessionNumber) {
|
315
|
this.accessionNumber = accessionNumber;
|
316
|
}
|
317
|
|
318
|
/**
|
319
|
* @return the catalogNumber
|
320
|
*/
|
321
|
public String getCatalogNumber() {
|
322
|
return catalogNumber;
|
323
|
}
|
324
|
|
325
|
/**
|
326
|
* @param catalogNumber the catalogNumber to set
|
327
|
*/
|
328
|
public void setCatalogNumber(String catalogNumber) {
|
329
|
this.catalogNumber = catalogNumber;
|
330
|
}
|
331
|
|
332
|
/**
|
333
|
* @return the fieldNumber
|
334
|
*/
|
335
|
public String getFieldNumber() {
|
336
|
return fieldNumber;
|
337
|
}
|
338
|
|
339
|
/**
|
340
|
* @param fieldNumber the fieldNumber to set
|
341
|
*/
|
342
|
public void setFieldNumber(String fieldNumber) {
|
343
|
this.fieldNumber = fieldNumber;
|
344
|
}
|
345
|
|
346
|
/**
|
347
|
* @return the minElevation
|
348
|
*/
|
349
|
public Object getElevation() {
|
350
|
return elevation;
|
351
|
}
|
352
|
|
353
|
/**
|
354
|
* @param minElevation the minElevation to set
|
355
|
*/
|
356
|
public void setElevation(Integer elevation) {
|
357
|
this.elevation = elevation;
|
358
|
}
|
359
|
|
360
|
/**
|
361
|
* @return the maxElevation
|
362
|
*/
|
363
|
public Object getMaxElevation() {
|
364
|
return maxElevation;
|
365
|
}
|
366
|
|
367
|
/**
|
368
|
* @param maxElevation the maxElevation to set
|
369
|
*/
|
370
|
public void setMaxElevation(Integer maxElevation) {
|
371
|
this.maxElevation = maxElevation;
|
372
|
}
|
373
|
|
374
|
/**
|
375
|
* @return the dateBegin
|
376
|
*/
|
377
|
public String getStartGatheringDate() {
|
378
|
return startGatherinDate;
|
379
|
}
|
380
|
|
381
|
/**
|
382
|
* @param dateBegin the dateBegin to set
|
383
|
*/
|
384
|
public void setStartGatheringDate(String dateBegin) {
|
385
|
this.startGatherinDate = dateBegin;
|
386
|
}
|
387
|
|
388
|
/**
|
389
|
* @return the dateEnd
|
390
|
*/
|
391
|
public String getEndGatheringDate() {
|
392
|
return endGatheringDate;
|
393
|
}
|
394
|
|
395
|
/**
|
396
|
* @param dateEnd the dateEnd to set
|
397
|
*/
|
398
|
public void setEndGatheringDate(String dateEnd) {
|
399
|
this.endGatheringDate = dateEnd;
|
400
|
}
|
401
|
|
402
|
/**
|
403
|
* @return the unitCount
|
404
|
*/
|
405
|
public Object getUnitCount() {
|
406
|
return unitCount;
|
407
|
}
|
408
|
|
409
|
/**
|
410
|
* @param unitCount the unitCount to set
|
411
|
*/
|
412
|
public void setUnitCount(Integer unitCount) {
|
413
|
this.unitCount = unitCount;
|
414
|
}
|
415
|
|
416
|
/**
|
417
|
* @return the barcode
|
418
|
*/
|
419
|
public String getBarcode() {
|
420
|
return barcode;
|
421
|
}
|
422
|
|
423
|
/**
|
424
|
* @param barcode the barcode to set
|
425
|
*/
|
426
|
public void setBarcode(String barcode) {
|
427
|
this.barcode = barcode;
|
428
|
}
|
429
|
|
430
|
|
431
|
public String getPublicationDate() {
|
432
|
return publicationDate;
|
433
|
}
|
434
|
|
435
|
public void setPublicationDate(String publicationDate) {
|
436
|
this.publicationDate = publicationDate;
|
437
|
}
|
438
|
|
439
|
/**
|
440
|
* @return the kindOfUnit
|
441
|
*/
|
442
|
public String getKindOfUnit() {
|
443
|
return kindOfUnit;
|
444
|
}
|
445
|
|
446
|
/**
|
447
|
* @param kindOfUnit the kindOfUnit to set
|
448
|
*/
|
449
|
public void setKindOfUnit(String kindOfUnit) {
|
450
|
this.kindOfUnit = kindOfUnit;
|
451
|
}
|
452
|
|
453
|
/**
|
454
|
* @return the sources
|
455
|
*/
|
456
|
public List<String> getSources() {
|
457
|
return sources;
|
458
|
}
|
459
|
|
460
|
/**
|
461
|
* @param sources the sources to set
|
462
|
*/
|
463
|
public void setSources(List<String> sources) {
|
464
|
this.sources = sources;
|
465
|
}
|
466
|
|
467
|
/**
|
468
|
* @return the collection
|
469
|
*/
|
470
|
public String getCollection() {
|
471
|
return collection;
|
472
|
}
|
473
|
|
474
|
/**
|
475
|
* @param collection the collection to set
|
476
|
*/
|
477
|
public void setCollection(String collection) {
|
478
|
this.collection = collection;
|
479
|
}
|
480
|
|
481
|
/**
|
482
|
* @return the institution
|
483
|
*/
|
484
|
public String getInstitution() {
|
485
|
return institution;
|
486
|
}
|
487
|
|
488
|
/**
|
489
|
* @param institution the institution to set
|
490
|
*/
|
491
|
public void setInstitution(String institution) {
|
492
|
this.institution = institution;
|
493
|
}
|
494
|
|
495
|
/**
|
496
|
* @return the depth
|
497
|
*/
|
498
|
public Object getDepth() {
|
499
|
return depth;
|
500
|
}
|
501
|
|
502
|
/**
|
503
|
* @param depth the depth to set
|
504
|
*/
|
505
|
public void setDepth(Double depth) {
|
506
|
this.depth = depth;
|
507
|
}
|
508
|
|
509
|
/**
|
510
|
* @return the maxDepth
|
511
|
*/
|
512
|
public Object getMaxDepth() {
|
513
|
return maxDepth;
|
514
|
}
|
515
|
|
516
|
/**
|
517
|
* @param maxDepth the maxDepth to set
|
518
|
*/
|
519
|
public void setMaxDepth(Double maxDepth) {
|
520
|
this.maxDepth = maxDepth;
|
521
|
}
|
522
|
|
523
|
/**
|
524
|
* @return the fieldNotes
|
525
|
*/
|
526
|
public String getFieldNotes() {
|
527
|
return fieldNotes;
|
528
|
}
|
529
|
|
530
|
/**
|
531
|
* @param fieldNotes the fieldNotes to set
|
532
|
*/
|
533
|
public void setFieldNotes(String fieldNotes) {
|
534
|
this.fieldNotes = fieldNotes;
|
535
|
}
|
536
|
|
537
|
// /**
|
538
|
// * @return the dataResourceCitation
|
539
|
// */
|
540
|
// public String getCitation() {
|
541
|
// return citation;
|
542
|
// }
|
543
|
//
|
544
|
// /**
|
545
|
// * @param dataResourceCitation the dataResourceCitation to set
|
546
|
// */
|
547
|
// public void setCitation(String citation) {
|
548
|
// this.citation = citation;
|
549
|
// }
|
550
|
|
551
|
/**
|
552
|
* @return the dataResourceRights
|
553
|
*/
|
554
|
public List<String> getRights() {
|
555
|
return rights;
|
556
|
}
|
557
|
|
558
|
/**
|
559
|
* @param dataResourceRights the dataResourceRights to set
|
560
|
*/
|
561
|
public void setRights(List<String> rights) {
|
562
|
this.rights = rights;
|
563
|
}
|
564
|
|
565
|
public Location getLocation() {
|
566
|
return location;
|
567
|
}
|
568
|
|
569
|
public void setLocation(Location location) {
|
570
|
this.location = location;
|
571
|
}
|
572
|
|
573
|
public class Location {
|
574
|
private Object decimalLatitude;
|
575
|
private Object decimalLongitude;
|
576
|
private Object errorRadius;
|
577
|
private String country;
|
578
|
private String locality;
|
579
|
private String referenceSystem;
|
580
|
|
581
|
public Object getDecimalLatitude() {
|
582
|
return decimalLatitude;
|
583
|
}
|
584
|
public void setDecimalLatitude(Double decimalLatitude) {
|
585
|
this.decimalLatitude = decimalLatitude;
|
586
|
}
|
587
|
public Object getDecimalLongitude() {
|
588
|
return decimalLongitude;
|
589
|
}
|
590
|
public void setDecimalLongitude(Double decimalLongitude) {
|
591
|
this.decimalLongitude = decimalLongitude;
|
592
|
}
|
593
|
public Object getErrorRadius() {
|
594
|
return errorRadius;
|
595
|
}
|
596
|
public void setErrorRadius(Integer errorRadius) {
|
597
|
this.errorRadius = errorRadius;
|
598
|
}
|
599
|
public String getCountry() {
|
600
|
return country;
|
601
|
}
|
602
|
public void setCountry(String country) {
|
603
|
this.country = country;
|
604
|
}
|
605
|
public String getLocality() {
|
606
|
return locality;
|
607
|
}
|
608
|
public void setLocality(String locality) {
|
609
|
this.locality = locality;
|
610
|
}
|
611
|
public String getReferenceSystem() {
|
612
|
return referenceSystem;
|
613
|
}
|
614
|
public void setReferenceSystem(String referenceSystem) {
|
615
|
this.referenceSystem = referenceSystem;
|
616
|
}
|
617
|
|
618
|
}
|
619
|
|
620
|
}
|
621
|
|
622
|
}
|