8 package cz.vutbr.fit.knot.annotations.entity.attribute;
14 import java.util.Iterator;
15 import java.util.List;
16 import java.util.logging.Level;
17 import java.util.logging.Logger;
18 import javax.persistence.DiscriminatorValue;
19 import javax.persistence.Entity;
20 import javax.persistence.NamedQueries;
21 import javax.persistence.NamedQuery;
22 import javax.persistence.Transient;
36 @DiscriminatorValue(value =
"AnnotationLink")
38 @NamedQuery(name =
"Attribute.findByLinked", query =
"SELECT a FROM Attribute a WHERE a.linked = :linked"),})
43 private String tmpId = null;
54 this.uri = this.linkedAnnotation.getURI();
55 this.linked = linkedAnnotation.getId();
57 this.linkedAnnotation = null;
70 return this.linkedAnnotation;
82 StringBuilder result =
new StringBuilder();
84 if(linkedAnnotation != null){
86 result.append(
"<trix:uri>");
87 result.append(linkedAnnotation.getURIV2());
88 result.append(
"</trix:uri>");
89 result.append(
"</trix:triple>");
92 result.append(
"<trix:triple>");
93 result.append(
"<trix:uri>");
94 result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
95 result.append(
"</trix:uri>");
98 if (ontologyUri == null || ontologyUri.isEmpty()) {
99 result.append(
"<trix:name>");
100 result.append(this.name);
101 result.append(
"</trix:name>");
103 result.append(
"<trix:uri>");
104 result.append(ontologyUri);
105 result.append(
"</trix:uri>");
109 result.append(
"<trix:uri>");
110 result.append(
"koae:linkedAnnotation");
111 result.append(
"</trix:uri>");
112 result.append(
"</trix:triple>");
115 result.append(
"<trix:triple>");
116 result.append(
"<trix:uri>");
117 result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
118 result.append(
"</trix:uri>");
121 if (ontologyUri == null || ontologyUri.isEmpty()) {
122 result.append(
"<trix:name>");
123 result.append(this.name);
124 result.append(
"</trix:name>");
126 result.append(
"<trix:uri>");
127 result.append(ontologyUri);
128 result.append(
"</trix:uri>");
132 result.append(
"<trix:uri>");
133 result.append(linkedAnnotation.getAnnotType().getUri());
134 result.append(
"</trix:uri>");
135 result.append(
"</trix:triple>");
138 result.append(
"<trix:uri>");
139 result.append(getAttributeType().getUri());
140 result.append(
"</trix:uri>");
142 result.append(
"</trix:triple>");
145 result.append(
"<trix:triple>");
146 result.append(
"<trix:uri>");
147 result.append(this.refAnnotation.getSource()).append(this.refAnnotation.getFragmentXpointersV2());
148 result.append(
"</trix:uri>");
151 if(ontologyUri == null || ontologyUri.isEmpty()){
152 result.append(
"<trix:name>");
153 result.append(this.name);
154 result.append(
"</trix:name>");
156 result.append(
"<trix:uri>");
157 result.append(ontologyUri);
158 result.append(
"</trix:uri>");
163 result.append(
"<trix:uri>");
164 result.append(
"koae:linkedAnnotation");
165 result.append(
"</trix:uri>");
166 result.append(
"</trix:triple>");
169 return result.toString();
182 public String
toXMLString(
boolean proto11,
boolean tmpIdForNested,
boolean withOntology) {
183 String ontoString =
"";
186 if (getTypeOntologyUri() != null && !getTypeOntologyUri().isEmpty()) {
187 ontoString +=
" typeOntologyUri=\"" + getTypeOntologyUri() +
"\"";
190 Iterator<AnnotTypeAttr> typeAttrIt = refAnnotation.getAnnotType().getAttributes().iterator();
191 while (typeAttrIt.hasNext()) {
193 if (name.equals(actualAttr.
getName())) {
195 ontoString +=
" ontologyUri=\"" + actualAttr.getUriInOntology() +
"\"";
203 if(uri == null || uri.isEmpty()){
206 uriString =
" uri=\"" + uri +
"\"";
209 if (this.getValue() == null && tmpId != null) {
210 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"annotationLink\" tmpId=\""
211 + tmpId +
"\"" + getCommentXmlPart(proto11) +
">";
212 }
else if(this.getValue() == null){
213 if(attributeType != null){
214 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"" + attributeType.getUri() +
"\"" + uriString
215 + getCommentXmlPart(proto11) +
">";
218 String msg =
"Unknown type of attribute created.";
219 Logger.getLogger(LinkedAnnotationAttribute.class.getName()).log(Level.SEVERE, msg);
221 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"\"" + uriString
222 + getCommentXmlPart(proto11) +
">";
225 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"annotationLink\"" + uriString
226 + getCommentXmlPart(proto11) +
">";
236 public void setRawValue(String value)
throws IllegalArgumentException {
243 String annotIdStr = value.replace(AppBean.getBaseAnnotUri(),
"");
249 annotId = Integer.parseInt(annotIdStr);
251 catch (NumberFormatException nfe) {
256 if (annotId != null) {
258 Object[] params =
new Object[2];
261 List aList = AppBean.getPersistenceManager().queryDB(
"Annotation.findById", params);
264 if (aList != null && !aList.isEmpty()) {
266 this.linkedAnnotation = linkedAnnnot;
267 this.setAttributeType(linkedAnnnot.getAnnotType());
268 this.uri = linkedAnnnot.getURI();
298 if (this.attributeType != null) {
299 return this.attributeType.getUriInOntology();
String toXMLString(boolean proto11, boolean tmpIdForNested, boolean withOntology)
void setRawValue(String value)
Class representing attribute of type of annotation.
void setTmpId(String tmpId)
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
Singleton for storing global variables.
String getTypeOntologyUri()
Class representing attribute of type AnnotationLink.
Base class representing attribute of annotation.
static final int LOG_LEVEL
String getUriInOntology()
void setValue(Object value)
String toXMLStringWHV2(String ontologyUri)
Class representing annotation.