diff src/de/mpiwg/itgroup/annotationManager/restlet/SearchAnnotations.java @ 17:b0ef5c860464

updating and deleting annotations works now! more cleanup.
author casties
date Thu, 22 Mar 2012 21:37:16 +0100
parents 667d98fd28bd
children
line wrap: on
line diff
--- a/src/de/mpiwg/itgroup/annotationManager/restlet/SearchAnnotations.java	Thu Mar 22 10:54:56 2012 +0100
+++ b/src/de/mpiwg/itgroup/annotationManager/restlet/SearchAnnotations.java	Thu Mar 22 21:37:16 2012 +0100
@@ -29,8 +29,7 @@
 
 import de.mpiwg.itgroup.annotationManager.Constants.NS;
 import de.mpiwg.itgroup.annotationManager.Errors.TripleStoreSearchError;
-import de.mpiwg.itgroup.annotationManager.RDFHandling.Convert;
-import de.mpiwg.itgroup.annotationManager.RDFHandling.Convert.Annotation;
+import de.mpiwg.itgroup.annotationManager.RDFHandling.Annotation;
 import de.mpiwg.itgroup.annotationManager.RDFHandling.RDFSearcher;
 import de.mpiwg.itgroup.annotationManager.drupal.AnnotationHandler;
 import de.mpiwg.itgroup.annotationManager.drupal.UnknowUserException;
@@ -97,9 +96,9 @@
 				"<td><a href=\"%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\">%s</a></td><td><a href=\"%s\">%s</a></td></div>";
 		try {
 			
-			List<Convert.Annotation> annots=searcher.searchByUriUser(uri,user,limit,offset);
+			List<Annotation> annots=searcher.searchByUriUser(uri,user,limit,offset);
 
-			for (Convert.Annotation annot:annots){
+			for (Annotation annot:annots){
 				
 				
 				RestServer restServer = (RestServer) getApplication();
@@ -107,10 +106,10 @@
 				List<String> xpointer = new ArrayList<String>();
 
 				if (annot.xpointers==null || annot.xpointers.size()==0)
-					retString+=String.format(lineFormat, userName,userName,annot.url,annot.url,annot.time,annot.text,annot.xpointer,annot.xpointer,annot.annotationUri,annot.annotationUri);
+					retString+=String.format(lineFormat, userName,userName,annot.url,annot.url,annot.time,annot.text,annot.xpointer,annot.xpointer,annot.getAnnotationUri(),annot.getAnnotationUri());
 				else {
 					for(String xpointerString:annot.xpointers){
-						retString+=String.format(lineFormat, userName,userName,annot.url,annot.url,annot.time,annot.text,xpointerString,xpointerString,annot.annotationUri,annot.annotationUri);
+						retString+=String.format(lineFormat, userName,userName,annot.url,annot.url,annot.time,annot.text,xpointerString,xpointerString,annot.getAnnotationUri(),annot.getAnnotationUri());
 					}
 				}
 			
@@ -139,7 +138,7 @@
 	 * @param annot
 	 * @return
 	 */
-	public JSONObject annot2AnnotatorJSON(Convert.Annotation annot){
+	public JSONObject annot2AnnotatorJSON(Annotation annot){
 		JSONObject jo = new JSONObject();
 		try {
 			jo.put("text", annot.text);
@@ -169,7 +168,7 @@
 				}
 			}
 			jo.put("ranges", transformToRanges(xpointer));
-			jo.put("id", annot.annotationUri);
+			jo.put("id", annot.getAnnotationUri());
 			return jo;
 		} catch (JSONException e) {
 			// TODO Auto-generated catch block
@@ -196,10 +195,10 @@
 		JSONArray ja;
 		try {
 			
-			List<Convert.Annotation> annots=searcher.searchByUriUser(uri,user,limit,offset);
+			List<Annotation> annots=searcher.searchByUriUser(uri,user,limit,offset);
 
 			ja = new JSONArray();
-			for (Convert.Annotation annot:annots){
+			for (Annotation annot:annots){
 //				JSONObject jo = new JSONObject();
 //				jo.put("text", annot.text);
 //				jo.put("uri",annot.url);
@@ -325,8 +324,8 @@
 	 * 
 	 * @return
 	 */
-	protected Convert.Annotation handleForm(Representation entity) {
-		Convert.Annotation annot;
+	protected Annotation handleForm(Representation entity) {
+		Annotation annot;
 		Form form = new Form(entity);
 		String username = form.getValues("username");
 		String mode = form.getValues("mode");
@@ -384,7 +383,7 @@
 				return null;
 			}
 			try {
-				annot= new Convert.Annotation(xpointer, username, null, text, type, newAnnot.getString("node_uri"));
+				annot= new Annotation(xpointer, username, null, text, type, newAnnot.getString("node_uri"));
 			} catch (JSONException e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
@@ -392,7 +391,7 @@
 				return null;
 			}
 		} else
-			annot = new Convert.Annotation(xpointer, username, null, text,
+			annot = new Annotation(xpointer, username, null, text,
 				type, url);
 		return annot;
 	}
@@ -451,7 +450,7 @@
 		if (!username.startsWith("http"))
 			username=NS.MPIWG_PERSONS+username;
 		
-		return new Convert.Annotation(xpointer, username, null, text, type, url);
+		return new Annotation(xpointer, username, null, text, type, url);
 	}
 
 	/**
@@ -471,9 +470,9 @@
 	 * @return
 	 * @throws JSONException
 	 */
-	public Convert.Annotation handleAnnotatorSchema(JSONObject jo,
+	public Annotation handleAnnotatorSchema(JSONObject jo,
 			Representation entity) throws JSONException {
-		Convert.Annotation annot;
+		Annotation annot;
 		String url = jo.getString("uri");
 		String text = jo.getString("text");
 
@@ -536,7 +535,7 @@
 		if (!username.startsWith("http"))
 			username=NS.MPIWG_PERSONS+username;
 		
-		return new Convert.Annotation(xpointer, username, null, text, null);
+		return new Annotation(xpointer, username, null, text, null);
 	}
 
 }