ref #7674 Add equals() and hashCode() to RowWrapperDTO
[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.model.common.Language;
15 import eu.etaxonomy.cdm.model.location.NamedArea;
16 import eu.etaxonomy.cdm.model.location.Point;
17 import eu.etaxonomy.cdm.model.occurrence.GatheringEvent;
18 import eu.etaxonomy.cdm.persistence.dto.TermDto;
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<TermDto> 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<TermDto> 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 if (gathering.getLocality() != null){
91 dto.locality = gathering.getLocality().getLanguageLabel(Language.DEFAULT());
92 }
93 if (gathering.getExactLocation() != null){
94 dto.exactLocation = gathering.getExactLocation();
95 }
96 if (gathering.getCountry() != null){
97 dto.country = gathering.getCountry().getTitleCache();
98 }
99 if (gathering.getCollectingMethod() != null){
100 dto.collectingMethod = gathering.getCollectingMethod();
101 }
102 if (gathering.getCollector() != null ){
103 dto.collector = gathering.getCollector().getTitleCache();
104 }
105 if (gathering.getAbsoluteElevation() != null){
106 dto.absoluteElevation = gathering.getAbsoluteElevation();
107 }
108 if (gathering.getAbsoluteElevationMax() != null){
109 dto.absoluteElevationMax = gathering.getAbsoluteElevationMax();
110 }
111 if (gathering.getAbsoluteElevationText() != null){
112 dto.absoluteElevationText = gathering.getAbsoluteElevationText();
113 }
114 if (gathering.getDistanceToGround() != null){
115 dto.distanceToGround = gathering.getDistanceToGround();
116 }
117 if (gathering.getDistanceToGroundMax() != null){
118 dto.distanceToGroundMax = gathering.getDistanceToGroundMax();
119 }
120 if (gathering.getDistanceToGroundText() != null){
121 dto.distanceToGroundText = gathering.getDistanceToGroundText();
122 }
123 if (gathering.getDistanceToWaterSurface() != null){
124 dto.distanceToWaterSurface= gathering.getDistanceToWaterSurface();
125 }
126 if (gathering.getDistanceToWaterSurfaceMax() != null){
127 dto.distanceToWaterSurfaceMax= gathering.getDistanceToWaterSurfaceMax();
128 }
129 if (gathering.getDistanceToWaterSurfaceText() != null){
130 dto.distanceToWaterSurfaceText= gathering.getDistanceToWaterSurfaceText();
131 }
132
133 for (NamedArea area: gathering.getCollectingAreas()){
134 TermDto areaDto = TermDto.fromNamedArea(area);
135 if (dto.getCollectingAreas() == null){
136 dto.collectingAreas = new HashSet<>();
137 }
138 dto.collectingAreas.add(areaDto);
139 }
140
141 return dto;
142 }
143
144
145 public String getLocality() {
146 return locality;
147 }
148 public Point getExactLocation() {
149 return exactLocation;
150 }
151 public String getCountry() {
152 return country;
153 }
154 public Set<TermDto> getCollectingAreas() {
155 return collectingAreas;
156 }
157 public String getCollectingMethod() {
158 return collectingMethod;
159 }
160 public Integer getAbsoluteElevation() {
161 return absoluteElevation;
162 }
163 public Integer getAbsoluteElevationMax() {
164 return absoluteElevationMax;
165 }
166 public String getAbsoluteElevationText() {
167 return absoluteElevationText;
168 }
169 public Double getDistanceToGround() {
170 return distanceToGround;
171 }
172 public Double getDistanceToGroundMax() {
173 return distanceToGroundMax;
174 }
175 public String getDistanceToGroundText() {
176 return distanceToGroundText;
177 }
178 public Double getDistanceToWaterSurface() {
179 return distanceToWaterSurface;
180 }
181 public Double getDistanceToWaterSurfaceMax() {
182 return distanceToWaterSurfaceMax;
183 }
184 public String getDistanceToWaterSurfaceText() {
185 return distanceToWaterSurfaceText;
186 }
187 public String getCollector() {
188 return collector;
189 }
190 public void setCollector(String collector) {
191 this.collector = collector;
192 }
193 private String distanceToWaterSurfaceText;
194
195 }