8 package cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes;
15 import java.util.Iterator;
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;
35 @DiscriminatorValue(
"NestedSuggestion")
37 @NamedQuery(name =
"SuggestionAttribute.findByNested", query =
"SELECT a FROM SuggestionAttribute a WHERE a.nestedSugg = :nested"),
55 this.simpleType =
"NestedSuggestion";
56 this.nestedSuggestion = nestedSuggestion;
57 this.refSuggestion = refSuggestion;
67 if(this.nestedSuggestion != null){
68 return this.nestedSuggestion;
69 }
else if(this.nestedAnnotation != null){
70 return this.nestedAnnotation;
84 this.nestedSuggestion = (Suggestion) value;
85 this.simpleType =
"NestedSuggestion";
86 this.nestedAnnotation = null;
88 this.nestedAnnotation = (Annotation) value;
89 this.simpleType =
"NestedAnnotation";
90 this.nestedSuggestion = null;
92 this.nestedSuggestion = null;
93 this.nestedAnnotation = null;
106 public void setRawValue(String value)
throws IllegalArgumentException {
107 throw new UnsupportedOperationException(
"Server internal error.");
118 public String
toXMLString(
boolean proto11,
boolean withOntology) {
122 String ontoString =
"";
123 if (proto11 && comment != null && !comment.isEmpty()) {
124 sCom =
"><a:comment>"
128 +
"</a:comment></a:attribute";
129 sCom2 =
"<a:comment>"
137 if(!getTypeOntologyUri().isEmpty()){
138 ontoString +=
" typeOntologyUri=\""+getTypeOntologyUri()+
"\"";
141 Iterator<AnnotTypeAttr> typeAttrIt = refSuggestion.getAnnotType().getAttributes().iterator();
142 while(typeAttrIt.hasNext()){
144 if(name.equals(actualAttr.
getName())){
146 ontoString +=
" ontologyUri=\"" + actualAttr.getUriInOntology() +
"\"";
152 if (nestedSuggestion == null) {
153 if (attributeType != null) {
154 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"" + attributeType.getUri() +
"\"" + sCom +
">";
158 String msg =
"Unknown type of attribute created.";
159 Logger.getLogger(NestedAnnotationAttribute.class.getName()).log(Level.SEVERE, msg);
161 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"\"" + sCom +
">";
166 if(nestedSuggestion.getTmpId() != null){
167 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"nestedAnnotation\" "
168 +
"tmpId=\"" + nestedSuggestion.getTmpId() +
"\">"
174 return "<a:attribute name=\"" + name +
"\"" + ontoString +
" type=\"nestedAnnotation\" "
175 +
"tmpId=\"" + nestedSuggestion.getId() +
"\">"
176 + nestedSuggestion.toXMLString(
false,
"", proto11)
191 StringBuilder result =
new StringBuilder();
194 if(this.nestedAnnotation != null){
196 result.append(
"<trix:uri>");
197 result.append(this.nestedAnnotation.getURIV2());
198 result.append(
"</trix:uri>");
199 result.append(
"</trix:triple>");
202 result.append(
"<trix:triple>");
204 result.append(
"<trix:uri>");
205 result.append(this.nestedAnnotation.getURIV2());
206 result.append(
"</trix:uri>");
208 result.append(
"<trix:uri>koae:nestedIn</trix:uri>");
210 result.append(
"<trix:uri>");
211 result.append(this.refSuggestion.getURIV2());
212 result.append(
"</trix:uri>");
214 result.append(
"</trix:triple>");
218 result.append(
"<trix:triple>");
219 result.append(
"<trix:uri>");
220 result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
221 result.append(
"</trix:uri>");
223 if (ontologyUri == null || ontologyUri.isEmpty()) {
224 result.append(
"<trix:name>");
225 result.append(this.name);
226 result.append(
"</trix:name>");
228 result.append(
"<trix:uri>");
229 result.append(ontologyUri);
230 result.append(
"</trix:uri>");
233 result.append(
"<trix:uri>");
234 result.append(this.refSuggestion.getAnnotType().getUri());
235 result.append(
"</trix:uri>");
237 result.append(
"</trix:triple>");
241 result.append(
"<trix:triple>");
242 result.append(
"<trix:uri>");
243 result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
244 result.append(
"</trix:uri>");
247 if (ontologyUri == null || ontologyUri.isEmpty()) {
248 result.append(
"<trix:name>");
249 result.append(this.name);
250 result.append(
"</trix:name>");
252 result.append(
"<trix:uri>");
253 result.append(ontologyUri);
254 result.append(
"</trix:uri>");
258 result.append(
"<trix:uri>");
259 result.append(
"koae:nestedAnnotation");
260 result.append(
"</trix:uri>");
261 result.append(
"</trix:triple>");
266 else if(this.nestedSuggestion != null){
268 result.append(
"<trix:uri>");
269 result.append(this.nestedSuggestion.getURIV2());
270 result.append(
"</trix:uri>");
271 result.append(
"</trix:triple>");
274 result.append(
"<trix:triple>");
276 result.append(
"<trix:uri>");
277 result.append(this.nestedSuggestion.getURIV2());
278 result.append(
"</trix:uri>");
280 result.append(
"<trix:uri>koae:nestedIn</trix:uri>");
282 result.append(
"<trix:uri>");
283 result.append(this.refSuggestion.getURIV2());
284 result.append(
"</trix:uri>");
286 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>");
295 if (ontologyUri == null || ontologyUri.isEmpty()) {
296 result.append(
"<trix:name>");
297 result.append(this.name);
298 result.append(
"</trix:name>");
300 result.append(
"<trix:uri>");
301 result.append(ontologyUri);
302 result.append(
"</trix:uri>");
305 result.append(
"<trix:uri>");
306 result.append(this.refSuggestion.getAnnotType().getUri());
307 result.append(
"</trix:uri>");
309 result.append(
"</trix:triple>");
313 result.append(
"<trix:triple>");
314 result.append(
"<trix:uri>");
315 result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
316 result.append(
"</trix:uri>");
319 if (ontologyUri == null || ontologyUri.isEmpty()) {
320 result.append(
"<trix:name>");
321 result.append(this.name);
322 result.append(
"</trix:name>");
324 result.append(
"<trix:uri>");
325 result.append(ontologyUri);
326 result.append(
"</trix:uri>");
330 result.append(
"<trix:uri>");
331 result.append(
"koae:nestedAnnotation");
332 result.append(
"</trix:uri>");
333 result.append(
"</trix:triple>");
339 result.append(
"<trix:uri>");
340 if(getAttributeType() == null){
344 result.append(getAttributeType().getUri());
346 result.append(
"</trix:uri>");
347 result.append(
"</trix:triple>");
350 result.append(
"<trix:triple>");
351 result.append(
"<trix:uri>");
352 result.append(this.refSuggestion.getSource()).append(this.refSuggestion.getFragmentXpointersV2());
353 result.append(
"</trix:uri>");
356 if (ontologyUri == null || ontologyUri.isEmpty()) {
357 result.append(
"<trix:name>");
358 result.append(this.name);
359 result.append(
"</trix:name>");
361 result.append(
"<trix:uri>");
362 result.append(ontologyUri);
363 result.append(
"</trix:uri>");
367 result.append(
"<trix:uri>");
368 result.append(
"koae:nestedAnnotation");
369 result.append(
"</trix:uri>");
370 result.append(
"</trix:triple>");
373 return result.toString();
383 if(this.attributeType != null)
385 return this.attributeType.getUriInOntology();
String toXMLString(boolean withComment)
void setValue(Object value)
SugNestedAttribute(String name, Suggestion nestedSuggestion, Suggestion refSuggestion)
Class representing attribute of type of annotation.
String toXMLString(boolean proto11, boolean withOntology)
Class representing attribute of type NestedAnnotation for peupose of suggestion.
Class representing attribute of type NestedAnnotation.
static final int LOG_LEVEL_SERVER_INTERNAL_ERRORS
Class representing attribute of suggestion.
String getTypeOntologyUri()
static final int LOG_LEVEL
String getUriInOntology()
void setRawValue(String value)
Class representing suggestion of annotation.
String toXMLStringWHV2(String ontologyUri)
Class representing annotation.