Merge branch 'release/5.5.0'
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / dto / GatheringEventDTO.java
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.util.HashSet;
12 import java.util.Set;
13
14 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
15 import eu.etaxonomy.cdm.model.common.LanguageString;
16 import eu.etaxonomy.cdm.model.location.NamedArea;
17 import eu.etaxonomy.cdm.model.location.Point;
18 import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
19
20 /**
21 * @author k.luther
22 * @since 21.06.2018
23 *
24 */
25 public class GatheringEventDTO {
26
27 private String locality;
28 private Point exactLocation;
29 private String country;
30 private Set<String> collectingAreas;
31 private String collectingMethod;
32 private Integer absoluteElevation;
33 private Integer absoluteElevationMax;
34 private String absoluteElevationText;
35 private Double distanceToGround;
36 private Double distanceToGroundMax;
37 private String distanceToGroundText;
38 private Double distanceToWaterSurface;
39 private Double distanceToWaterSurfaceMax;
40 private String collector;
41
42 /**
43 * @param locality
44 * @param exactLocation
45 * @param country
46 * @param collectingAreas
47 * @param collectingMethod
48 * @param absoluteElevation
49 * @param absoluteElevationMax
50 * @param absoluteElevationText
51 * @param distanceToGround
52 * @param distanceToGroundMax
53 * @param distanceToGroundText
54 * @param distanceToWaterSurface
55 * @param distanceToWaterSurfaceMax
56 * @param distanceToWaterSurfaceText
57 */
58 public GatheringEventDTO(String locality, Point exactLocation, String country, Set<String> collectingAreas,
59 String collectingMethod, String collector, Integer absoluteElevation, Integer absoluteElevationMax,
60 String absoluteElevationText, Double distanceToGround, Double distanceToGroundMax,
61 String distanceToGroundText, Double distanceToWaterSurface, Double distanceToWaterSurfaceMax,
62 String distanceToWaterSurfaceText) {
63
64 this.locality = locality;
65 this.exactLocation = exactLocation;
66 this.country = country;
67 this.collectingAreas = collectingAreas;
68 this.collectingMethod = collectingMethod;
69 this.setCollector(collector);
70 this.absoluteElevation = absoluteElevation;
71 this.absoluteElevationMax = absoluteElevationMax;
72 this.absoluteElevationText = absoluteElevationText;
73 this.distanceToGround = distanceToGround;
74 this.distanceToGroundMax = distanceToGroundMax;
75 this.distanceToGroundText = distanceToGroundText;
76 this.distanceToWaterSurface = distanceToWaterSurface;
77 this.distanceToWaterSurfaceMax = distanceToWaterSurfaceMax;
78 this.distanceToWaterSurfaceText = distanceToWaterSurfaceText;
79 }
80
81 /**
82 *
83 */
84 public GatheringEventDTO() {
85
86 }
87
88 public static GatheringEventDTO newInstance(GatheringEvent gathering){
89 GatheringEventDTO dto = new GatheringEventDTO();
90 gathering = HibernateProxyHelper.deproxy(gathering);
91 if (gathering.getLocality() != null){
92 LanguageString locality = HibernateProxyHelper.deproxy(gathering.getLocality());
93 dto.locality = locality.getText();
94 }
95 if (gathering.getExactLocation() != null){
96 dto.exactLocation = gathering.getExactLocation();
97 }
98 if (gathering.getCountry() != null){
99 dto.country = gathering.getCountry().getTitleCache();
100 }
101 if (gathering.getCollectingMethod() != null){
102 dto.collectingMethod = gathering.getCollectingMethod();
103 }
104 if (gathering.getCollector() != null ){
105 dto.collector = gathering.getCollector().getTitleCache();
106 }
107 if (gathering.getAbsoluteElevation() != null){
108 dto.absoluteElevation = gathering.getAbsoluteElevation();
109 }
110 if (gathering.getAbsoluteElevationMax() != null){
111 dto.absoluteElevationMax = gathering.getAbsoluteElevationMax();
112 }
113 if (gathering.getAbsoluteElevationText() != null){
114 dto.absoluteElevationText = gathering.getAbsoluteElevationText();
115 }
116 if (gathering.getDistanceToGround() != null){
117 dto.distanceToGround = gathering.getDistanceToGround();
118 }
119 if (gathering.getDistanceToGroundMax() != null){
120 dto.distanceToGroundMax = gathering.getDistanceToGroundMax();
121 }
122 if (gathering.getDistanceToGroundText() != null){
123 dto.distanceToGroundText = gathering.getDistanceToGroundText();
124 }
125 if (gathering.getDistanceToWaterSurface() != null){
126 dto.distanceToWaterSurface= gathering.getDistanceToWaterSurface();
127 }
128 if (gathering.getDistanceToWaterSurfaceMax() != null){
129 dto.distanceToWaterSurfaceMax= gathering.getDistanceToWaterSurfaceMax();
130 }
131 if (gathering.getDistanceToWaterSurfaceText() != null){
132 dto.distanceToWaterSurfaceText= gathering.getDistanceToWaterSurfaceText();
133 }
134
135 for (NamedArea area: gathering.getCollectingAreas()){
136 String areaString = area.getLabel();
137 if (dto.getCollectingAreas() == null){
138 dto.collectingAreas = new HashSet<>();
139 }
140 dto.collectingAreas.add(areaString);
141 }
142
143 return dto;
144 }
145
146
147 public String getLocality() {
148 return locality;
149 }
150 public Point getExactLocation() {
151 return exactLocation;
152 }
153 public String getCountry() {
154 return country;
155 }
156 public Set<String> getCollectingAreas() {
157 return collectingAreas;
158 }
159 public String getCollectingMethod() {
160 return collectingMethod;
161 }
162 public Integer getAbsoluteElevation() {
163 return absoluteElevation;
164 }
165 public Integer getAbsoluteElevationMax() {
166 return absoluteElevationMax;
167 }
168 public String getAbsoluteElevationText() {
169 return absoluteElevationText;
170 }
171 public Double getDistanceToGround() {
172 return distanceToGround;
173 }
174 public Double getDistanceToGroundMax() {
175 return distanceToGroundMax;
176 }
177 public String getDistanceToGroundText() {
178 return distanceToGroundText;
179 }
180 public Double getDistanceToWaterSurface() {
181 return distanceToWaterSurface;
182 }
183 public Double getDistanceToWaterSurfaceMax() {
184 return distanceToWaterSurfaceMax;
185 }
186 public String getDistanceToWaterSurfaceText() {
187 return distanceToWaterSurfaceText;
188 }
189 public String getCollector() {
190 return collector;
191 }
192 public void setCollector(String collector) {
193 this.collector = collector;
194 }
195 private String distanceToWaterSurfaceText;
196
197 }