annotate src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java @ 25:52dff477e45f

on the way to a new ontology...
author casties
date Wed, 25 Apr 2012 18:02:44 +0200
parents a3e324009990
children 235b91ba8dff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dwinter
parents:
diff changeset
1 package de.mpiwg.itgroup.annotationManager.RDFHandling;
dwinter
parents:
diff changeset
2
dwinter
parents:
diff changeset
3 import java.text.DateFormat;
dwinter
parents:
diff changeset
4 import java.text.SimpleDateFormat;
dwinter
parents:
diff changeset
5 import java.util.ArrayList;
dwinter
parents:
diff changeset
6 import java.util.Calendar;
dwinter
parents:
diff changeset
7 import java.util.Date;
dwinter
parents:
diff changeset
8 import java.util.List;
dwinter
parents:
diff changeset
9
dwinter
parents:
diff changeset
10 import org.apache.log4j.Logger;
dwinter
parents:
diff changeset
11 import org.openrdf.repository.RepositoryException;
dwinter
parents:
diff changeset
12 import org.restlet.Context;
dwinter
parents:
diff changeset
13 import org.restlet.engine.component.ChildContext;
dwinter
parents:
diff changeset
14
dwinter
parents:
diff changeset
15 import de.mpiwg.itgroup.annotationManager.Constants.NS;
dwinter
parents:
diff changeset
16 import de.mpiwg.itgroup.annotationManager.Errors.TripleStoreStoreError;
dwinter
parents:
diff changeset
17 import de.mpiwg.itgroup.annotationManager.Errors.XPointerError;
5
0be9d53a6967 editor for annotations
dwinter
parents: 3
diff changeset
18 import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException;
0be9d53a6967 editor for annotations
dwinter
parents: 3
diff changeset
19 import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler;
0be9d53a6967 editor for annotations
dwinter
parents: 3
diff changeset
20 import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler.LiteralQuadruple;
0be9d53a6967 editor for annotations
dwinter
parents: 3
diff changeset
21 import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler.Quadruple;
0
dwinter
parents:
diff changeset
22
dwinter
parents:
diff changeset
23 /**
dwinter
parents:
diff changeset
24 * @author dwinter
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
25 *
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
26 * Klasse zum Konvertieren von Annotationen zum mpiwg RDF-Format: http://ontologies.mpiwg-berlin.mpg.de/annotations/
0
dwinter
parents:
diff changeset
27 */
dwinter
parents:
diff changeset
28
dwinter
parents:
diff changeset
29 public class Convert {
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
30 private String context = "file:///annotations";
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
31 private static Logger logger = Logger.getRootLogger();
25
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
32 private String urlBase = "http://entities.mpiwg-berlin.mpg.de/annotations/"; // TODO should go into config
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
33
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
34 public Convert(String context) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
35 this.context = context;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
36 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
37
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
38 /**
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
39 *
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
40 * @param xpointer
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
41 * Beschreibt die Annotation
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
42 * @param creator
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
43 * Username des Creators
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
44 * @param time
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
45 * Erstellungszeit, wenn null wird das aktuelle Datum verwenden beim Konvertieren
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
46 * @param text
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
47 * der Annotation
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
48 * @param type
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
49 * Annotationstype (Entsprechend den in http://www.w3.org/2000/10/annotationType# definierten.)
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
50 * @return
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
51 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
52
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
53 private List<Quadruple> annot2quadruple(String xpointer, String creator, String time, String annot, String type) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
54 return annot2quadruple(new Annotation(xpointer, creator, time, annot, type));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
55 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
56
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
57 /**
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
58 * @param annot
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
59 * @return
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
60 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
61 public List<Quadruple> annot2quadruple(Annotation annot) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
62 List<Quadruple> retQuad = new ArrayList<Quadruple>();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
63
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
64 // create new URL if annot has no annotationUrl
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
65 String annotationUrl = annot.getAnnotationUri();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
66 if (annotationUrl == null) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
67 annotationUrl = createRessourceURL("annot:");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
68 }
25
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
69 // type
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
70 // TODO: where to get types?
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
71 retQuad.add(new LiteralQuadruple(annotationUrl, NS.RDF + "type", annot.type, context));
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
72
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
73 // author
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
74 if (annot.creator.startsWith("http")) {
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
75 retQuad.add(new Quadruple(annotationUrl, NS.DCTERMS_NS + "creator", annot.creator, context));
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
76 } else {
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
77 // TODO: this should not happen
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
78 retQuad.add(new LiteralQuadruple(annotationUrl, NS.DCTERMS_NS + "creator", annot.creator, context));
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
79 }
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
80 // creation time
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
81 if (annot.time == null) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
82 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
83 annot.time = format.format(Calendar.getInstance().getTime());
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
84 }
25
52dff477e45f on the way to a new ontology...
casties
parents: 23
diff changeset
85 retQuad.add(new LiteralQuadruple(annotationUrl, NS.DCTERMS_NS + "created", annot.time, context));
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
86
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
87 String[] xpointerSplitted = annot.xpointer.split("#");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
88
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
89 if (xpointerSplitted.length > 2) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
90 throw new XPointerError();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
91 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
92
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
93 // now add the xpointers
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
94 retQuad.add(new Quadruple(annotationUrl, NS.MPIWG_annot + "annotatesDocuviewerText", xpointerSplitted[0], context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
95 retQuad.add(new Quadruple(annotationUrl, NS.MPIWG_annot + "textSelection", annot.xpointer, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
96
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
97 String annotationtext = createRessourceURL("annotText:");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
98
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
99 retQuad.add(new Quadruple(annotationUrl, NS.ANNOTATION_NS + "body", annotationtext, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
100
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
101 retQuad.add(new Quadruple(annotationtext, NS.RDF + "type", NS.MPIWG_annot + "StandardTextNote", context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
102
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
103 retQuad.add(new LiteralQuadruple(annotationtext, NS.MPIWG_annot + "containsText", annot.text, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
104
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
105 for (Quadruple ret : retQuad) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
106 logger.debug(ret.toString());
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
107 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
108
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
109 annot.setAnnotationUri(annotationUrl);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
110 return retQuad;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
111 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
112
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
113 /**
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
114 * Erzeuge eine urn aus der aktullen Zeit in millis
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
115 *
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
116 * @return
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
117 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
118 private String createRessourceURL(String prefix) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
119
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
120 Calendar cal = Calendar.getInstance();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
121
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
122 long time = cal.getTimeInMillis();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
123
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
124 return String.format("%s%s%s", urlBase, prefix, time);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
125
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
126 }
0
dwinter
parents:
diff changeset
127
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
128 /**
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
129 * Hier ist die uri der Annotation angegeben.
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
130 *
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
131 * @param annot
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
132 * @return
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
133 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
134
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
135 private List<Quadruple> rel2quadruple(Annotation annot) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
136
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
137 List<Quadruple> retQuad = new ArrayList<Quadruple>();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
138
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
139 String annotation = createRessourceURL("annot:");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
140
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
141 if (annot.time == null) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
142 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
143 annot.time = format.format(Calendar.getInstance().getTime());
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
144
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
145 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
146
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
147 // TODO: check type
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
148 retQuad.add(new Quadruple(annotation, NS.RDF + "type", NS.ANNOTATION_TYPE + annot.type, context));
0
dwinter
parents:
diff changeset
149
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
150 // add author
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
151 if (annot.creator.startsWith("http")) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
152 retQuad.add(new Quadruple(annotation, NS.ANNOTATION_NS + "author", annot.creator, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
153 } else {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
154 retQuad.add(new LiteralQuadruple(annotation, NS.ANNOTATION_NS + "author", annot.creator, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
155 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
156
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
157 // creation time
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
158 retQuad.add(new LiteralQuadruple(annotation, NS.ANNOTATION_NS + "created", annot.time, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
159
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
160 String[] xpointerSplitted = annot.xpointer.split("#");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
161
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
162 if (xpointerSplitted.length > 2) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
163 throw new XPointerError();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
164 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
165
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
166 // now add the xpointers
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
167 retQuad.add(new Quadruple(annotation, NS.MPIWG_annot + "annotatesDocuviewerText", xpointerSplitted[0], context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
168 retQuad.add(new Quadruple(annotation, NS.MPIWG_annot + "textSelection", annot.xpointer, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
169
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
170 // String annotationtext =createRessourceURL("annotText:");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
171
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
172 retQuad.add(new Quadruple(annotation, NS.ANNOTATION_NS + "body", annot.url, context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
173
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
174 retQuad.add(new Quadruple(annot.url, NS.RDF + "type", NS.MPIWG_annot + "ExtendedAnnotation", context));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
175
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
176 for (Quadruple ret : retQuad) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
177 logger.debug(ret.toString());
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
178 }
0
dwinter
parents:
diff changeset
179
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
180 // save new annotation url in annotation object
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
181 annot.setAnnotationUri(annotation);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
182 return retQuad;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
183
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
184 }
0
dwinter
parents:
diff changeset
185
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
186 /**
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
187 * Stores the Annotation in the TripleStore.
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
188 *
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
189 * @param annot
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
190 * @return
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
191 * @throws TripleStoreStoreError
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
192 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
193 public Annotation storeAnnotation(Annotation annot) throws TripleStoreStoreError {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
194 List<Quadruple> annotationRdf = new ArrayList<Quadruple>();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
195 if ((annot.type == null) || annot.type.equals("")) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
196 annot.type = "Comment";
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
197 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
198 if (annot.text != null && !annot.text.equals("")) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
199 annotationRdf = annot2quadruple(annot);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
200 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
201 if (annot.url != null && !annot.url.equals("")) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
202 annotationRdf.addAll(rel2quadruple(annot));
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
203 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
204 try {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
205 TripleStoreHandler th = TripleStoreConnection.newTripleStoreHandler();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
206 th.write(annotationRdf);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
207 } catch (RepositoryException e) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
208 // TODO Auto-generated catch block
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
209 e.printStackTrace();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
210 throw new TripleStoreStoreError();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
211 } catch (TripleStoreHandlerException e) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
212 // TODO Auto-generated catch block
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
213 e.printStackTrace();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
214 throw new TripleStoreStoreError();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
215 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
216 return annot;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
217 }
0
dwinter
parents:
diff changeset
218
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
219 /**
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
220 * @param args
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
221 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
222 public static void main(String[] args) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
223 Convert myConvert = new Convert("http://annotations.rdf");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
224 List<Quadruple> rets = myConvert
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
225 .annot2quadruple(
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
226 "http://mpdl-dev.mpiwg-berlin.mpg.de/ECHOdocuViewfullTest?url=/mpiwg/online/permanent/library/163127KK&amp;viewMode=text&amp;pn=7#xpointer(string-range(id(&quot;s1&quot;), &quot;&quot;, 66, 12))",
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
227 "mbuchman", null, "myannot", "Example");
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
228 for (Quadruple ret : rets) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
229 System.out.println(ret.toString());
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
230 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 13
diff changeset
231 }
0
dwinter
parents:
diff changeset
232
dwinter
parents:
diff changeset
233 }