15 package cz.vutbr.fit.knot.annotations.entity.attribute;
19 import java.io.Serializable;
20 import java.util.logging.Level;
21 import java.util.logging.Logger;
22 import javax.persistence.Basic;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.ManyToOne;
30 import javax.persistence.NamedQueries;
31 import javax.persistence.NamedQuery;
32 import javax.persistence.Table;
33 import javax.validation.constraints.NotNull;
34 import javax.validation.constraints.Size;
35 import javax.xml.bind.annotation.XmlRootElement;
44 @Table(name =
"entityAdditionalAttribute")
47 @NamedQuery(name =
"EntityAdditionalAttribute.findAll", query =
"SELECT e FROM EntityAdditionalAttribute e"),
48 @NamedQuery(name =
"EntityAdditionalAttribute.findById", query =
"SELECT e FROM EntityAdditionalAttribute e WHERE e.id = :id"),
49 @NamedQuery(name =
"EntityAdditionalAttribute.findByName", query =
"SELECT e FROM EntityAdditionalAttribute e WHERE e.name = :name"),
50 @NamedQuery(name =
"EntityAdditionalAttribute.findByStringValue", query =
"SELECT e FROM EntityAdditionalAttribute e WHERE e.stringValue = :stringValue"),
51 @NamedQuery(name =
"EntityAdditionalAttribute.findByEntity", query =
"SELECT e FROM EntityAdditionalAttribute e WHERE e.entityId = :entity")})
53 private static final long serialVersionUID = 1L;
57 @GeneratedValue(strategy = GenerationType.IDENTITY)
58 @Basic(optional =
false)
63 @Basic(optional = false)
65 @Size(min = 1, max = 255)
66 @Column(name = "name")
70 @Basic(optional = false)
72 @Column(name = "type")
76 @Basic(optional = true)
77 @Size(min = 0, max = 255)
78 @Column(name = "stringValue")
79 private String stringValue;
82 @Column(name = "priority")
83 protected Integer priority;
86 @Basic(optional = false)
87 @Column(name = "entityId", nullable = false, insertable = false, updatable = false)
91 @ManyToOne(optional = false)
92 @JoinColumn(name = "entityId", referencedColumnName = "
id")
121 this.stringValue = stringValue;
122 this.refEntityAttribute = refEntityAttribute;
134 this.stringValue = stringValue;
135 this.refEntityAttribute = refEntityAttribute;
149 this.stringValue = stringValue;
150 this.refEntityAttribute = refEntityAttribute;
222 this.stringValue = stringValue;
240 return refEntityAttribute;
249 this.refEntityAttribute = refEntityAttribute;
267 this.priority = priority;
277 int typeIndex = Constants.SIMPLE_TYPES_FOR_ENT_AD_AT.indexOf(type);
279 typeIndex = Constants.SIMPLE_TYPES_FOR_ENT_AD_AT.indexOf(
"String");
282 String msg =
"URI for string was not found!";
283 Logger.getLogger(EntityAdditionalAttribute.class.getName()).log(Level.SEVERE, msg);
289 typeURI = Constants.SIMPLE_TYPES_URIS_FOR_ENT_AD_AT.get(typeIndex);
291 StringBuilder result =
new StringBuilder();
292 result.append(
"<trix:triple><trix:uri>");
293 result.append(Util.toHTMLString(this.refEntityAttribute.getUri()));
294 result.append(
"</trix:uri><trix:name>");
295 result.append(Util.toHTMLString(name));
296 result.append(
"</trix:name><trix:typedLiteral datatype=\"").append(typeURI).append(
"\">");
297 result.append(Util.toHTMLString(stringValue));
298 result.append(
"</trix:typedLiteral></trix:triple>");
299 return result.toString();
312 int typeIndex = Constants.SIMPLE_TYPES_FOR_ENT_AD_AT.indexOf(type);
315 result =
"<" + name +
" type=\"" + Constants.SIMPLE_TYPES_URIS_FOR_ENT_AD_AT.get(typeIndex)
318 result =
"<" + name +
">" + Util.toHTMLString(stringValue) +
"</" + name +
">";
321 result =
"<" + name +
">" + Util.toHTMLString(stringValue) +
"</" + name +
">";
329 hash += (
id != null ? id.hashCode() : 0);
345 EntityAdditionalAttribute other = (EntityAdditionalAttribute)
object;
346 if ((this.
id == null && other.
id != null) || (this.id != null && !this.id.equals(other.id))) {
354 return "cz.vutbr.fit.knot.annotations.entity.attribute.EntityAdditionalAttribute[ id=" +
id +
" ]";
370 throw new UnsupportedOperationException(
"Not supported yet.");
372 EntityAdditionalAttribute other = (EntityAdditionalAttribute) o;
373 if (this.priority == null && other.
getPriority() == null) {
376 if (this.priority == null && other.
getPriority() != null) {
379 if (this.priority != null && other.
getPriority() == null) {
382 return this.priority.compareTo(other.getPriority());
void setStringValue(String stringValue)
void setPriority(Integer priority)
EntityAttribute getRefEntityAttribute()
Additional attribute of entity in annotation attribute.
void setType(String type)
Class representing vocabulary entity attribute.
String toXMLResponseStringV2()
boolean equals(Object object)
void setRefEntityAttribute(EntityAttribute refEntityAttribute)
void setName(String name)
EntityAdditionalAttribute(String name, String stringValue, EntityAttribute refEntityAttribute)
static final int LOG_LEVEL
static final String DEFAULT_SIMPLE_TYPE_FOR_ENT_AD_AT
EntityAdditionalAttribute(Integer id)
EntityAdditionalAttribute(String name, String type, String stringValue, EntityAttribute refEntityAttribute)
static final int LOG_LEVEL_SERVER_ERRORS
static String toHTMLString(String source)
EntityAdditionalAttribute(Integer id, String name, String stringValue, EntityAttribute refEntityAttribute)
Utility class (manipulates RFC 3339 dates)