14 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
22 import java.io.Serializable;
23 import javax.persistence.Basic;
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.Lob;
31 import javax.persistence.ManyToOne;
32 import javax.persistence.NamedQueries;
33 import javax.persistence.NamedQuery;
34 import javax.persistence.Table;
35 import javax.validation.constraints.NotNull;
36 import javax.validation.constraints.Size;
37 import javax.xml.bind.annotation.XmlRootElement;
38 import javax.xml.xpath.XPathExpressionException;
48 @Table(name =
"suggestionFragment")
51 @NamedQuery(name =
"SuggestionFragment.findAll", query =
"SELECT s FROM SuggestionFragment s"),
52 @NamedQuery(name =
"SuggestionFragment.findById", query =
"SELECT s FROM SuggestionFragment s WHERE s.id = :id"),
53 @NamedQuery(name =
"SuggestionFragment.findBySuggestion", query =
"SELECT s FROM SuggestionFragment s WHERE s.suggestion = :suggestion"),
54 @NamedQuery(name =
"SuggestionFragment.findByOffset", query =
"SELECT s FROM SuggestionFragment s WHERE s.offset = :frOffset"),
55 @NamedQuery(name =
"SuggestionFragment.findByLength", query =
"SELECT s FROM SuggestionFragment s WHERE s.length = :frLength"),
56 @NamedQuery(name =
"SuggestionFragment.findByIsGood", query =
"SELECT s FROM SuggestionFragment s WHERE s.isGood = :isGood")})
58 private static final long serialVersionUID = 1L;
62 @GeneratedValue(strategy = GenerationType.IDENTITY)
63 @Basic(optional =
false)
68 @Basic(optional = false)
70 @Column(name = "suggestion", nullable = false, insertable = false, updatable = false)
71 private
int suggestion;
75 @Size(max = 2147483647)
76 @Column(name = "path")
80 @Column(name = "offset")
81 private Integer offset;
84 @Column(name = "fLength")
85 private Integer length;
88 @Basic(optional = false)
91 @Size(min = 0, max = 16777215)
92 @Column(name = "annotatedText")
93 private String annotatedText;
98 @Basic(optional = false)
100 @Column(name = "isGood")
101 private
boolean isGood;
106 @ManyToOne(optional = false)
107 @JoinColumn(name = "suggestion", referencedColumnName = "
id")
127 this.offset = offset;
128 this.length = length;
129 this.annotatedText = annotatedText;
130 this.refSuggestion = refSuggestion;
146 this.offset = offset;
147 this.length = length;
148 this.annotatedText = annotatedText;
149 this.refSuggestion = refSuggestion;
150 this.isGood = isGood;
162 this.offset = offset;
163 this.length = length;
200 this.suggestion = suggestion;
237 this.offset = offset;
256 this.length = length;
266 return annotatedText;
275 this.annotatedText = annotatedText;
294 this.isGood = isGood;
303 return refSuggestion;
313 return refSuggestion;
322 this.refSuggestion = refSuggestion;
333 this.refSuggestion = (Suggestion) value;
354 this.path = uf.getXPathString();
356 this.path = uf.getXPathString() +
"/text()";
358 this.offset = uf.getOffset();
359 this.length = uf.getLength();
360 this.annotatedText = uf.getText();
369 this.path = fr.getPath();
370 this.length = fr.getLength();
371 this.offset = fr.getOffset();
372 this.annotatedText = fr.getAnnotatedText();
373 this.isGood = fr.getIsGood();
382 this.path = fr.getPath();
383 this.length = fr.getLength();
384 this.offset = fr.getOffset();
385 this.annotatedText = fr.getAnnotatedText();
386 this.isGood = fr.getIsGood();
402 SuggestionFragment other = (SuggestionFragment)
object;
404 if (this.path != other.
path && (
this.path == null || !
this.path.equals(other.
path))) {
407 if (this.offset != other.
offset && (
this.offset == null || !
this.offset.equals(other.
offset))) {
410 if (this.length != other.
length && (
this.length == null || !
this.length.equals(other.
length))) {
413 if ((this.annotatedText == null) ? (other.annotatedText != null) : !this.annotatedText.equals(other.
annotatedText)) {
432 if (getClass() != obj.getClass()) {
436 if ((this.path == null) ? (other.path != null) : !this.path.equals(other.
path)) {
437 if ((this.path == null) ? (other.path != null) : !this.path.equals(other.
path.concat(
"/text()"))) {
441 if (this.offset != other.
offset && (
this.offset == null || !
this.offset.equals(other.
offset))) {
444 if (this.length != other.
length && (
this.length == null || !
this.length.equals(other.
length))) {
447 if ((this.annotatedText == null) ? (other.annotatedText != null) : !this.annotatedText.equals(other.
annotatedText)) {
469 if (this.offset != uf.
getOffset() && (this.offset == null || !this.offset.equals(uf.getOffset()))) {
472 if (this.length != uf.
getLength() && (this.length == null || !this.length.equals(uf.getLength()))) {
475 if ((this.annotatedText == null) ? (uf.getText() != null) : !this.annotatedText.equals(uf.getText())) {
489 invalid =
" valid=\"false\"";
491 return "<a:fragment" + invalid +
">"
492 +
"<a:path>" + path +
"</a:path>"
493 +
"<a:offset>" + offset +
"</a:offset>"
494 +
"<a:length>" + length +
"</a:length>"
495 +
"<a:annotatedText>" + Util.toHTMLString(annotatedText) +
"</a:annotatedText>"
505 String annotUri = this.getRefSuggestion().getSource();
506 String fragXpointer = this.getXpointerV2();
508 return "<oa:SpecificResource rdf:about=\"" + annotUri +
"#" + fragXpointer +
"\">"
510 +
"<oa:FragmentSelector rdf:about=\"" + annotUri +
"#" + fragXpointer +
"#selector\">"
511 +
"<dcterms:conformsTo rdf:resource=\"http://tools.ietf.org/rfc/rfc3023\" />"
512 +
"<rdf:value>" + fragXpointer +
"</rdf:value></oa:FragmentSelector></oa:hasSelector>"
513 +
"<oa:hasSource><dctypes:Text rdf:about=\"" + annotUri +
"\"><dc:format>text/xml</dc:format>"
514 +
"</dctypes:Text></oa:hasSource></oa:SpecificResource>";
523 return "xpointer(string-range(" + path +
",\"" + annotatedText +
"\", " + offset +
", " + length +
"))";
532 String xpointer =
"xpointer(string-range(" + path +
",'" + annotatedText +
"', " + offset +
", " + length +
"))";
533 return Util.toHTMLString(xpointer);
539 hash += (
id != null ? id.hashCode() : 0);
540 hash += (offset != null ? offset.hashCode() : 0);
541 hash += (length != null ? length.hashCode() : 0);
542 hash += (annotatedText != null ? annotatedText.hashCode() : 0);
548 return "cz.vutbr.fit.knot.annotations.modules.suggestionManager.SuggestionFragment[ id=" +
id +
" ]";
561 throw new UnsupportedOperationException(
"Not supported yet.");
563 SuggestionFragment other = (SuggestionFragment)
object;
564 int compareResult = offset.compareTo(other.getOffset());
565 if (compareResult == 0) {
566 compareResult = length.compareTo(other.getLength());
569 return compareResult;
void setAnnotatedText(String annotatedText)
Suggestion getRefSuggestion()
void setSuggestion(int suggestion)
void setOffset(Integer offset)
void setLength(Integer length)
Interface for Suggestion and Alternative.
boolean fragmentEqualsWUF(UpdatableFragment uf)
SecSuggestion getRefSecSuggestion()
Class representing suggested annotation fragment.
void updateWithUpdatableFragment(UpdatableFragment uf)
void setRefSecSuggestion(SecSuggestion value)
SuggestionFragment(String path, Integer offset, Integer length, String annotatedText, Suggestion refSuggestion)
void updateFromAlternativeFragment(AlternativeFragment fr)
boolean equals(Object object)
Class representing fragment for suggestion alternative.
String getAnnotatedText()
UpdatableFragment toUpdatableFragment()
Class for XML document fragment.
void setIsGood(boolean isGood)
int compareTo(Object object)
boolean contentEquals(Object obj)
SuggestionFragment(String path, Integer offset, Integer length)
SuggestionFragment(String path, Integer offset, Integer length, String annotatedText, Suggestion refSuggestion, Boolean isGood)
Class representing suggestion of annotation.
void setRefSuggestion(Suggestion refSuggestion)
Utility class (manipulates RFC 3339 dates)
Class representing annotated fragment.
void setPath(String path)
void updateFromFragment(Fragment fr)
Interface for SuggestionFragment and AlternativeFragment.