13 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
29 import cz.vutbr.fit.knot.annotations.modules.suggestionManager.attributes.*;
30 import java.io.Serializable;
31 import java.text.SimpleDateFormat;
32 import java.util.ArrayList;
33 import java.util.Collections;
34 import java.util.Date;
35 import java.util.HashMap;
36 import java.util.Iterator;
37 import java.util.List;
38 import java.util.logging.Level;
39 import java.util.logging.Logger;
40 import javax.persistence.Basic;
41 import javax.persistence.CascadeType;
42 import javax.persistence.Column;
43 import javax.persistence.Entity;
44 import javax.persistence.GeneratedValue;
45 import javax.persistence.GenerationType;
46 import javax.persistence.Id;
47 import javax.persistence.JoinColumn;
48 import javax.persistence.Lob;
49 import javax.persistence.NamedQueries;
50 import javax.persistence.NamedQuery;
51 import javax.persistence.OneToMany;
52 import javax.persistence.OneToOne;
53 import javax.persistence.Table;
54 import javax.persistence.Temporal;
55 import javax.persistence.TemporalType;
56 import javax.persistence.Transient;
57 import javax.validation.constraints.NotNull;
58 import javax.validation.constraints.Size;
59 import javax.xml.bind.annotation.XmlRootElement;
68 @Table(name =
"suggestion")
71 @NamedQuery(name =
"Suggestion.findAll", query =
"SELECT s FROM Suggestion s"),
72 @NamedQuery(name =
"Suggestion.findById", query =
"SELECT s FROM Suggestion s WHERE s.id = :id"),
73 @NamedQuery(name =
"Suggestion.findByAlternativeOfAndNotSugg", query =
"SELECT s FROM Suggestion s WHERE s.alternativeOf = :alternativeOf AND s.id <> :notThisSugId"),
74 @NamedQuery(name =
"Suggestion.findByAlternativeOf", query =
"SELECT s FROM Suggestion s WHERE s.alternativeOf = :alternativeOf"),
75 @NamedQuery(name =
"Suggestion.findByType", query =
"SELECT s FROM Suggestion s WHERE s.type = :type"),
76 @NamedQuery(name =
"Suggestion.findByAuthorIdStr", query =
"SELECT s FROM Suggestion s WHERE s.authorIdStr = :authorIdStr"),
77 @NamedQuery(name =
"Suggestion.findByAuthorName", query =
"SELECT s FROM Suggestion s WHERE s.authorName = :authorName"),
78 @NamedQuery(name =
"Suggestion.findByAuthorAddress", query =
"SELECT s FROM Suggestion s WHERE s.authorAddress = :authorAddress"),
79 @NamedQuery(name =
"Suggestion.findBySource", query =
"SELECT s FROM Suggestion s WHERE s.source = :source"),
80 @NamedQuery(name =
"Suggestion.findBySourceDocId", query =
"SELECT s FROM Suggestion s WHERE s.sourceDocumentId = :sourceDocId"),
81 @NamedQuery(name =
"Suggestion.findForAlternatives", query =
"SELECT s FROM Suggestion s WHERE s.sourceDocumentId = :sourceDocId AND s.confidence >= :minCon AND s.alternativeOf IS NULL AND s.isFromSECAPI = TRUE"),
82 @NamedQuery(name =
"Suggestion.findBySourceDocIdNNConfid", query =
"SELECT s FROM Suggestion s WHERE s.sourceDocumentId = :sourceDocId AND s.confidence > 0"),
83 @NamedQuery(name =
"Suggestion.findBySourceDocument", query =
"SELECT s FROM Suggestion s WHERE s.sourceDocument = :sourceDocument"),
84 @NamedQuery(name =
"Suggestion.findByAutorId", query =
"SELECT s FROM Suggestion s WHERE s.autorId = :autorId"),
85 @NamedQuery(name =
"Suggestion.clearIsFromSECAPI", query =
"UPDATE Suggestion s SET s.isFromSECAPI = FALSE WHERE s.id = :id")
88 private static final long serialVersionUID = 1L;
91 @GeneratedValue(strategy = GenerationType.IDENTITY)
92 @Basic(optional =
false)
97 @Basic(optional = false)
99 @Column(name = "type", nullable=false, insertable=false, updatable=false)
103 @Basic(optional = true)
104 @Column(name = "created")
105 @Temporal(TemporalType.TIMESTAMP)
106 private Date created;
109 @Basic(optional = true)
110 @Size(min = 1, max = 255)
111 @Column(name = "authorIdStr")
112 private String authorIdStr;
116 @Column(name = "authorName")
117 private String authorName;
121 @Column(name = "authorAddress")
122 private String authorAddress;
125 @Basic(optional = false)
127 @Size(min = 1, max = 255)
128 @Column(name = "source")
129 private String source;
132 @Basic(optional = false)
134 @Column(name = "sourceDocumentId", nullable=false, insertable=false, updatable=false)
135 private
int sourceDocumentId;
138 @Basic(optional = false)
140 @Column(name = "content")
141 private String content;
144 @Basic(optional = false)
145 @Column(name = "confidence")
146 private Integer confidence;
149 @Basic(optional = false)
151 @Column(name = "displayConfidence")
152 private
boolean displayConfidence;
155 @Column(name = "authorId", insertable=false, updatable=false)
156 private String autorId;
159 @Column(name = "nestedIn", insertable=false, updatable=false)
160 private String nestedIn;
163 @Column(name = "alternativeOf", insertable=false, updatable=false)
164 private String alternativeOf;
167 @OneToOne(optional = false)
168 @JoinColumn(name = "type", referencedColumnName = "
id")
172 @OneToOne(optional = false)
173 @JoinColumn(name = "sourceDocumentId", referencedColumnName = "
id")
177 @OneToMany(mappedBy = "refSuggestion", cascade = CascadeType.ALL,
182 @OneToMany(mappedBy = "refSuggestion", cascade = CascadeType.ALL,
187 @OneToOne(optional = true)
188 @JoinColumn(name = "authorId", referencedColumnName = "
id")
192 @OneToOne(optional = true)
193 @JoinColumn(name = "nestedIn", referencedColumnName = "
id")
197 @OneToOne(optional = true)
198 @JoinColumn(name = "alternativeOf", referencedColumnName = "
id")
202 @Basic(optional = false)
204 @Column(name = "isFromSECAPI")
205 private
boolean isFromSECAPI;
208 @Basic(optional = true)
209 @Column(name = "SAEntityIdentifier")
210 private String SAEntityIdentifier;
214 private String tmpId;
242 this.updateWithAnnotationForDB(a);
243 isFromSECAPI =
false;
252 this.updateWithAlternativeForDB(a);
264 this.annotType = type;
265 this.content = content;
266 this.nestedIn = nestedIn;
267 this.attributes =
new ArrayList<SugBaseAttribute>();
268 this.fragments =
new ArrayList<SuggestionFragment>();
269 isFromSECAPI =
false;
270 displayConfidence =
false;
284 public Suggestion(Integer
id, String authorIdStr, String authorName, String authorAddress,
AnnotDocument sourceDocument, String content, String nestedIn) {
286 this.authorIdStr = authorIdStr;
287 this.authorName = authorName;
288 this.authorAddress = authorAddress;
289 this.sourceDocument = sourceDocument;
290 if (sourceDocument != null) {
291 this.source = sourceDocument.getUriForAnnot();
293 this.content = content;
294 this.nestedIn = nestedIn;
295 this.nestedInSuggestion = null;
296 this.attributes =
new ArrayList<SugBaseAttribute>();
297 this.fragments =
new ArrayList<SuggestionFragment>();
298 isFromSECAPI =
false;
299 displayConfidence =
false;
314 this.annotType = annotType;
315 this.created = created;
316 this.authorIdStr = authorIdStr;
317 this.authorName = authorName;
318 this.authorAddress = authorAddress;
319 this.sourceDocument = sourceDocument;
320 if (sourceDocument != null) {
321 this.source = sourceDocument.getUriForAnnot();
323 this.content = content;
324 this.nestedInSuggestion = null;
325 this.attributes =
new ArrayList<SugBaseAttribute>();
326 this.fragments =
new ArrayList<SuggestionFragment>();
327 isFromSECAPI =
false;
328 displayConfidence =
false;
344 this.annotType = annotType;
345 this.created = created;
346 this.authorIdStr = authorIdStr;
347 this.authorName = authorName;
348 this.authorAddress = authorAddress;
349 this.sourceDocument = sourceDocument;
350 if (sourceDocument != null) {
351 this.source = sourceDocument.getUriForAnnot();
353 this.content = content;
354 this.nestedInSuggestion = nestedInAnnot;
355 this.attributes =
new ArrayList<SugBaseAttribute>();
356 this.fragments =
new ArrayList<SuggestionFragment>();
357 isFromSECAPI =
false;
358 displayConfidence =
false;
367 this.type = newData.getAnnotType().getId();
368 this.created = newData.getCreated();
369 this.authorIdStr = newData.getAuthorIdStr();
370 this.authorName = newData.getAuthorName();
371 this.authorAddress = newData.getAuthorAddress();
372 this.source = newData.getSource();
373 this.sourceDocumentId = newData.getSourceDocument().getId();
374 this.content = newData.getContent();
376 this.nestedIn = newData.getNestedInSuggestion().getId().toString();
378 this.annotType = newData.getAnnotType();
379 this.sourceDocument = newData.getSourceDocument();
380 this.attributes = newData.getAttributes();
381 this.fragments = newData.getFragments();
382 this.user = newData.getUser();
383 this.nestedInSuggestion = newData.getNestedInSuggestion();
384 this.displayConfidence = newData.displayConfidence;
393 this.type = newData.getAnnotType().getId();
394 this.created = newData.getCreated();
395 this.authorIdStr = newData.getAuthorIdStr();
396 this.authorName = newData.getAuthorName();
397 this.authorAddress = newData.getAuthorAddress();
398 this.source = newData.getSource();
399 this.sourceDocumentId = newData.getSourceDocument().getId();
400 this.content = newData.getContent();
401 this.annotType = newData.getAnnotType();
402 this.sourceDocument = newData.getSourceDocument();
403 this.attributes =
new ArrayList<SugBaseAttribute>();
405 Iterator<BaseAttribute> atIt = newData.getAttributes().iterator();
406 while (atIt.hasNext()) {
410 newAt = SugAttributeManager.createAttribute(at.getName(), at.
getSimpleType(),
this);
411 }
catch (ClassNotFoundException ex) {
412 String msg =
"Unable to create suggestion attribute with type = " + at.getSimpleType();
413 Logger.getLogger(Suggestion.class.getName()).log(Level.SEVERE, null, msg);
416 newAt.updateFromBaseAttribut(at);
417 this.attributes.add(newAt);
420 this.fragments =
new ArrayList<SuggestionFragment>();
422 Iterator<Fragment> fragIt = newData.getFragments().iterator();
423 while (fragIt.hasNext()) {
426 this.fragments.add(newFrag);
429 this.user = newData.getUser();
430 displayConfidence =
false;
439 this.tmpId = newData.getTmpId();
440 this.type = newData.getAnnotType().getId();
441 this.source = newData.getSource();
442 this.sourceDocumentId = newData.getSourceDocument().getId();
443 this.content = newData.getContent();
444 this.annotType = newData.getAnnotType();
445 this.sourceDocument = newData.getSourceDocument();
446 this.confidence = newData.getConfidence();
447 this.alternativeOfSuggestion = newData.getAlternativeOfSuggestion();
448 this.SAEntityIdentifier = newData.getSAEntityIdentifier();
449 List newDataAtts = newData.getAttributes();
450 if (newDataAtts != null && !newDataAtts.isEmpty()) {
451 for (
int i = 0; i < newDataAtts.size(); i++) {
458 sba = SugAttributeManager.createAttribute(
"", attr.getSimpleType(),
this);
459 }
catch (Exception e) {
460 String msg =
"Unable to create suggestion attribute with type = " + attr.getSimpleType();
461 Logger.getLogger(Suggestion.class.getName()).log(Level.SEVERE, msg, e);
466 String msg =
"Unable to create suggestion attribute with type = " + attr.getSimpleType();
467 Logger.getLogger(Annotation.class.getName()).log(Level.SEVERE, msg);
471 sba.updateFromAlternativeAttribut(attr);
472 if (this.attributes == null) {
473 this.attributes =
new ArrayList<SugBaseAttribute>();
475 this.attributes.add(sba);
479 this.attributes =
new ArrayList<SugBaseAttribute>();
482 Iterator frIt = newData.getFragments().iterator();
483 if (this.fragments == null) {
484 this.fragments =
new ArrayList<SuggestionFragment>();
486 this.fragments.clear();
487 while (frIt.hasNext()) {
490 newSugFr.setRefSuggestion(
this);
491 fragments.add(newSugFr);
493 displayConfidence =
false;
501 this.type = newData.getAnnotType().getId();
502 this.source = newData.getSource();
503 this.sourceDocumentId = newData.getSourceDocument().getId();
504 this.content = newData.getContent();
505 this.annotType = newData.getAnnotType();
506 this.sourceDocument = newData.getSourceDocument();
507 List newDataAtts = newData.getAttributes();
508 if (newDataAtts != null && !newDataAtts.isEmpty()) {
509 for (
int i = 0; i < newDataAtts.size(); i++) {
516 sba = SugAttributeManager.createAttribute(
"", ba.getSimpleType(),
this);
517 }
catch (Exception e) {
519 String msg =
"Unable to create suggestion attribute with type = " + ba.getSimpleType();
520 Logger.getLogger(Annotation.class.getName()).log(Level.SEVERE, msg, e);
524 sba.updateFromBaseAttribut(ba);
525 if (this.attributes == null) {
526 this.attributes =
new ArrayList<SugBaseAttribute>();
528 this.attributes.add(sba);
531 Iterator<Fragment> frIt = newData.getFragments().iterator();
532 if (this.fragments == null) {
533 this.fragments =
new ArrayList<SuggestionFragment>();
535 this.fragments.clear();
536 while (frIt.hasNext()) {
538 newSugFr.updateFromFragment(frIt.next());
539 newSugFr.setRefSuggestion(
this);
540 fragments.add(newSugFr);
542 displayConfidence =
false;
579 this.annotType = annotType;
597 this.created = created;
618 authorIdStr = user.getURI();
619 if (user.
getName() != null && !user.getName().contentEquals(
"")) {
620 authorName = user.getName();
622 if (user.
getEmail() != null && !user.getEmail().contentEquals(
"")) {
623 authorAddress = user.getEmail();
643 this.authorIdStr = authorIdStr;
661 this.authorName = authorName;
670 return authorAddress;
679 this.authorAddress = authorAddress;
697 this.source = source;
706 return sourceDocumentId;
715 this.sourceDocumentId = sourceDocumentId;
751 this.content = content;
769 this.autorId = autorId;
778 return sourceDocument;
788 this.sourceDocument = sourceDocument;
789 if (sourceDocument != null) {
790 this.source = sourceDocument.getUriForAnnot();
809 this.nestedIn = nestedIn;
827 this.attributes = attributes;
836 this.attributes.add(attribute);
855 return new ArrayList<SuggestionFragment>(fragments);
864 this.fragments = fragments;
874 return nestedInSuggestion;
883 this.nestedInSuggestion = nestedInSuggestion;
892 return alternativeOfSuggestion;
901 this.alternativeOfSuggestion = alternativeOfSuggestion;
910 return nestedInAnnot;
919 this.nestedInAnnot = nestedInAnnot;
937 this.confidence = confidence;
946 return displayConfidence;
955 this.displayConfidence = displayConfidence;
993 this.isFromSECAPI = isFromSECAPI;
1002 return SAEntityIdentifier;
1012 this.SAEntityIdentifier = SAEntityIdentifier;
1023 fragments.add(fragment);
1034 fragments.add((SuggestionFragment) fragment);
1041 hash += (
id != null ? id.hashCode() : 0);
1054 return AppBean.getBaseUri() +
"/sugg/" +
id;
1063 String xpointers =
"";
1065 Iterator<SuggestionFragment> fragIt = fragments.iterator();
1066 while(fragIt.hasNext()){
1067 xpointers +=
"#" + fragIt.next().getXpointerV2();
1081 public String
toXMLStringV2(ArrayList<String> attFilter,
int langNum, Boolean KBRefMode){
1082 if (attFilter == null) {
1083 attFilter =
new ArrayList<String>();
1086 if (KBRefMode == null) {
1089 StringBuilder result =
new StringBuilder();
1090 String suggUri = AppBean.getBaseUri()+
"/sugg/" +
id;
1093 result.append(
"<suggestion confidence=\"");
1094 result.append(confidence);
1095 result.append(
"\" displayConfidence=\"");
1096 if (displayConfidence) {
1097 result.append(
"true");
1099 result.append(
"false");
1101 result.append(
"\">");
1102 result.append(
"<oa:Annotation rdf:about=\"");
1103 result.append(suggUri);
1104 result.append(
"\">");
1107 result.append(
"<oa:hasBody>");
1108 result.append(
"<oa:SemanticTag rdf:about=\"");
1109 result.append(annotType.getUri());
1110 result.append(
"\"/>");
1111 result.append(
"</oa:hasBody>");
1114 if(fragments == null || fragments.isEmpty()){
1116 result.append(
"<oa:hasTarget>");
1118 result.append(
"<dctypes:Text rdf:about=\"");
1119 result.append(source);
1120 result.append(
"\">");
1121 result.append(
"<dc:format>text/xml</dc:format>");
1122 result.append(
"</dctypes:Text>");
1124 result.append(
"</oa:hasTarget>");
1125 }
else if (fragments.size() == 1) {
1127 result.append(
"<oa:hasTarget>");
1129 result.append(
"</oa:hasTarget>");
1130 }
else if (fragments.size() > 1) {
1132 result.append(
"<oa:hasTarget>");
1133 result.append(
"<oa:Composite rdf:about=\"");
1135 result.append(source);
1136 result.append(getFragmentXpointersV2());
1137 result.append(
"\">");
1139 Iterator<SuggestionFragment> fragIt = fragments.iterator();
1140 while(fragIt.hasNext()){
1142 result.append(
"<oa:item>");
1143 result.append(tmpFrag.toXMLStringV2());
1144 result.append(
"</oa:item>");
1147 result.append(
"</oa:Composite>");
1148 result.append(
"</oa:hasTarget>");
1152 result.append(
"<oa:hasBody>");
1154 result.append(
"<cnt:ContentAsText rdf:about=\"");
1155 result.append(suggUri);
1156 result.append(
"#body\">");
1158 result.append(
"<rdf:type rdf:resource=\"http://purl.org/dc/dcmitype/Text\"/>");
1159 result.append(
"<cnt:chars><![CDATA[");
1160 result.append(content);
1161 result.append(
"]]></cnt:chars><dc:format>text/plain</dc:format>");
1162 result.append(
"</cnt:ContentAsText>");
1163 result.append(
"</oa:hasBody>");
1167 result.append(
"<oa:hasBody>");
1169 result.append(
"<cnt:ContentAsText rdf:about=\"");
1170 result.append(source);
1171 result.append(
"\">");
1173 result.append(
"<rdf:type rdf:resource=\"http://www.w3.org/2004/03/trix/rdfg-1/Graph\"/>");
1175 result.append(
"<trix:TriX>");
1176 result.append(
"<trix:graph>");
1181 result.append(attributesToKBRefString(attFilter, langNum));
1183 Iterator<SugBaseAttribute> attribIt = attributes.iterator();
1184 while (attribIt.hasNext()) {
1187 tmpAttrib = SugAttributeManager.changeAttributeInstance(tmpAttrib);
1189 String aName = tmpAttrib.getName();
1190 if (attFilter.contains(aName)) {
1193 result.append(tmpAttrib.toXMLStringV2());
1197 result.append(
"</trix:graph>");
1198 result.append(
"</trix:TriX>");
1200 result.append(
"<dc:format>text/xml</dc:format>");
1201 result.append(
"</cnt:ContentAsText>");
1202 result.append(
"</oa:hasBody>");
1205 SimpleDateFormat df =
new SimpleDateFormat(
"yyyy-MM-dd'T'hh:mm:ssZ");
1207 if(created == null){
1208 Date now =
new Date();
1209 date = df.format(now.getTime());
1211 date = df.format(created);
1214 result.append(
"<oa:annotatedAt>");
1215 result.append(date);
1216 result.append(
"</oa:annotatedAt>");
1218 result.append(
"<oa:serializedAt>");
1219 result.append(date);
1220 result.append(
"</oa:serializedAt>");
1223 result.append(
"</oa:Annotation>");
1224 result.append(
"</suggestion>");
1227 Iterator<SugBaseAttribute> attrNestedIt = attributes.iterator();
1228 while(attrNestedIt.hasNext()){
1230 String aName = tmpAttrib.getName();
1231 if (attFilter.contains(aName)) {
1235 result.append(tmpAttrib.getNestedAnnotation().toXMLStringV2(attFilter, langNum, KBRefMode));
1238 result.append(tmpAttrib.getNestedSuggestion().toXMLStringV2(attFilter, langNum, KBRefMode));
1242 return result.toString();
1253 StringBuilder result =
new StringBuilder();
1254 StringBuilder tmpResult =
new StringBuilder();
1255 Iterator<SugBaseAttribute> attribIt = attributes.iterator();
1257 kRefAt.setSimpleType(
"Entity");
1258 kRefAt.setEntityAdditionalAttributes(
new ArrayList<SugEntityAdditionalAttribute>());
1259 kRefAt.setRefSuggestion(
this);
1261 kRefAt.setEntityType(this.getAnnotType().getName());
1262 Boolean nameSet =
false;
1263 Boolean uriSet =
false;
1264 Boolean vrSet =
false;
1265 Boolean desSet =
false;
1266 while (attribIt.hasNext()) {
1268 Boolean processed =
false;
1270 tmpAttrib = SugAttributeManager.changeAttributeInstance(tmpAttrib);
1274 kRefAt.setEntityName(tmpAttrib.getStringValue());
1283 kRefAt.setDescription(kRefAt.getDescription() + tmpAttrib.
getTextValue());
1285 kRefAt.setDescription(tmpAttrib.getTextValue());
1293 kRefAt.setDescription(kRefAt.getDescription() + tmpAttrib.
getStringValue());
1295 kRefAt.setDescription(tmpAttrib.getStringValue());
1301 if (tmpAttrib.
getUri() != null && !uriSet) {
1302 kRefAt.setUri(tmpAttrib.getUri());
1307 if (tmpAttrib.
getUri() != null) {
1308 kRefAt.setEntityVisualURI(tmpAttrib.getUri());
1314 String aName = tmpAttrib.getName();
1315 if (attFilter.contains(aName)) {
1319 tmpResult.append(tmpAttrib.toXMLStringV2());
1323 adAt.setRefEntityAttribute(kRefAt);
1324 kRefAt.getEntityAdditionalAttributes().add(adAt);
1326 tmpResult.append(tmpAttrib.toXMLStringV2());
1331 if (nameSet && desSet && uriSet) {
1332 result.append(kRefAt.toXMLStringV2());
1333 result.append(tmpResult);
1335 attribIt = attributes.iterator();
1336 while (attribIt.hasNext()) {
1339 tmpAttrib = SugAttributeManager.changeAttributeInstance(tmpAttrib);
1341 String aName = tmpAttrib.getName();
1342 if (attFilter.contains(aName)) {
1345 result.append(tmpAttrib.toXMLStringV2());
1357 String xpointers =
"";
1359 Iterator<SuggestionFragment> fragIt = fragments.iterator();
1360 while(fragIt.hasNext()){
1361 xpointers +=
"#" + fragIt.next().getXpointer();
1374 return toXMLString(
true,
"", proto11);
1385 public String
toXMLString(
boolean annotTag, String annotTagAttrs,
boolean proto11) {
1386 String authorAttr =
"";
1387 if (authorName != null) {
1388 authorAttr = authorAttr +
" name=\"" + authorName +
"\"";
1390 if (authorAddress != null) {
1391 authorAttr = authorAttr +
" address=\"" + authorAddress +
"\"";
1393 String tIdForD =
" tmpId=\"" +
id +
"\"";
1394 String authorIdString =
"";
1395 if (authorIdStr != null) {
1396 authorIdString = authorIdStr;
1399 String tmpContent =
"";
1400 if(content != null){
1401 tmpContent = content;
1405 return "<annotation" + annotTagAttrs +
">"
1406 +
"<rdf:Description" + tIdForD +
" rdf:about=\"\">"
1407 +
"<rdf:type rdf:resource=\"" + annotType.getUri() +
"\"/>"
1408 +
"<a:author id=\"" + authorIdString +
"\"" + authorAttr +
"/>"
1409 +
"<a:source rdf:resource=\"" + source +
"\"/>"
1410 + fragmentsToXMLString()
1416 + attributesToXMLString(proto11)
1417 +
"</rdf:Description>"
1420 return "<rdf:Description" + tIdForD +
" rdf:about=\"\">"
1421 +
"<rdf:type rdf:resource=\"" + annotType.getUri() +
"\"/>"
1422 +
"<a:author id=\"" + authorIdString +
"\"" + authorAttr +
"/>"
1423 +
"<a:source rdf:resource=\"" + source +
"\"/>"
1424 + fragmentsToXMLString()
1430 + attributesToXMLString(proto11)
1431 +
"</rdf:Description>";
1440 String fragmentsString =
"";
1441 Iterator<SuggestionFragment> fragIt = fragments.iterator();
1443 while (fragIt.hasNext()) {
1445 fragmentsString += fr.toXMLString();
1447 return fragmentsString;
1457 String attrString =
"";
1459 String attrNameString;
1466 Integer attrNameIdx;
1467 HashMap<String, Integer> sameNameCntMap =
new HashMap<String, Integer>();
1469 Collections.sort(attributes);
1470 Iterator<SugBaseAttribute> attrIt = attributes.iterator();
1472 while (attrIt.hasNext()) {
1473 attr = attrIt.next();
1475 SugAttributeManager.changeAttributeInstance(attr);
1477 attrNameString = attr.getName();
1478 attrMapKey = attrNameString.concat(attr.getSimpleType());
1479 if (sameNameCntMap.containsKey(attrMapKey)) {
1482 attrNameIdx = sameNameCntMap.get(attrMapKey);
1485 attr.setName(attrNameString.concat(attrNameIdx.toString()));
1486 attrString += attr.toXMLString(proto11,
false);
1488 attr.setName(attrNameString);
1490 sameNameCntMap.put(attrMapKey, attrNameIdx);
1493 attrString += attr.toXMLString(proto11,
false);
1494 sameNameCntMap.put(attrMapKey, 1);
1512 Suggestion other = (Suggestion)
object;
1513 if ((this.
id == null && other.
id != null) || (this.id != null && !this.id.equals(other.id))) {
1517 if(other.
id == null &&
this.id == null){
1518 if(!contentEquals(
object)){
1534 public boolean equals(Object
object,
boolean noLinked){
1538 Suggestion other = (Suggestion)
object;
1539 if ((this.
id == null && other.
id != null) || (this.id != null && !this.id.equals(other.id))) {
1543 if(other.
id == null &&
this.id == null){
1544 if(!contentEquals(
object,
false,noLinked)){
1561 return contentEquals(obj,
false,
false);
1574 public boolean contentEquals(Object obj,
boolean withCreated,
boolean noLinked) {
1578 if (getClass() != obj.getClass()) {
1583 if (this.created != other.
created && (
this.created == null || !
this.created.equals(other.
created))) {
1587 if ((this.authorIdStr == null) ? (other.authorIdStr != null) : !this.authorIdStr.equals(other.
authorIdStr)) {
1590 if ((this.authorName == null) ? (other.authorName != null) : !this.authorName.equals(other.
authorName)) {
1593 if ((this.authorAddress == null) ? (other.authorAddress != null) : !this.authorAddress.equals(other.
authorAddress)) {
1596 if ((this.source == null) ? (other.source != null) : !this.source.equals(other.
source)) {
1599 if ((this.content == null) ? (other.content != null) : !this.content.equals(other.
content)) {
1602 if (this.annotType != other.
annotType && (
this.annotType == null || !
this.annotType.equals(other.
annotType))) {
1605 if (this.sourceDocument != other.
sourceDocument && (
this.sourceDocument == null || !
this.sourceDocument.equals(other.
sourceDocument))) {
1609 if (this.attributes == null && other.
attributes != null) {
1611 }
else if (this.attributes != null && other.
attributes == null) {
1613 }
else if (this.attributes != other.
attributes &&
this.attributes != null && other.
attributes != null) {
1614 if (this.attributes.size() != other.attributes.size()) {
1617 Iterator<SugBaseAttribute> atIt = this.attributes.iterator();
1618 while (atIt.hasNext()) {
1620 boolean found =
false;
1621 Iterator<SugBaseAttribute> oAtIt = other.attributes.iterator();
1625 while (oAtIt.hasNext()) {
1628 if(at instanceof SugLinkedAttribute && oAt instanceof SugLinkedAttribute){
1645 if (this.fragments == null && other.
fragments != null) {
1647 }
else if (this.fragments != null && other.
fragments == null) {
1649 }
else if (this.fragments != other.
fragments &&
this.fragments != null && other.
fragments != null) {
1650 if (this.fragments.size() != other.fragments.size()) {
1653 Iterator<SuggestionFragment> frIt = this.fragments.iterator();
1654 while (frIt.hasNext()) {
1656 boolean found =
false;
1657 Iterator<SuggestionFragment> oFrIt = other.fragments.iterator();
1658 while (oFrIt.hasNext()) {
1670 if (this.user != other.
user && (
this.user == null || !
this.user.equals(other.
user))) {
1683 return "cz.vutbr.fit.knot.annotations.modules.SuggestionManager.Suggestion[ id=" +
id +
" ]";
1695 return AppBean.getBaseSugUri() +
id;
Class representing attribute of alternative of suggestion.
Suggestion(AnnotType annotType, Date created, String authorIdStr, String authorName, String authorAddress, AnnotDocument sourceDocument, String content)
Class representing attribute of type Text for prupose of suggestion.
Annotation getNestedAnnotation()
void setNestedIn(String nestedIn)
Additional attribute of entity in suggestion attribute.
Attribute manager provides a way how to create new attributes for prupose of suggestion.
Interface for Suggestion and Alternative.
static final ArrayList< String > FORBIDDEN_ENTITY_TYPES
void setNestedInAnnot(Annotation nestedInAnnot)
static final int KB_ENTITY_URI
String getSAEntityIdentifier()
Suggestion(Alternative a)
boolean equals(Object object, boolean noLinked)
String getAuthorAddress()
Class representing annotated copy of document.
boolean contentEquals(Object obj)
Annotation getNestedInAnnot()
void updateWithAnnotation(Annotation newData)
void updateWithAlternativeForDB(Alternative newData)
Integer getSourceDocumentId()
Singleton for storing global variables.
String getFragmentXpointers()
Suggestion nestedInSuggestion
void setAuthorAddress(String authorAddress)
void setSource(String source)
Class representing vocabulary entity attribute for prupose of suggestion.
Suggestion getNestedSuggestion()
String attributesToXMLString(boolean proto11)
Class representing attribute of suggestion.
void setIsFromSECAPI(boolean isFromSECAPI)
void setSourceDocument(AnnotDocument sourceDocument)
static final int KB_DISAMBIGUATION
Class representing suggested annotation fragment.
abstract Object getValue()
List< Fragment > getFragments()
boolean getDisplayConfidence()
static boolean hasAttributeRightInstance(SugBaseAttribute attr)
List< SuggestionFragment > fragments
static final String UPDATABLE_AN_AT_NAME
String toXMLStringV2(ArrayList< String > attFilter, int langNum, Boolean KBRefMode)
void setAutorId(String autorId)
Suggestion(AnnotType type, String content, String nestedIn)
Suggestion(Integer id, String authorIdStr, String authorName, String authorAddress, AnnotDocument sourceDocument, String content, String nestedIn)
void addSecFragment(SecFragment fragment)
Class representing attribute of type String for prupose of suggestion.
void updateWithSuggestion(Suggestion newData)
Class representing fragment for suggestion alternative.
static final String KB_REF_ATT_NAME
Suggestion getNestedInSuggestion()
List< SuggestionFragment > getFragments()
void setAuthorName(String authorName)
ArrayList< SuggestionFragment > getFragmentsAL()
boolean contentEquals(Object obj, boolean withCreated, boolean noLinked)
Suggestion getAlternativeOfSuggestion()
Base class representing attribute of annotation.
static final int LOG_LEVEL
Class representing type of annotation.
List< SugBaseAttribute > attributes
static final int KB_DESCRIPTION
void addFragment(SuggestionFragment fragment)
String toXMLString(boolean proto11)
boolean getIsFromSECAPI()
String fragmentsToXMLString()
Class representing attribute of type AnnotationLink for prupose of suggestion.
String toXMLString(boolean annotTag, String annotTagAttrs, boolean proto11)
Suggestion(AnnotType annotType, Date created, String authorIdStr, String authorName, String authorAddress, AnnotDocument sourceDocument, String content, Suggestion nestedInAnnot)
void setFragments(ArrayList< SuggestionFragment > fragments)
boolean contentEquals(Object obj)
Class representing alternative of suggestion.
void setSAEntityIdentifier(String SAEntityIdentifier)
List< SugBaseAttribute > getAttributes()
void setNestedInSuggestion(Suggestion nestedInSuggestion)
void setTmpId(String tmpId)
static final int LOG_LEVEL_SERVER_ERRORS
void setAlternativeOfSuggestion(Suggestion alternativeOfSuggestion)
void setAttributes(ArrayList< SugBaseAttribute > attributes)
String getFragmentXpointersV2()
Class representing suggestion of annotation.
void setDisplayConfidence(boolean displayConfidence)
AnnotDocument sourceDocument
void setSourceDocumentId(Integer sourceDocumentId)
Class responsible for localised strings.
AnnotDocument getSourceDocument()
void setContent(String content)
boolean equals(Object object)
static final int KB_VISUAL_REPRESENTATION
void setAnnotType(AnnotType annotType)
Class representing annotated fragment.
static final int KB_ARTWORK_NAME
boolean contentEquals(Object obj)
List< BaseAttribute > getAttributes()
Class representing annotation.
void setCreated(Date created)
void addAttribute(SugBaseAttribute attribute)
StringBuilder attributesToKBRefString(ArrayList< String > attFilter, int langNum)
void setConfidence(Integer confidence)
final void updateWithAnnotationForDB(Annotation newData)
void setType(Integer type)
void setAuthorIdStr(String authorIdStr)
Interface for SuggestionFragment and AlternativeFragment.