14 package cz.vutbr.fit.knot.annotations.entity;
 
   20 import java.io.Serializable;
 
   21 import javax.persistence.Basic;
 
   22 import javax.persistence.Column;
 
   23 import javax.persistence.Entity;
 
   24 import javax.persistence.GeneratedValue;
 
   25 import javax.persistence.GenerationType;
 
   26 import javax.persistence.Id;
 
   27 import javax.persistence.JoinColumn;
 
   28 import javax.persistence.Lob;
 
   29 import javax.persistence.ManyToOne;
 
   30 import javax.persistence.NamedQueries;
 
   31 import javax.persistence.NamedQuery;
 
   32 import javax.persistence.OneToOne;
 
   33 import javax.persistence.Table;
 
   42 @Table(name = 
"annotTypeAttr")
 
   44   @NamedQuery(name = 
"AnnotTypeAttr.findAll", query = 
"SELECT a FROM AnnotTypeAttr a"),
 
   45   @NamedQuery(name = 
"AnnotTypeAttr.findById", query = 
"SELECT a FROM AnnotTypeAttr a WHERE a.id = :id"),
 
   46   @NamedQuery(name = 
"AnnotTypeAttr.findByAnnotType", query = 
"SELECT a FROM AnnotTypeAttr a WHERE a.annotType = :annotType"),
 
   47   @NamedQuery(name = 
"AnnotTypeAttr.findByName", query = 
"SELECT a FROM AnnotTypeAttr a WHERE a.name = :name"),
 
   48   @NamedQuery(name = 
"AnnotTypeAttr.findBySimpleType", query = 
"SELECT a FROM AnnotTypeAttr a WHERE a.simpleType = :simpleType"),
 
   49   @NamedQuery(name = 
"AnnotTypeAttr.findByType", query = 
"SELECT a FROM AnnotTypeAttr a WHERE a.type = :type")})
 
   50 public class AnnotTypeAttr implements Serializable, Comparable<Object> {
 
   51   private static final long serialVersionUID = 1L;
 
   54   @GeneratedValue(strategy = GenerationType.IDENTITY)
 
   55   @Basic(optional = 
false)
 
   59   @Basic(optional = false)
 
   60   @Column(name = "annotType", nullable=false, insertable=false, updatable=false)
 
   61   private 
int annotType;
 
   63   @Basic(optional = false)
 
   64   @Column(name = "name")
 
   67   @Column(name = "simpleType")
 
   68   private String simpleType;
 
   72   @Basic(optional = true)
 
   73   @Column(name = "type", insertable=false, updatable=false)
 
   76   @Basic(optional = false)
 
   77   @Column(name = "required")
 
   78   private Boolean required;
 
   80   @Basic(optional = true)
 
   81   @Column(name = "uriInOntology")
 
   82   private String uriInOntology;
 
   84   @Basic(optional = true)
 
   86   @Column(name = "commentary")
 
   87   private String comment;
 
   89   @Column(name = "priority")
 
   90   protected Integer priority;
 
   93   @ManyToOne(optional = false)
 
   94   @JoinColumn(name = "annotType", referencedColumnName = "
id")
 
   97   @OneToOne(optional = true)
 
   98   @JoinColumn(name = "type", referencedColumnName = "
id")
 
  125     this.annotationType = annotationType;
 
  127     this.simpleType = simpleType;
 
  129     this.attributeType = null;
 
  130     this.required = required;
 
  131     this.uriInOntology = null;
 
  145     this.annotationType = annotationType;
 
  147     this.simpleType = simpleType;
 
  149     this.attributeType = null;
 
  150     this.required = required;
 
  151     this.uriInOntology = null;
 
  153     this.priority = priority;
 
  165     this.annotationType = annotationType;
 
  167     this.simpleType = null;
 
  168     this.type = structuredType.getId();
 
  169     this.attributeType = structuredType;
 
  170     this.required = required;
 
  171     this.uriInOntology = null;
 
  182     this.name = annotTypeAttr.getName();
 
  183     this.simpleType = annotTypeAttr.getSimpleType();
 
  184     this.type = annotTypeAttr.getType();
 
  185     this.attributeType = annotTypeAttr.getAttributeType();
 
  186     this.required = annotTypeAttr.getRequired();
 
  187     this.uriInOntology = annotTypeAttr.getUriInOntology();
 
  188     this.comment = annotTypeAttr.getComment();
 
  224     this.annotType = annotType;
 
  260     this.simpleType = simpleType;
 
  289     return annotationType;
 
  298     this.annotationType = annotationType;
 
  308     return attributeType;
 
  317     this.attributeType = attributeType;
 
  335     this.required = required;
 
  344     return uriInOntology;
 
  353     this.uriInOntology = uriInOntology;
 
  371     this.comment = comment;
 
  389     this.priority = priority;
 
  405       throw new UnsupportedOperationException(
"Not supported yet.");
 
  407     AnnotTypeAttr other = (AnnotTypeAttr) o;
 
  408     if (this.priority == null && other.
getPriority() == null) {
 
  411     if (this.priority == null && other.
getPriority() != null) {
 
  414     if (this.priority != null && other.
getPriority() == null) {
 
  417     return this.priority.compareTo(other.getPriority());
 
  423     hash += (
id != null ? id.hashCode() : 0);
 
  439     AnnotTypeAttr other = (AnnotTypeAttr) 
object;
 
  440     if ((this.
id == null && other.
id != null) || (this.id != null && !this.id.equals(other.id))) {
 
  457     if (getClass() != obj.getClass()) {
 
  464     if ((this.name == null) ? (other.name != null) : !this.name.equals(other.
name)) {
 
  467     if ((this.simpleType == null) ? (other.simpleType != null) : !this.simpleType.equals(other.
simpleType)) {
 
  470     if (this.type != other.
type && (
this.type == null || !
this.type.equals(other.
type))) {
 
  473     if (this.required != other.
required && (
this.required == null || !
this.required.equals(other.
required))) {
 
  476     if (this.annotationType != other.
annotationType && (
this.annotationType == null || !
this.annotationType.equals(other.
annotationType))) {
 
  479     if (this.attributeType != other.
attributeType && (
this.attributeType == null || !
this.attributeType.equals(other.
attributeType))) {
 
  482     if (this.comment == null ? other.
comment != null : !
this.comment.equals(other.
comment)) {
 
  485     if (this.priority == null ? other.
priority != null : !
this.priority.equals(other.
priority)) {
 
  493     return "cz.vutbr.fit.knot.annotations.entity.AnnotTypeAttr[id=" + 
id + 
",name=" + name + 
",simpleType=" + simpleType + 
",type=" + type + 
"]";
 
  505       rq = 
" required=\"true\"";
 
  507     String serializedCom = 
"/";
 
  508     if (withComment && comment != null && !comment.isEmpty()) {
 
  509       serializedCom = 
"><a:comment>" 
  513                     + 
"</a:comment></a:attribute";
 
  517         BaseAttribute buf = AttributeManager.createAttribute(name, simpleType, null);
 
  519             return "<a:attribute name=\"" + name + 
"\" type=\"" + buf.
getSimpleType() + 
"\"" + rq + serializedCom + 
">";
 
  521     } 
catch (ClassNotFoundException e) {
 
  533     if (simpleType == null || simpleType.isEmpty()) {
 
  536         rq = 
" required=\"true\"";
 
  538       String serializedCom = 
"/";
 
  539       if (withComment && comment != null && !comment.isEmpty()) {
 
  540         serializedCom = 
"><a:comment>" 
  544         + 
"</a:comment></a:attribute";
 
  546       return "<a:attribute name=\"" + name + 
"\" type=\"" + attributeType.getUri() 
 
  547              + 
"\"" + rq + serializedCom + 
">";
 
  549     return simpleTypeToString(withComment);
 
  558     if (this.simpleType == null) {
 
  561     if(this.simpleType.equalsIgnoreCase(
"annotationLink")){
 
  563     } 
else if (this.simpleType.equalsIgnoreCase(
"nestedAnnotation")) {
 
  576     int typeIndex = Constants.SIMPLE_TYPES_NAMES_V2.indexOf(simpleType);
 
  577     if (typeIndex != -1) {
 
  578       return Constants.SIMPLE_TYPES_URI_V2.get(typeIndex);
 
  580       return this.attributeType.getUri();
 
  591     StringBuilder serializedAnnotTypeAttr = 
new StringBuilder();
 
  594     StringBuilder serializedCom = null;
 
  595     if (withComment && this.comment != null && !this.comment.isEmpty()) {
 
  596       serializedCom = 
new StringBuilder();
 
  597       serializedCom.append(
"<comment><![CDATA[");
 
  598       serializedCom.append(this.comment);
 
  599       serializedCom.append(
"]]></comment>");
 
  602     if (simpleType != null && !simpleType.isEmpty()) {
 
  604       serializedAnnotTypeAttr.append(
"<attribute valueType=\"");
 
  605       serializedAnnotTypeAttr.append(getValueType());
 
  606       serializedAnnotTypeAttr.append(
"\" name=\"");
 
  607       serializedAnnotTypeAttr.append(this.name);
 
  608       serializedAnnotTypeAttr.append(
"\" typeUri=\"");
 
  609       serializedAnnotTypeAttr.append(getTypeUriV2());
 
  610       serializedAnnotTypeAttr.append(
"\" required=\"");
 
  611       serializedAnnotTypeAttr.append(this.required.toString());
 
  612       serializedAnnotTypeAttr.append(
"\"");
 
  613       if(this.uriInOntology != null && !this.uriInOntology.isEmpty()){
 
  614         serializedAnnotTypeAttr.append(
" ontologyUri=\"");
 
  615         serializedAnnotTypeAttr.append(this.uriInOntology);
 
  616         serializedAnnotTypeAttr.append(
"\"");
 
  618       if(serializedCom == null){
 
  619         serializedAnnotTypeAttr.append(
"/>");
 
  621         serializedAnnotTypeAttr.append(
">");
 
  622         serializedAnnotTypeAttr.append(serializedCom.toString());
 
  623         serializedAnnotTypeAttr.append(
"</attribute>");
 
  626       return serializedAnnotTypeAttr.toString();
 
  629       serializedAnnotTypeAttr.append(
"<attribute valueType=\"");
 
  630       serializedAnnotTypeAttr.append(getValueType());
 
  631       serializedAnnotTypeAttr.append(
"\" name=\"");
 
  632       serializedAnnotTypeAttr.append(this.name);
 
  633       serializedAnnotTypeAttr.append(
"\" typeUri=\"");
 
  634       serializedAnnotTypeAttr.append(this.attributeType.getUri());
 
  635       serializedAnnotTypeAttr.append(
"\" required=\"");
 
  636       serializedAnnotTypeAttr.append(this.required.toString());
 
  637       serializedAnnotTypeAttr.append(
"\"");
 
  638       if(this.uriInOntology != null && !this.uriInOntology.isEmpty()){
 
  639         serializedAnnotTypeAttr.append(
" ontologyUri=\"");
 
  640         serializedAnnotTypeAttr.append(this.uriInOntology);
 
  641         serializedAnnotTypeAttr.append(
"\"");
 
  643       if(serializedCom == null){
 
  644         serializedAnnotTypeAttr.append(
"/>");
 
  646         serializedAnnotTypeAttr.append(
">");
 
  647         serializedAnnotTypeAttr.append(serializedCom.toString());
 
  648         serializedAnnotTypeAttr.append(
"</attribute>");
 
  651       return serializedAnnotTypeAttr.toString();
 
String toXMLString(boolean withComment)
boolean equals(Object object)
void setUriInOntology(String uriInOntology)
void setSimpleType(String simpleType)
Class representing attribute of type of annotation. 
boolean contentEquals(Object obj)
void setPriority(Integer priority)
String simpleTypeToString(boolean withComment)
void setComment(String comment)
AnnotTypeAttr(AnnotTypeAttr annotTypeAttr)
AnnotType getAnnotationType()
AnnotType getAttributeType()
AnnotTypeAttr(AnnotType annotationType, String name, String simpleType, Boolean required, Integer priority)
Class representing attribute of type AnyAnnotation. 
void setRequired(Boolean required)
void setAnnotType(int annotType)
String toXMLStringV2(boolean withComment)
Base class representing attribute of annotation. 
Class representing type of annotation. 
void setAttributeType(AnnotType attributeType)
AnnotTypeAttr(AnnotType annotationType, String name, AnnotType structuredType, Boolean required)
void setName(String name)
String getUriInOntology()
void setAnnotationType(AnnotType annotationType)
Class attribute manager provides a way how to create new attributes. 
void setType(Integer type)
AnnotTypeAttr(Integer id)
AnnotTypeAttr(AnnotType annotationType, String name, String simpleType, Boolean required)