4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
AnyAnnotationAttribute.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz, Jan Planer xplane01@stud.fit.vutbr.cz
4  * File: AnyAnnotationAttribute.java
5  * Description: Class representing attribute of type AnyAnnotation
6  */
7 
8 package cz.vutbr.fit.knot.annotations.entity.attribute;
9 
10 import javax.persistence.DiscriminatorValue;
11 import javax.persistence.Entity;
12 
13 /**
14  * @file AnyAnnotationAttribute.java
15  *
16  * @brief Class representing attribute of type AnyAnnotation
17  */
18 
19 /**
20  * Class representing attribute of type AnyAnnotation
21  *
22  * @brief Class representing attribute of type AnyAnnotation
23  */
24 @Entity
25 @DiscriminatorValue("AnyAnnotation")
26 public class AnyAnnotationAttribute extends BaseAttribute {
27 
28  /**
29  * Sets value of the attribute. Value should already be a native java value.
30  *
31  * @param value New value of the attribute
32  */
33  @Override
34  public void setValue(Object value) {
35  //return;
36  }
37 
38  /**
39  * Gets value of the attribute
40  *
41  * @return value of the attribute
42  */
43  @Override
44  public Object getValue() {
45  return null;
46  }
47 
48  /**
49  * Parses provided value and sets that value as a value of attribute
50  *
51  * AnyAnnotation can not have value
52  *
53  * @param value new value of the attribute in raw form from XML
54  */
55  @Override
56  public void setRawValue(String value) {
57  }
58 
59  /**
60  * Returns serialized informations about attribute of annotation in XML
61  * for protocol v. 2.0 without header (target and attribute specification
62  * triples)
63  *
64  * @param ontologyUri URI of attribute in ontology
65  * @return Returns serialized informations about attribute of annotation in XML
66  */
67  public String toXMLStringWHV2(String ontologyUri){
68  StringBuilder result = new StringBuilder();
69  if(getAttributeType() != null){
70  if(getTextValue().equals("koae:linkedAnnotation")){
71  // linked
72  result.append("<trix:uri>");
73  result.append(getAttributeType().getUri());
74  result.append("</trix:uri>");
75  // end of first trix
76  result.append("</trix:triple>");
77 
78  // serilize triple with document uri
79  result.append("<trix:triple>");
80  result.append("<trix:uri>");
81  result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
82  result.append("</trix:uri>");
83 
84  // serialize triple with name
85  if(ontologyUri == null || ontologyUri.isEmpty()){
86  result.append("<trix:name>");
87  result.append(this.name);
88  result.append("</trix:name>");
89  }else{
90  result.append("<trix:uri>");
91  result.append(ontologyUri);
92  result.append("</trix:uri>");
93  }
94 
95  // serialize triple with information about nesting
96  result.append("<trix:uri>");
97  result.append("koae:linkedAnnotation");
98  result.append("</trix:uri>");
99  result.append("</trix:triple>");
100  }else if(uri.equals("koae:nestedAnnotation")){
101  // nested
102  result.append("<trix:uri>");
103  result.append(getAttributeType().getUri());
104  result.append("</trix:uri>");
105  // end of first trix
106  result.append("</trix:triple>");
107 
108  // serilize triple with document uri
109  result.append("<trix:triple>");
110  result.append("<trix:uri>");
111  result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
112  result.append("</trix:uri>");
113 
114  // serialize triple with name
115 
116  if(ontologyUri == null || ontologyUri.isEmpty()){
117  result.append("<trix:name>");
118  result.append(this.name);
119  result.append("</trix:name>");
120  }else{
121  result.append("<trix:uri>");
122  result.append(ontologyUri);
123  result.append("</trix:uri>");
124  }
125 
126  // serialize triple with information about nesting
127  result.append("<trix:uri>");
128  result.append("koae:nestedAnnotation");
129  result.append("</trix:uri>");
130  result.append("</trix:triple>");
131  }
132  }else{
133  // only Any Annotation
134  result.append("<trix:typedLiteral datatype=\"http://knot.fit.vutbr.cz/annotations/knotOAExtension#anyAnnotation\"/>");
135  result.append("</trix:triple>");
136  }
137  return result.toString();
138  }
139 
140 } // class AnyAnnotationAttribute
Base class representing attribute of annotation.