Project

General

Profile

Download (2.72 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2017 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.taxeditor.editor.workingSet.matrix;
10

    
11
import java.util.Collection;
12

    
13
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
14
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
15
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
16
import eu.etaxonomy.cdm.model.location.NamedArea;
17
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
18
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
19
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
20
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

    
24
/**
25
 * @author pplitzner
26
 * @since Dec 14, 2017
27
 *
28
 */
29
public class RowWrapper {
30

    
31
    private SpecimenDescription description;
32

    
33
    private Collection<TaxonBase<?>> associatedTaxa;
34
    private FieldUnit fieldUnit;
35
    private String identifier;
36
    private NamedArea country;
37

    
38
    public RowWrapper(SpecimenDescription description) {
39
        this.description = description;
40

    
41
        IOccurrenceService occurrenceService = CdmStore.getService(IOccurrenceService.class);
42
        SpecimenOrObservationBase<?> specimen = HibernateProxyHelper.deproxy(description.getDescribedSpecimenOrObservation(), SpecimenOrObservationBase.class);
43
        if(specimen!=null){
44
            associatedTaxa = occurrenceService.listAssociatedTaxa(specimen, null, null, null, null);
45
            Collection<FieldUnit> fieldUnits = occurrenceService.getFieldUnits(specimen.getUuid());
46
            if(fieldUnits.size()!=1){
47
                MessagingUtils.error(RowWrapper.class, "More than one or no field unit found for specimen", null);
48
            }
49
            else{
50
                fieldUnit = fieldUnits.iterator().next();
51
            }
52
            if(specimen instanceof DerivedUnit){
53
                identifier = occurrenceService.getMostSignificantIdentifier(HibernateProxyHelper.deproxy(specimen, DerivedUnit.class));
54
            }
55
            if(fieldUnit!=null && fieldUnit.getGatheringEvent()!=null){
56
                country = fieldUnit.getGatheringEvent().getCountry();
57
            }
58
        }
59
    }
60

    
61
    public SpecimenDescription getSpecimenDescription() {
62
        return description;
63
    }
64

    
65
    public Collection<TaxonBase<?>> getAssociatedTaxa() {
66
        return associatedTaxa;
67
    }
68

    
69
    public FieldUnit getFieldUnit() {
70
        return fieldUnit;
71
    }
72

    
73
    public String getIdentifier() {
74
        return identifier;
75
    }
76

    
77
    public NamedArea getCountry() {
78
        return country;
79
    }
80

    
81
}
(5-5/8)