annotate src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/RDFSearcher.java @ 34:bd414fe235b5 default tip

now with 100% better sparql.
author casties
date Thu, 31 May 2012 21:32:30 +0200
parents e5f5848892a2
children
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.util.ArrayList;
dwinter
parents:
diff changeset
4 import java.util.List;
dwinter
parents:
diff changeset
5
dwinter
parents:
diff changeset
6 import org.apache.log4j.Logger;
dwinter
parents:
diff changeset
7 import org.openrdf.query.BindingSet;
dwinter
parents:
diff changeset
8 import org.openrdf.query.TupleQueryResult;
dwinter
parents:
diff changeset
9
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
10 import de.mpiwg.itgroup.annotationManager.Constants.NS;
0
dwinter
parents:
diff changeset
11 import de.mpiwg.itgroup.annotationManager.Errors.TripleStoreSearchError;
5
0be9d53a6967 editor for annotations
dwinter
parents: 2
diff changeset
12 import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException;
0be9d53a6967 editor for annotations
dwinter
parents: 2
diff changeset
13 import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler;
0
dwinter
parents:
diff changeset
14
dwinter
parents:
diff changeset
15 public class RDFSearcher {
dwinter
parents:
diff changeset
16
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
17 private String context;
0
dwinter
parents:
diff changeset
18
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
19 private Logger logger = Logger.getRootLogger();
0
dwinter
parents:
diff changeset
20
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
21 static final String baseGraph = " ?annotation <" + NS.RDF_NS + "type> <" + NS.OAC_NS + "Annotation>."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
22 + " ?annotation <" + NS.OAC_NS + "hasTarget> ?target."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
23 + " ?annotation <" + NS.OAC_NS + "hasBody> ?body."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
24 + " ?annotation <" + NS.DCTERMS_NS + "creator> ?creator."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
25 + " ?annotation <" + NS.DCTERMS_NS + "created> ?created."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
26 + " ?body <" + NS.CNT_NS + "chars> ?text."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
27 + " ?target <" + NS.DCTERMS_NS + "isPartOf> ?uri.";
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
28 static final String optGraph = " OPTIONAL { ?body <" + NS.RDF_NS + "type> <" + NS.OAC_NS + "Body>}"
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
29 + " OPTIONAL { ?body <" + NS.RDF_NS + "type> <" + NS.CNT_NS + "ContentAsText>}"
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
30 + " OPTIONAL { ?target <" + NS.RDF_NS + "type> <" + NS.OAC_NS + "Target>}";
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
31 static final String nonOptGraph = " ?body <" + NS.RDF_NS + "type> <" + NS.OAC_NS + "Body>."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
32 + " ?body <" + NS.RDF_NS + "type> <" + NS.CNT_NS + "ContentAsText>."
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
33 + " ?target <" + NS.RDF_NS + "type> <" + NS.OAC_NS + "Target>.";
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
35 static final String annotGraph = baseGraph + optGraph;
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
36
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
37 public RDFSearcher(String context) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
38 this.context = context;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
39 }
16
667d98fd28bd working on search and update.
casties
parents: 7
diff changeset
40
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
41 /**
30
b37487b756ac still working on new annotations...
casties
parents: 23
diff changeset
42 * Retrieves Annotations by ID.
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
43 *
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
44 * @param id
30
b37487b756ac still working on new annotations...
casties
parents: 23
diff changeset
45 * id of the Annotation
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
46 * @return
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
47 * @throws TripleStoreHandlerException
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
48 * @throws TripleStoreSearchError
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
49 */
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
50 public List<Annotation> searchById(String id) throws TripleStoreHandlerException, TripleStoreSearchError {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
51 if (id == null) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
52 return null;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
53 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
54 List<Annotation> retAnnots = new ArrayList<Annotation>();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
55 TripleStoreHandler th = TripleStoreConnection.newTripleStoreHandler();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
56 String queryString = "";
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
57 StringBuilder whereString = new StringBuilder();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
58 whereString.append(String.format("<%s> <http://www.openannotation.org/ns/hasTarget> ?target.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
59 whereString.append("?target <http://www.purl.org/dc/terms/isPartOf> ?uri.");
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
60 whereString.append(String.format("<%s> <http://www.openannotation.org/ns/hasBody> ?body.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
61 whereString.append("?body <http://www.w3.org/2011/content#chars> ?bodyText.");
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
62 whereString.append(String.format("<%s> <http://www.purl.org/dc/terms/creator> ?userUrl.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
63 whereString.append(String.format("<%s> <http://www.purl.org/dc/terms/created> ?creationDate", id));
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
64
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
65 /*
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
66 * StringBuilder whereString = new
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
67 * StringBuilder(String.format("<%s> ?p <http://www.w3.org/2000/10/annotationType#Comment>.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
68 * whereString.append(String
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
69 * .format("<%s> <http://ontologies.mpiwg-berlin.mpg.de/annotations/annotatesDocuviewerText> ?uri.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
70 * whereString.append(String.format("<%s> <http://ontologies.mpiwg-berlin.mpg.de/annotations/textSelection> ?xpointer.",
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
71 * id)); whereString.append(String.format("<%s> <http://www.w3.org/2000/10/annotation-ns#body> ?annotText.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
72 * whereString.append(String.format("<%s> <http://www.w3.org/2000/10/annotation-ns#author> ?author.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
73 * whereString.append(String.format("<%s> <http://www.w3.org/2000/10/annotation-ns#created> ?created.", id));
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
74 * whereString.append(" OPTIONAL {?annotText <http://ontologies.mpiwg-berlin.mpg.de/annotations/containsText> ?text.}");
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
75 */
16
667d98fd28bd working on search and update.
casties
parents: 7
diff changeset
76
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
77 queryString = String.format("select * from <%s> where {%s}", context, whereString);
16
667d98fd28bd working on search and update.
casties
parents: 7
diff changeset
78
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
79 logger.debug("RDFSearcher:" + queryString);
16
667d98fd28bd working on search and update.
casties
parents: 7
diff changeset
80
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
81 try {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
82 TupleQueryResult results = th.querySPARQL(queryString);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
83 while (results.hasNext()) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
84 BindingSet result = results.next();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
85 String annotUri = result.getBinding("uri").getValue().stringValue();
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
86 String annotUser = result.getBinding("userUrl").getValue().stringValue();
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
87 String textString = "";
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
88 if (result.getBinding("bodyText") != null) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
89 textString = result.getBinding("bodyText").getValue().stringValue();
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
90 }
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
91
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
92 String xpointer = result.getBinding("target").getValue().stringValue();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
93 String created = result.getBinding("creationDate").getValue().stringValue();
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
94 Annotation annot = new Annotation(xpointer, annotUser, created, textString, null, annotUri, id);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
95 retAnnots.add(annot);
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
96 }
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
97 } catch (Exception e) {
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
98 e.printStackTrace();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
99 throw new TripleStoreSearchError();
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
100 }
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
101 return retAnnots;
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
102 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
103
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
104 /**
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
105 * Sucht im Triplestore nach Annotationen
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
106 *
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
107 * select * from <file:///annotations2> where { ?target <http://www.purl.org/dc/terms/isPartOf>
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
108 * <file:///Volumes/Schlachteplatte/Users/casties/Library/Eclipse/annotator/dev.html>. ?ann
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
109 * <http://www.openannotation.org/ns/hasTarget> ?target. ?ann <http://www.openannotation.org/ns/hasBody> ?body. ?body
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
110 * <http://www.w3.org/2011/content#chars> ?bodyText. }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
111 *
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
112 * @param uri
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
113 * Adresse der Annotierten Ressource, in der Regel nicht mit dem xpointer, sonder die URI der kompletten Ressource
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
114 * oder NULL oder leer
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
115 * @param user
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
116 * Author der Annotationen, entweder als uri der Person oder ein Username, je nachdem wie die Annotatinen angelegt
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
117 * wurden.
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
118 * @param limit
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
119 * @param offset
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
120 * @return
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
121 * @throws TripleStoreHandlerException
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
122 * @throws TripleStoreSearchError
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
123 */
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
124 public List<Annotation> searchByUriUser(String uri, String user, String limit, String offset)
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
125 throws TripleStoreHandlerException, TripleStoreSearchError {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
126
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
127 List<Annotation> retAnnots = new ArrayList<Annotation>();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
128 TripleStoreHandler th = TripleStoreConnection.newTripleStoreHandler();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
129 String queryString = "";
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
130
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
131 String whereString = annotGraph;
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
132
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
133 if (uri != null && !uri.equals("")) {
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
134 whereString += String.format("FILTER (?uri = <%s>)", uri);
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
135 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
136
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
137 if (user != null && !user.equals("")) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
138 if (user.startsWith("http")) {
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
139 whereString += String.format("FILTER (?creator = <%s>)", user);
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
140 } else {
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
141 whereString += String.format("FILTER (?creator = \"%s\")", user);
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
142 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
143 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
144
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
145 queryString = String.format("SELECT * FROM <%s> WHERE {%s}", context, whereString);
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
146
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
147 logger.debug("RDFSearcher:" + queryString);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
148
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
149 try {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
150 TupleQueryResult results = th.querySPARQL(queryString);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
151
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
152 while (results.hasNext()) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
153 BindingSet result = results.next();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
154 String annotatedUri;
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
155 if (uri != null && !uri.equals("")) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
156 annotatedUri = uri;
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
157 } else {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
158 annotatedUri = result.getBinding("uri").getValue().stringValue();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
159 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
160 String annotUser;
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
161 if (user != null && !user.equals("")) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
162 annotUser = user;
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
163 } else {
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
164 annotUser = result.getBinding("creator").getValue().stringValue();
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
165 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
166 String textString = "";
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
167 if (result.getBinding("text") != null) {
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
168 textString = result.getBinding("text").getValue().stringValue();
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
169 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
170 String xpointer = result.getBinding("target").getValue().stringValue();
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
171 String time = result.getBinding("created").getValue().stringValue();
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
172 String annotationUri = result.getBinding("annotation").getValue().stringValue();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
173 Annotation annot = new Annotation(xpointer, annotUser, time, textString, null, annotatedUri, annotationUri);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
174 retAnnots.add(annot);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
175 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
176 } catch (Exception e) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
177 e.printStackTrace();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
178 throw new TripleStoreSearchError();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
179 }
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
180 // TODO Auto-generated method stub
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
181 return retAnnots;
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
182 }
16
667d98fd28bd working on search and update.
casties
parents: 7
diff changeset
183
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
184 public void deleteById(String id) throws TripleStoreHandlerException, TripleStoreSearchError {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
185 if (id == null) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
186 return;
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
187 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
188 TripleStoreHandler th = TripleStoreConnection.newTripleStoreHandler();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
189 // delete triples with id as subject
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
190 /*
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
191 * wish Virtuoso would speak SparQL1.1... String queryString =
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
192 * String.format("WITH <%s> DELETE { <%s> ?p ?o } WHERE { <%s> ?p ?o }", context, id, id);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
193 */
34
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
194 String whereString = annotGraph + String.format(" FILTER(?annotation = <%s>)", id);
bd414fe235b5 now with 100% better sparql.
casties
parents: 33
diff changeset
195 String queryString = String.format("DELETE FROM <%s> {%s} WHERE {%s}", context, baseGraph+nonOptGraph, whereString);
33
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
196
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
197 logger.debug("RDFSearcher:" + queryString);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
198
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
199 try {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
200 th.querySPARQL(queryString);
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
201 } catch (Exception e) {
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
202 e.printStackTrace();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
203 throw new TripleStoreSearchError();
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
204 }
e5f5848892a2 new annotation model basically works.
casties
parents: 30
diff changeset
205 }
17
b0ef5c860464 updating and deleting annotations works now!
casties
parents: 16
diff changeset
206
0
dwinter
parents:
diff changeset
207
dwinter
parents:
diff changeset
208 }