4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SugAnyAttribute.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: SugAnyAttribute.java
5  * Description: Class representing attribute of type AnyAnnotation for prupose of suggestion
6  */
7 
8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
9 
10 import javax.persistence.DiscriminatorValue;
11 import javax.persistence.Entity;
12 
13 /**
14  * @file SugAnyAttribute.java
15  *
16  * @brief Class representing attribute of type AnyAnnotation for prupose of suggestion
17  */
18 
19 /**
20  * Class representing attribute of type AnyAnnotation for prupose of suggestion
21  *
22  * @brief Class representing attribute of type AnyAnnotation for prupose of suggestion
23  */
24 @Entity
25 @DiscriminatorValue("AnyAnnotation")
26 public class SugAnyAttribute extends SugBaseAttribute{
27  /**
28  * Sets value of the attribute. Value should already be a native java value.
29  *
30  * @param value New value of the attribute
31  */
32  @Override
33  public void setValue(Object value) {
34  //return;
35  }
36 
37  /**
38  * Gets value of the attribute
39  *
40  * @return value of the attribute
41  */
42  @Override
43  public Object getValue() {
44  return null;
45  }
46 
47  /**
48  * Parses provided value and sets that value as a value of attribute
49  *
50  * AnyAnnotation can not have value
51  *
52  * @param value new value of the attribute in raw form from XML
53  */
54  @Override
55  public void setRawValue(String value) {
56  }
57 
58  /**
59  * Returns serialized informations about attribute of suggestion in XML for
60  * protocol v. 2.0 without header (target and attribute specification triples)
61  *
62  *
63  * @param ontologyUri URI of attribute in ontology
64  * @return Returns serialized informations about attribute of suggestion in XML
65  */
66  public String toXMLStringWHV2(String ontologyUri){
67  StringBuilder result = new StringBuilder();
68 
69  // only Any Annotation
70  result.append("<trix:typedLiteral datatype=\"http://knot.fit.vutbr.cz/annotations/knotOAExtension#anyAnnotation\"/>");
71  result.append("</trix:triple>");
72 
73  result.append("<trix:triple>");
74  result.append("<trix:uri>");
75  result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
76  result.append("</trix:uri>");
77 
78  // serialize triple with name
79  if(ontologyUri == null || ontologyUri.isEmpty()){
80  result.append("<trix:name>");
81  result.append(this.name);
82  result.append("</trix:name>");
83  }else{
84  result.append("<trix:uri>");
85  result.append(ontologyUri);
86  result.append("</trix:uri>");
87  }
88 
89  result.append("<trix:uri>");
90  result.append(this.uri);
91  result.append("</trix:uri>");
92  result.append("</trix:triple>");
93 
94  return result.toString();
95  }
96 } // public class SugAnyAttribute
Class representing attribute of type AnyAnnotation for prupose of suggestion.