8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
13 import java.text.SimpleDateFormat;
14 import java.util.Date;
15 import java.util.TimeZone;
16 import javax.persistence.DiscriminatorValue;
17 import javax.persistence.Entity;
18 import javax.persistence.NamedQueries;
19 import javax.persistence.NamedQuery;
33 @DiscriminatorValue(
"Date")
35 @NamedQuery(name =
"SuggestionAttribute.findByDateValue", query =
"SELECT a FROM SuggestionAttribute a WHERE a.dateValue = :dateValue"),
54 this.simpleType =
"Date";
55 this.dateValue = value;
56 this.refSuggestion = refSuggestion;
69 this.simpleType =
"Date";
70 this.dateValue = value;
71 this.refSuggestion = refSuggestion;
72 this.priority = priority;
81 public void setRawValue(String value)
throws IllegalArgumentException {
82 String zone = Util.parseTimeZoneID(value);
83 String originalOffset = TimeZone.getDefault().getID();
85 TimeZone.setDefault(TimeZone.getTimeZone(
"GMT" + zone));
86 this.stringValue = zone;
88 this.boolVAlue =
true;
91 this.dateValue = Util.parseDate(value);
92 }
catch (Exception e) {
94 this.dateValue = Util.parseRFC3339Date(value);
95 }
catch (Exception ex) {
97 SimpleDateFormat sdf =
new SimpleDateFormat(
"yyyy-MM-dd");
98 this.dateValue = sdf.parse(value);
99 }
catch (Exception exx) {
100 throw new IllegalArgumentException(
"Value " + value +
" is not a valid date");
105 TimeZone.setDefault(TimeZone.getTimeZone(originalOffset));
116 if(this.stringValue != null){
117 String originalOffset = TimeZone.getDefault().getID();
118 TimeZone.setDefault(TimeZone.getTimeZone(
"GMT" + this.stringValue));
119 String ret = Util.toRFC3339DateOnly(dateValue);
120 TimeZone.setDefault(TimeZone.getTimeZone(originalOffset));
123 if (this.boolVAlue != null && this.boolVAlue ==
true) {
124 return Util.toRFC3339DateOnlyWTZ(this.dateValue);
126 return Util.toRFC3339DateOnly(this.dateValue);
Class representing attribute of type Date for prupose of suggestion.
SugDateAttribute(String name, Date value, Suggestion refSuggestion, Integer priority)
SugDateAttribute(String name, Date value, Suggestion refSuggestion)
static final String DATE_URI
Class representing attribute of type DateTime prupose of suggestion.
void setRawValue(String value)
Class representing suggestion of annotation.
Utility class (manipulates RFC 3339 dates)
String getTypeOntologyUri()