Project

General

Profile

Revision 448ce6bb

ID448ce6bbb53745eb30dc9f7266a660720ad0b25b
Parent c52f3357
Child d0e1e5f3

Added by Patrick Plitzner about 6 years ago

  • extended dto assembly

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
64 64
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
65 65
import eu.etaxonomy.cdm.model.molecular.DnaSample;
66 66
import eu.etaxonomy.cdm.model.molecular.Sequence;
67
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
67 68
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
68 69
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
69 70
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent;
......
327 328
    private DerivateHierarchyDTO assembleDerivateHierarchyDTO(FieldUnit fieldUnit, Taxon associatedTaxon){
328 329

  
329 330
        DerivateHierarchyDTO dto = new DerivateHierarchyDTO();
330
        //        TaxonNameBase name = associatedTaxon.getName();
331
        //        name = HibernateProxyHelper.deproxy(name, TaxonNameBase.class);
332
        //        dto.setType(!name.getTypeDesignations().isEmpty());
331

  
332
        //types
333
        TaxonNameBase name = associatedTaxon.getName();
334
        dto.setHasType(!name.getTypeDesignations().isEmpty());
333 335

  
334 336
        if(fieldUnit.getGatheringEvent()!=null){
335 337
            GatheringEvent gatheringEvent = fieldUnit.getGatheringEvent();
......
352 354

  
353 355
        //iterate over sub derivates
354 356
        for (DerivedUnit derivedUnit : derivedUnits) {
357
            //current accession number
358
            String currentAccessionNumber = derivedUnit.getAccessionNumber()!=null?derivedUnit.getAccessionNumber():"";
359
            //current herbarium
360
            String currentHerbarium = "";
361
            eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
362
            if(collection!=null){
363
                currentHerbarium = collection.getCode()!=null?collection.getCode():"";
364
                //count herbaria
365
                Integer count = collectionToCountMap.get(collection);
366
                if(count==null){
367
                    count = 1;
368
                }
369
                else{
370
                    count++;
371
                }
372
                collectionToCountMap.put(collection, count);
373
            }
355 374
            //assemble molecular data
356 375
            if(derivedUnit instanceof DnaSample){//.getRecordBasis()==SpecimenOrObservationType.DnaSample){
357 376
                dto.setHasDna(true);
358 377

  
359 378
                DnaSample dna = (DnaSample)derivedUnit;
360 379
                if(dna.getBankNumber()!=null){
361
                    dto.addMolecularData(dna.getBankNumber());
380
                    dto.addMolecularData(dna.getBankNumber(), "SampleDesignation?");//FIXME replace with actual getter
362 381
                }
363 382
            }
364 383
            //assemble media data
......
370 389
                    if(media.getKindOfUnit().getUuid().equals(UUID.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03"))){
371 390
                        dto.setHasSpecimenScan(true);
372 391
                        if(mediaUriString!=null){
373
                            dto.addSpecimenScan(mediaUriString);
392
                            dto.addSpecimenScan(mediaUriString, currentHerbarium+" "+currentAccessionNumber);
374 393
                        }
375 394
                    }
376 395
                    else if(media.getKindOfUnit().getUuid().equals(UUID.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34"))){
377 396
                        dto.setHasDetailImage(true);
378 397
                        if(mediaUriString!=null){
379
                            dto.addDetailImage(mediaUriString);
398
                            String motif = "";
399
                            if(media.getMediaSpecimen()!=null && media.getMediaSpecimen().getTitle(Language.DEFAULT())!=null){
400
                                motif = media.getMediaSpecimen().getTitle(Language.DEFAULT()).getText();
401
                            }
402
                            dto.addDetailImage(mediaUriString, motif);
380 403
                        }
381 404
                    }
382 405
                }
383 406
            }
384 407
            //assemble preserved specimen data
385 408
            else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
386
                eu.etaxonomy.cdm.model.occurrence.Collection collection = derivedUnit.getCollection();
387
                if(collection!=null){
388
                    Integer count = collectionToCountMap.get(collection);
389
                    if(count==null){
390
                        count = 1;
391
                    }
392
                    else{
393
                        count++;
394
                    }
395
                    collectionToCountMap.put(collection, count);
396
                }
409

  
397 410
            }
398 411
        }
412

  
413
        //citation
414
        String citation = "";
415
        citation += dto.getCountry();
416
        if(fieldUnit.getGatheringEvent()!=null){
417
            if(fieldUnit.getGatheringEvent().getLocality()!=null){
418
                citation += fieldUnit.getGatheringEvent().getLocality().getText();
419
            }
420
            if(fieldUnit.getGatheringEvent().getExactLocation()!=null
421
                    && fieldUnit.getGatheringEvent().getExactLocation().getLatitude()!=null
422
                    && fieldUnit.getGatheringEvent().getExactLocation().getLongitude()!=null){
423
                citation += fieldUnit.getGatheringEvent().getExactLocation().getLatitude().toString();
424
                citation += ", ";
425
                citation += fieldUnit.getGatheringEvent().getExactLocation().getLongitude().toString();
426
            }
427
        }
428

  
399 429
        //assemble herbaria string
400 430
        String herbariaString = "";
401 431
        final String herbariaSeparator = ", ";
......
413 443
            herbariaString = herbariaString.substring(0, herbariaString.length()-herbariaSeparator.length());
414 444
        }
415 445
        dto.setHerbarium(herbariaString);
446
        dto.setCitation(citation);
416 447
        return dto;
417 448
    }
418 449

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateHierarchyDTO.java
1 1
package eu.etaxonomy.cdm.api.service.dto;
2 2

  
3 3
import java.util.ArrayList;
4
import java.util.HashMap;
4 5
import java.util.List;
6
import java.util.Map;
5 7

  
6 8
public class DerivateHierarchyDTO {
7 9

  
......
22 24
	private String protologue;
23 25
	private String citation;
24 26
	private List<String> types;
25
	private List<String> specimenScans;
26
	private List<String> molecularData;
27
	private List<String> detailImages;
27
	private Map<String, String> specimenScans;
28
	private Map<String, String> molecularData;
29
	private Map<String, String> detailImages;
28 30
    /**
29 31
     * @return the hasDna
30 32
     */
......
179 181
    /**
180 182
     * @return the specimenScans
181 183
     */
182
    public List<String> getSpecimenScans() {
184
    public Map<String, String> getSpecimenScans() {
183 185
        return specimenScans;
184 186
    }
185 187
    /**
186 188
     * @param specimenScans the specimenScans to set
187 189
     */
188
    public void setSpecimenScans(List<String> specimenScans) {
190
    public void setSpecimenScans(Map<String, String> specimenScans) {
189 191
        this.specimenScans = specimenScans;
190 192
    }
191 193

  
192
    public void addSpecimenScan(String uri){
194
    public void addSpecimenScan(String uri, String herbarium){
193 195
        if(specimenScans==null){
194
            specimenScans = new ArrayList<String>();
196
            specimenScans = new HashMap<String, String>();
195 197
        }
196
        specimenScans.add(uri);
198
        specimenScans.put(uri, herbarium);
197 199
    }
198 200
    /**
199 201
     * @return the molecularData
200 202
     */
201
    public List<String> getMolecularData() {
203
    public Map<String, String> getMolecularData() {
202 204
        return molecularData;
203 205
    }
204 206
    /**
205 207
     * @param molecularData the molecularData to set
206 208
     */
207
    public void setMolecularData(List<String> molecularData) {
209
    public void setMolecularData(Map<String, String> molecularData) {
208 210
        this.molecularData = molecularData;
209 211
    }
210 212

  
211
    public void addMolecularData(String uri){
213
    public void addMolecularData(String uri, String marker){
212 214
        if(molecularData==null){
213
            molecularData = new ArrayList<String>();
215
            molecularData = new HashMap<String, String>();
214 216
        }
215
        molecularData.add(uri);
217
        molecularData.put(uri, marker);
216 218
    }
217 219

  
218 220
    /**
219 221
     * @return the detailImages
220 222
     */
221
    public List<String> getDetailImages() {
223
    public Map<String, String> getDetailImages() {
222 224
        return detailImages;
223 225
    }
224 226
    /**
225 227
     * @param detailImages the detailImages to set
226 228
     */
227
    public void setDetailImages(List<String> detailImages) {
229
    public void setDetailImages(Map<String, String> detailImages) {
228 230
        this.detailImages = detailImages;
229 231
    }
230 232

  
231
    public void addDetailImage(String uri){
233
    public void addDetailImage(String uri, String motif){
232 234
        if(detailImages==null){
233
            detailImages = new ArrayList<String>();
235
            detailImages = new HashMap<String, String>();
234 236
        }
235
        detailImages.add(uri);
237
        detailImages.put(uri, motif);
236 238
    }
237 239

  
238 240

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)