8 package cz.vutbr.fit.knot.annotations.entity.attribute;
 
   13 import java.util.Iterator;
 
   14 import java.util.logging.Level;
 
   15 import java.util.logging.Logger;
 
   16 import javax.persistence.DiscriminatorValue;
 
   17 import javax.persistence.Entity;
 
   18 import javax.persistence.NamedQueries;
 
   19 import javax.persistence.NamedQuery;
 
   33 @DiscriminatorValue(
"NestedAnnotation")
 
   35     @NamedQuery(name = 
"Attribute.findByNested", query = 
"SELECT a FROM Attribute a WHERE a.nested = :nested"),
 
   54     this.simpleType = 
"NestedAnnotation";
 
   55     this.nestedAnnotation = nestedAnnotation;
 
   56     this.refAnnotation = refAnnotation;
 
   66     return this.nestedAnnotation;
 
   78       this.uri = this.nestedAnnotation.getURI();
 
   80       this.nestedAnnotation = null; 
 
   94   public void setRawValue(String value) 
throws IllegalArgumentException {
 
   95     throw new UnsupportedOperationException(
"Server internal error.");
 
  107   public String 
toXMLString(
boolean proto11, 
boolean tmpIdForNested, 
boolean withOntology) {
 
  111     String ontoString = 
"";
 
  112     if (proto11 && comment != null && !comment.isEmpty()) {
 
  113       sCom = 
"><a:comment>" 
  117               + 
"</a:comment></a:attribute";
 
  118       sCom2 = 
"<a:comment>" 
  126       if(!getTypeOntologyUri().isEmpty()){
 
  127         ontoString += 
" typeOntologyUri=\""+getTypeOntologyUri()+
"\"";
 
  130       Iterator<AnnotTypeAttr> typeAttrIt = refAnnotation.getAnnotType().getAttributes().iterator();
 
  131       while(typeAttrIt.hasNext()){
 
  133           if(name.equals(actualAttr.
getName())){
 
  135                 ontoString += 
" ontologyUri=\"" + actualAttr.getUriInOntology() + 
"\"";
 
  141     if (nestedAnnotation == null) {
 
  142       if (attributeType != null) {
 
  143         return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"" + attributeType.getUri() + 
"\"" + sCom + 
">";
 
  147           String msg = 
"Unknown type of attribute created.";
 
  148           Logger.getLogger(NestedAnnotationAttribute.class.getName()).log(Level.SEVERE, msg);
 
  150         return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"\"" + sCom + 
">";
 
  155     return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"nestedAnnotation\" " 
  156             + 
"tmpId=\"" + nestedAnnotation.getTmpId() + 
"\">" 
  157             + nestedAnnotation.
toXMLString(
false, 
"", proto11, tmpIdForNested)
 
  171     StringBuilder result = 
new StringBuilder();
 
  173     if(this.nestedAnnotation != null){
 
  175       result.append(
"<trix:uri>");
 
  176       result.append(this.nestedAnnotation.getURIV2());
 
  177       result.append(
"</trix:uri>");
 
  178       result.append(
"</trix:triple>");
 
  181       result.append(
"<trix:triple>");
 
  183       result.append(
"<trix:uri>");
 
  184       result.append(this.nestedAnnotation.getURIV2());
 
  185       result.append(
"</trix:uri>");
 
  187       result.append(
"<trix:uri>koae:nestedIn</trix:uri>");
 
  189       result.append(
"<trix:uri>");
 
  190       result.append(this.refAnnotation.getURIV2());
 
  191       result.append(
"</trix:uri>");
 
  193       result.append(
"</trix:triple>");
 
  197       result.append(
"<trix:triple>");
 
  198       result.append(
"<trix:uri>");
 
  199       result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
 
  200       result.append(
"</trix:uri>");
 
  202       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  203         result.append(
"<trix:name>");
 
  204         result.append(this.name);
 
  205         result.append(
"</trix:name>");
 
  207         result.append(
"<trix:uri>");
 
  208         result.append(ontologyUri);
 
  209         result.append(
"</trix:uri>");
 
  212       result.append(
"<trix:uri>");
 
  213       result.append(this.refAnnotation.getAnnotType().getUri());
 
  214       result.append(
"</trix:uri>");
 
  216       result.append(
"</trix:triple>");
 
  220       result.append(
"<trix:triple>");
 
  221       result.append(
"<trix:uri>");
 
  222       result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
 
  223       result.append(
"</trix:uri>");
 
  226       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  227         result.append(
"<trix:name>");
 
  228         result.append(this.name);
 
  229         result.append(
"</trix:name>");
 
  231         result.append(
"<trix:uri>");
 
  232         result.append(ontologyUri);
 
  233         result.append(
"</trix:uri>");
 
  237       result.append(
"<trix:uri>");
 
  238       result.append(
"koae:nestedAnnotation");
 
  239       result.append(
"</trix:uri>");
 
  240       result.append(
"</trix:triple>");
 
  243       result.append(
"<trix:uri>");
 
  244       if(getAttributeType() == null){
 
  248         result.append(getAttributeType().getUri());
 
  250       result.append(
"</trix:uri>");
 
  251       result.append(
"</trix:triple>");
 
  254       result.append(
"<trix:triple>");
 
  255       result.append(
"<trix:uri>");
 
  256       result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
 
  257       result.append(
"</trix:uri>");
 
  260       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  261         result.append(
"<trix:name>");
 
  262         result.append(this.name);
 
  263         result.append(
"</trix:name>");
 
  265         result.append(
"<trix:uri>");
 
  266         result.append(ontologyUri);
 
  267         result.append(
"</trix:uri>");
 
  271       result.append(
"<trix:uri>");
 
  272       result.append(
"koae:nestedAnnotation");
 
  273       result.append(
"</trix:uri>");
 
  274       result.append(
"</trix:triple>");
 
  277     return result.toString();
 
  287       if(this.attributeType != null)
 
  289         return this.attributeType.getUriInOntology();
 
String toXMLString(boolean withComment)
Class representing attribute of type of annotation. 
Class representing attribute of type NestedAnnotation. 
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
NestedAnnotationAttribute()
NestedAnnotationAttribute(String name, Annotation nestedAnnotation, Annotation refAnnotation)
void setValue(Object value)
Base class representing attribute of annotation. 
static final int LOG_LEVEL
String toXMLString(boolean proto11, boolean tmpIdForNested, boolean withOntology)
String getUriInOntology()
String getTypeOntologyUri()
void setRawValue(String value)
String toXMLStringWHV2(String ontologyUri)
Class representing annotation.