8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
13 import java.math.BigDecimal;
14 import java.util.ArrayList;
16 import javax.persistence.DiscriminatorValue;
17 import javax.persistence.Entity;
18 import javax.persistence.NamedQueries;
19 import javax.persistence.NamedQuery;
33 @DiscriminatorValue(
"GeoPoint")
35 @NamedQuery(name =
"SuggestionAttribute.findByGeoLat", query =
"SELECT a FROM SuggestionAttribute a WHERE a.geoLat = :geoLat"),
36 @NamedQuery(name =
"SuggestionAttribute.findByGeoLong", query =
"SELECT a FROM SuggestionAttribute a WHERE a.geoLong = :geoLong")
55 this.simpleType =
"GeoPoint";
57 this.geoLong = geoLong;
58 this.refSuggestion = refSuggestion;
72 this.simpleType =
"GeoPoint";
74 this.geoLong = geoLong;
75 this.refSuggestion = refSuggestion;
76 this.priority = priority;
86 return new GeoPoint(geoLat, geoLong);
96 this.geoLat = ((
GeoPoint) value).getLatitude();
97 this.geoLong = ((
GeoPoint) value).getLongitude();
118 if (geoLat == null || geoLong == null) {
122 +
"<geo:lat>" + geoLat.toPlainString() +
"</geo:lat> "
123 +
"<geo:long>" + geoLong.toPlainString() +
"</geo:long>"
133 public void setRawValues(Object values)
throws IllegalArgumentException {
134 @SuppressWarnings(
"unchecked") ArrayList<Object> valuesArray = (ArrayList<Object>)values;
135 @SuppressWarnings(
"unchecked") Map<String,String> tag = (Map<String,String>)valuesArray.get(0);
137 String latitude = tag.get(
"geo:lat");
138 String longitude = tag.get(
"geo:long");
141 this.geoLat =
new BigDecimal(latitude);
142 this.geoLong =
new BigDecimal(longitude);
143 }
catch (NumberFormatException e) {
144 throw new IllegalArgumentException(
"Latitude or Longitude is not valid Decimal value.");
173 public void setStringValue(String latitude, String longitude)
throws IllegalArgumentException {
174 if (latitude == null && longitude == null) {
178 if (latitude == null || longitude == null) {
179 throw new IllegalArgumentException(
"Latitude or Longitude value is null");
183 this.geoLat =
new BigDecimal(latitude);
184 this.geoLong =
new BigDecimal(longitude);
185 }
catch (NumberFormatException e) {
186 throw new IllegalArgumentException(
"Latitude or Longitude is not valid Decimal value.");
197 public void setStringValue(String GPointEncoded)
throws IllegalArgumentException {
199 if (GPointEncoded.equals(
"null")) {
204 String[] Points = GPointEncoded.split(
" ");
205 if (Points.length == 2) {
207 this.geoLat =
new BigDecimal(Points[0]);
208 this.geoLong =
new BigDecimal(Points[1]);
209 }
catch (NumberFormatException e) {
210 throw new IllegalArgumentException(
"Latitude or Longitude is not valid Decimal value.");
213 throw new IllegalArgumentException(
"Too many words in String.");
227 StringBuilder sb =
new StringBuilder();
228 if (this.geoLat != null) {
229 sb.append(this.geoLat.toString());
232 if (this.geoLong != null) {
233 sb.append(this.geoLong.toString());
235 return sb.toString();
SugGeoPointAttribute(String name, BigDecimal geoLat, BigDecimal geoLong, Suggestion refSuggestion, Integer priority)
void setStringValue(String GPointEncoded)
SugGeoPointAttribute(String name, BigDecimal geoLat, BigDecimal geoLong, Suggestion refSuggestion)
void setValue(Object value)
void setStringValue(String latitude, String longitude)
Class representing attribute of type GeoPoint.
String getTypeOntologyUri()
void setRawValues(Object values)
This class represents GeoPoint value.
Abstract class representing more complex attribute of suggestion.
static final String GEO_POINT_URI
Class representing suggestion of annotation.
String getXmlAttributeName()