Project

General

Profile

Download (7.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 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.service.dto;
10

    
11
import java.io.Serializable;
12
import java.util.HashSet;
13
import java.util.Set;
14

    
15
import org.joda.time.Partial;
16

    
17
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
18
import eu.etaxonomy.cdm.model.common.LanguageString;
19
import eu.etaxonomy.cdm.model.location.NamedArea;
20
import eu.etaxonomy.cdm.model.location.Point;
21
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
22

    
23
/**
24
 * @author k.luther
25
 * @since 21.06.2018
26
 *
27
 */
28
public class GatheringEventDTO implements Serializable{
29

    
30
    private static final long serialVersionUID = -4381193272881277448L;
31

    
32
    private String locality;
33
    private Point exactLocation;
34
    private String country;
35
    private Set<String> collectingAreas;
36
    private String collectingMethod;
37
    private Integer absoluteElevation;
38
    private Integer absoluteElevationMax;
39
    private String absoluteElevationText;
40
    private Double distanceToGround;
41
    private Double distanceToGroundMax;
42
    private String distanceToGroundText;
43
    private Double distanceToWaterSurface;
44
    private Double distanceToWaterSurfaceMax;
45
    private String collector;
46
    private Partial date;
47

    
48
    /**
49
     * @param locality
50
     * @param exactLocation
51
     * @param country
52
     * @param collectingAreas
53
     * @param collectingMethod
54
     * @param absoluteElevation
55
     * @param absoluteElevationMax
56
     * @param absoluteElevationText
57
     * @param distanceToGround
58
     * @param distanceToGroundMax
59
     * @param distanceToGroundText
60
     * @param distanceToWaterSurface
61
     * @param distanceToWaterSurfaceMax
62
     * @param distanceToWaterSurfaceText
63
     */
64
    public GatheringEventDTO(String locality, Point exactLocation, String country, Set<String> collectingAreas,
65
            String collectingMethod, String collector, Integer absoluteElevation, Integer absoluteElevationMax,
66
            String absoluteElevationText, Double distanceToGround, Double distanceToGroundMax,
67
            String distanceToGroundText, Double distanceToWaterSurface, Double distanceToWaterSurfaceMax,
68
            String distanceToWaterSurfaceText) {
69

    
70
        this.locality = locality;
71
        this.exactLocation = exactLocation;
72
        this.country = country;
73
        this.collectingAreas = collectingAreas;
74
        this.collectingMethod = collectingMethod;
75
        this.setCollector(collector);
76
        this.absoluteElevation = absoluteElevation;
77
        this.absoluteElevationMax = absoluteElevationMax;
78
        this.absoluteElevationText = absoluteElevationText;
79
        this.distanceToGround = distanceToGround;
80
        this.distanceToGroundMax = distanceToGroundMax;
81
        this.distanceToGroundText = distanceToGroundText;
82
        this.distanceToWaterSurface = distanceToWaterSurface;
83
        this.distanceToWaterSurfaceMax = distanceToWaterSurfaceMax;
84
        this.distanceToWaterSurfaceText = distanceToWaterSurfaceText;
85
    }
86

    
87
    /**
88
     *
89
     */
90
    public GatheringEventDTO() {
91

    
92
    }
93

    
94
    public static GatheringEventDTO newInstance(GatheringEvent gathering){
95
        GatheringEventDTO dto = new GatheringEventDTO();
96
        gathering = HibernateProxyHelper.deproxy(gathering);
97
        if (gathering.getLocality() != null){
98
            LanguageString locality = HibernateProxyHelper.deproxy(gathering.getLocality());
99
            dto.locality = locality.getText();
100
            }
101
        if (gathering.getExactLocation() != null){
102
            dto.exactLocation = gathering.getExactLocation();
103
        }
104
        if (gathering.getCountry() != null){
105
            dto.country =  gathering.getCountry().getTitleCache();
106
        }
107
        if (gathering.getCollectingMethod() != null){
108
            dto.collectingMethod = gathering.getCollectingMethod();
109
        }
110
        if (gathering.getCollector() != null ){
111
            dto.collector = gathering.getCollector().getTitleCache();
112
        }
113
        if (gathering.getAbsoluteElevation() != null){
114
            dto.absoluteElevation = gathering.getAbsoluteElevation();
115
        }
116
        if (gathering.getAbsoluteElevationMax() != null){
117
            dto.absoluteElevationMax = gathering.getAbsoluteElevationMax();
118
        }
119
        if (gathering.getAbsoluteElevationText() != null){
120
            dto.absoluteElevationText = gathering.getAbsoluteElevationText();
121
        }
122
        if (gathering.getDistanceToGround() != null){
123
            dto.distanceToGround = gathering.getDistanceToGround();
124
        }
125
        if (gathering.getDistanceToGroundMax() != null){
126
            dto.distanceToGroundMax = gathering.getDistanceToGroundMax();
127
        }
128
        if (gathering.getDistanceToGroundText() != null){
129
            dto.distanceToGroundText = gathering.getDistanceToGroundText();
130
        }
131
        if (gathering.getDistanceToWaterSurface() != null){
132
            dto.distanceToWaterSurface= gathering.getDistanceToWaterSurface();
133
        }
134
        if (gathering.getDistanceToWaterSurfaceMax() != null){
135
            dto.distanceToWaterSurfaceMax= gathering.getDistanceToWaterSurfaceMax();
136
        }
137
        if (gathering.getDistanceToWaterSurfaceText() != null){
138
            dto.distanceToWaterSurfaceText= gathering.getDistanceToWaterSurfaceText();
139
        }
140
        if(gathering.getTimeperiod() != null) {
141
            dto.setDate(gathering.getGatheringDate());
142
        }
143

    
144
        for (NamedArea area: gathering.getCollectingAreas()){
145
            String areaString = area.getLabel();
146
            if (dto.getCollectingAreas() == null){
147
                dto.collectingAreas = new HashSet<>();
148
            }
149
            dto.collectingAreas.add(areaString);
150
        }
151

    
152
        return dto;
153
    }
154

    
155

    
156
    public String getLocality() {
157
        return locality;
158
    }
159
    public Point getExactLocation() {
160
        return exactLocation;
161
    }
162
    public String getCountry() {
163
        return country;
164
    }
165
    public Set<String> getCollectingAreas() {
166
        return collectingAreas;
167
    }
168
    public String getCollectingMethod() {
169
        return collectingMethod;
170
    }
171
    public Integer getAbsoluteElevation() {
172
        return absoluteElevation;
173
    }
174
    public Integer getAbsoluteElevationMax() {
175
        return absoluteElevationMax;
176
    }
177
    public String getAbsoluteElevationText() {
178
        return absoluteElevationText;
179
    }
180
    public Double getDistanceToGround() {
181
        return distanceToGround;
182
    }
183
    public Double getDistanceToGroundMax() {
184
        return distanceToGroundMax;
185
    }
186
    public String getDistanceToGroundText() {
187
        return distanceToGroundText;
188
    }
189
    public Double getDistanceToWaterSurface() {
190
        return distanceToWaterSurface;
191
    }
192
    public Double getDistanceToWaterSurfaceMax() {
193
        return distanceToWaterSurfaceMax;
194
    }
195
    public String getDistanceToWaterSurfaceText() {
196
        return distanceToWaterSurfaceText;
197
    }
198
    public String getCollector() {
199
        return collector;
200
    }
201
    public void setCollector(String collector) {
202
        this.collector = collector;
203
    }
204
    public Partial getdate() {
205
        return date;
206
    }
207

    
208
    public void setDate(Partial date) {
209
        this.date = date;
210
    }
211
    private String distanceToWaterSurfaceText;
212

    
213
}
(19-19/44)