8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
 
   15 import java.util.Iterator;
 
   16 import java.util.List;
 
   17 import java.util.logging.Level;
 
   18 import java.util.logging.Logger;
 
   19 import javax.persistence.DiscriminatorValue;
 
   20 import javax.persistence.Entity;
 
   21 import javax.persistence.NamedQueries;
 
   22 import javax.persistence.NamedQuery;
 
   23 import javax.persistence.Transient;
 
   37 @DiscriminatorValue(value = 
"SuggestionLink")
 
   39   @NamedQuery(name = 
"SuggestionAttribute.findByLinked", query = 
"SELECT a FROM SuggestionAttribute a WHERE a.linkedSugg = :linked"),})
 
   44   private String tmpId = null;
 
   57           this.linkedSuggestion = (Suggestion) value;
 
   58           this.uri = this.linkedSuggestion.getURI();
 
   59           this.linkedSugg = linkedSuggestion.getId();
 
   60           this.linkedAnnot = null;
 
   61           this.linkedAnnotation = null;
 
   63           this.linkedAnnotation = (Annotation) value;
 
   64           this.uri = this.linkedAnnotation.getURI();
 
   65           this.linkedAnnot = linkedAnnotation.getId();
 
   66           this.linkedSugg = null;
 
   67           this.linkedSuggestion = null;
 
   70         this.linkedSuggestion = null;
 
   72         this.linkedSugg = null;
 
   73         this.linkedAnnotation = null;
 
   75         this.linkedAnnot = null;
 
   86     if(this.linkedSuggestion != null){
 
   87       return this.linkedSuggestion;
 
   88     }
else if(this.linkedAnnotation != null){
 
   89       return this.linkedAnnotation;
 
  103   public String 
toXMLString(
boolean proto11, 
boolean withOntology) {
 
  104     String ontoString = 
"";
 
  107       if (getTypeOntologyUri() != null && !getTypeOntologyUri().isEmpty()) {
 
  108         ontoString += 
" typeOntologyUri=\"" + getTypeOntologyUri() + 
"\"";
 
  111       Iterator<AnnotTypeAttr> typeAttrIt = refSuggestion.getAnnotType().getAttributes().iterator();
 
  112       while (typeAttrIt.hasNext()) {
 
  114         if (name.equals(actualAttr.
getName())) {
 
  116             ontoString += 
" ontologyUri=\"" + actualAttr.getUriInOntology() + 
"\"";
 
  123     if(uri == null || uri.isEmpty()){
 
  126       uriString = 
" uri=\"" + uri + 
"\"";
 
  129     if (this.getValue() == null && tmpId != null) {
 
  130       return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"annotationLink\" tmpId=\"" 
  131               + tmpId + 
"\"" + getCommentXmlPart(proto11) + 
">";
 
  133       if(this.linkedSuggestion != null){
 
  135         return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"annotationLink\" tmpId=\"" 
  136                 + linkedSuggestion.getId().toString() + 
"\"" + getCommentXmlPart(proto11) + 
">";
 
  137       }
else if(this.linkedAnnotation != null){
 
  139         return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"annotationLink\" uri=\"" 
  140                 + linkedAnnotation.getURI() + 
"\"" + getCommentXmlPart(proto11) + 
">";
 
  143         if(attributeType != null){
 
  144           return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"" + attributeType.getUri() + 
"\"" + uriString  
 
  145                  + getCommentXmlPart(proto11) + 
">";
 
  149             String msg = 
"Unknown type of attribute created.";
 
  150             Logger.getLogger(SugLinkedAttribute.class.getName()).log(Level.SEVERE, msg);
 
  152           return "<a:attribute name=\"" + name + 
"\"" + ontoString + 
" type=\"\"" + uriString  
 
  153                    + getCommentXmlPart(proto11) + 
">";
 
  168     StringBuilder result = 
new StringBuilder();
 
  171     if(this.linkedAnnotation != null){
 
  173       result.append(
"<trix:uri>");
 
  174       result.append(linkedAnnotation.getURIV2());
 
  175       result.append(
"</trix:uri>");
 
  176       result.append(
"</trix:triple>");
 
  179       result.append(
"<trix:triple>");
 
  180       result.append(
"<trix:uri>");
 
  181       result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
 
  182       result.append(
"</trix:uri>");
 
  185       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  186         result.append(
"<trix:name>");
 
  187         result.append(this.name);
 
  188         result.append(
"</trix:name>");
 
  190         result.append(
"<trix:uri>");
 
  191         result.append(ontologyUri);
 
  192         result.append(
"</trix:uri>");
 
  196       result.append(
"<trix:uri>");
 
  197       result.append(
"koae:linkedAnnotation");
 
  198       result.append(
"</trix:uri>");
 
  199       result.append(
"</trix:triple>");
 
  202       result.append(
"<trix:triple>");
 
  203       result.append(
"<trix:uri>");
 
  204       result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
 
  205       result.append(
"</trix:uri>");
 
  208       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  209         result.append(
"<trix:name>");
 
  210         result.append(this.name);
 
  211         result.append(
"</trix:name>");
 
  213         result.append(
"<trix:uri>");
 
  214         result.append(ontologyUri);
 
  215         result.append(
"</trix:uri>");
 
  219       result.append(
"<trix:uri>");
 
  220       result.append(linkedAnnotation.getAnnotType().getUri());
 
  221       result.append(
"</trix:uri>");
 
  222       result.append(
"</trix:triple>");
 
  227     }
else if (this.linkedSuggestion != null){
 
  229       result.append(
"<trix:uri>");
 
  230       result.append(linkedSuggestion.getURIV2());
 
  231       result.append(
"</trix:uri>");
 
  232       result.append(
"</trix:triple>");
 
  235       result.append(
"<trix:triple>");
 
  236       result.append(
"<trix:uri>");
 
  237       result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
 
  238       result.append(
"</trix:uri>");
 
  241       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  242         result.append(
"<trix:name>");
 
  243         result.append(this.name);
 
  244         result.append(
"</trix:name>");
 
  246         result.append(
"<trix:uri>");
 
  247         result.append(ontologyUri);
 
  248         result.append(
"</trix:uri>");
 
  252       result.append(
"<trix:uri>");
 
  253       result.append(
"koae:linkedAnnotation");
 
  254       result.append(
"</trix:uri>");
 
  255       result.append(
"</trix:triple>");
 
  258       result.append(
"<trix:triple>");
 
  259       result.append(
"<trix:uri>");
 
  260       result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
 
  261       result.append(
"</trix:uri>");
 
  264       if (ontologyUri == null || ontologyUri.isEmpty()) {
 
  265         result.append(
"<trix:name>");
 
  266         result.append(this.name);
 
  267         result.append(
"</trix:name>");
 
  269         result.append(
"<trix:uri>");
 
  270         result.append(ontologyUri);
 
  271         result.append(
"</trix:uri>");
 
  275       result.append(
"<trix:uri>");
 
  276       result.append(linkedSuggestion.getAnnotType().getUri());
 
  277       result.append(
"</trix:uri>");
 
  278       result.append(
"</trix:triple>");
 
  283       result.append(
"<trix:uri>");
 
  284       result.append(getAttributeType().getUri());
 
  285       result.append(
"</trix:uri>");
 
  287       result.append(
"</trix:triple>");
 
  290       result.append(
"<trix:triple>");
 
  291       result.append(
"<trix:uri>");
 
  292       result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
 
  293       result.append(
"</trix:uri>");
 
  296       if(ontologyUri == null || ontologyUri.isEmpty()){
 
  297         result.append(
"<trix:name>");
 
  298         result.append(this.name);
 
  299         result.append(
"</trix:name>");
 
  301         result.append(
"<trix:uri>");
 
  302         result.append(ontologyUri);
 
  303         result.append(
"</trix:uri>");
 
  308       result.append(
"<trix:uri>");
 
  309       result.append(
"koae:linkedAnnotation");
 
  310       result.append(
"</trix:uri>");
 
  311       result.append(
"</trix:triple>");
 
  314     return result.toString();
 
  323   public void setRawValue(String value) 
throws IllegalArgumentException {
 
  330     String annotIdStr = value.replace(AppBean.getBaseAnnotUri(), 
"");
 
  336       annotId = Integer.parseInt(annotIdStr);
 
  338     catch (NumberFormatException nfe) {
 
  343     if (annotId != null) {
 
  345       Object[] params = 
new Object[2];
 
  348       List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById", params);
 
  351       if (aList != null && !aList.isEmpty()) {
 
  353         this.linkedSuggestion = linkedSugg;
 
  354         this.setAttributeType(linkedSugg.getAnnotType());
 
  355         this.uri = linkedSugg.getURI();
 
  385     if (this.attributeType != null) {
 
  386       return this.attributeType.getUriInOntology();
 
String toXMLString(boolean proto11, boolean withOntology)
void setRawValue(String value)
void setTmpId(String tmpId)
Class representing attribute of type of annotation. 
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
Singleton for storing global variables. 
Class representing attribute of suggestion. 
void setValue(Object value)
static final int LOG_LEVEL
Class representing attribute of type AnnotationLink for prupose of suggestion. 
String getTypeOntologyUri()
String getUriInOntology()
String toXMLStringWHV2(String ontologyUri)
Class representing suggestion of annotation. 
Class representing annotation.