changeset 26:235b91ba8dff

on the way to new annotations...
author casties
date Thu, 26 Apr 2012 11:44:57 +0200
parents 52dff477e45f
children b4a798d417fe
files .classpath .hgignore .settings/org.eclipse.wst.common.project.facet.core.xml libs/jsontoken-1.1-SNAPSHOT.jar pom.xml src/main/java/de/mpiwg/itgroup/annotationManager/Constants/NS.java src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AddAndReadAnnotations.java src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorAnnotations.java src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorResourceImpl.java src/main/java/de/mpiwg/itgroup/annotationManager/restlet/SearchAnnotations.java
diffstat 11 files changed, 64 insertions(+), 84 deletions(-) [+]
line wrap: on
line diff
--- a/.classpath	Wed Apr 25 18:02:44 2012 +0200
+++ b/.classpath	Thu Apr 26 11:44:57 2012 +0200
@@ -12,45 +12,7 @@
 			<attribute name="owner.project.facets" value="jst.web"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="lib" path="libs/TripleStoreManager.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/jena.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/openrdf-sesame-2.3.2-onejar.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/protege-owl.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/protege.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/virt_sesame2.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/virtjdbc3.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
-	<classpathentry kind="lib" path="libs/virtjdbc4.jar">
-		<attributes>
-			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
-		</attributes>
-	</classpathentry>
+	<classpathentry kind="lib" path="libs/TripleStoreManager.jar"/>
+	<classpathentry kind="lib" path="libs/openrdf-sesame-2.3.2-onejar.jar"/>
 	<classpathentry kind="output" path="target/classes"/>
 </classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Thu Apr 26 11:44:57 2012 +0200
@@ -0,0 +1,3 @@
+
+syntax: regexp
+^target$
\ No newline at end of file
--- a/.settings/org.eclipse.wst.common.project.facet.core.xml	Wed Apr 25 18:02:44 2012 +0200
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml	Thu Apr 26 11:44:57 2012 +0200
@@ -6,5 +6,5 @@
   <fixed facet="java"/>
   <installed facet="java" version="1.6"/>
   <installed facet="wst.jsdt.web" version="1.0"/>
-  <installed facet="jst.web" version="2.4"/>
+  <installed facet="jst.web" version="3.0"/>
 </faceted-project>
Binary file libs/jsontoken-1.1-SNAPSHOT.jar has changed
--- a/pom.xml	Wed Apr 25 18:02:44 2012 +0200
+++ b/pom.xml	Thu Apr 26 11:44:57 2012 +0200
@@ -42,6 +42,13 @@
 				</exclusion>
 			</exclusions>
 		</dependency>
+	    <dependency>
+	    	<groupId>com.google.code.gson</groupId>
+	    	<artifactId>gson</artifactId>
+	    	<version>1.4</version>
+	    	<type>jar</type>
+	    	<scope>compile</scope>
+	    </dependency>
 		<dependency>
 			<groupId>org.restlet.jee</groupId>
 			<artifactId>org.restlet</artifactId>
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/Constants/NS.java	Wed Apr 25 18:02:44 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/Constants/NS.java	Thu Apr 26 11:44:57 2012 +0200
@@ -1,11 +1,12 @@
 package de.mpiwg.itgroup.annotationManager.Constants;
 
 public class NS {
-	public static final String MPIWG_PERSONS = "http://entities.mpiwg-berlin.mpg.de/persons/";
-	//public static String ANNOTATION_TYPE="http://www.w3.org/2000/10/annotationType#";
-	public static final String ANNOTATION_NS="http://www.openannotation.org/ns/";
-    public static final String DCTERMS_NS="http://www.purl.org/dc/terms/";
-	public static final String RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-	public static final String MPIWG_annot="http://entities.mpiwg-berlin.mpg.de/annotations/";
-		
+    public static final String MPIWG_PERSONS_URL = "http://entities.mpiwg-berlin.mpg.de/persons/";
+    // public static String
+    // ANNOTATION_TYPE="http://www.w3.org/2000/10/annotationType#";
+    public static final String OAC_NS = "http://www.openannotation.org/ns/";
+    public static final String DCTERMS_NS = "http://www.purl.org/dc/terms/";
+    public static final String RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+    public static final String MPIWG_ANNOT_URL = "http://entities.mpiwg-berlin.mpg.de/annotations/";
+
 }
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java	Wed Apr 25 18:02:44 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java	Thu Apr 26 11:44:57 2012 +0200
@@ -66,9 +66,11 @@
         if (annotationUrl == null) {
             annotationUrl = createRessourceURL("annot:");
         }
-        // type
-        // TODO: where to get types?
-        retQuad.add(new LiteralQuadruple(annotationUrl, NS.RDF + "type", annot.type, context));
+
+        // annotation class
+        retQuad.add(new Quadruple(annotationUrl, NS.RDF_NS + "type", NS.OAC_NS + "Annotation", context));
+        // TODO: what types?
+        //retQuad.add(new LiteralQuadruple(annotationUrl, NS.RDF + "type", annot.type, context));
 
         // author
         if (annot.creator.startsWith("http")) {
@@ -84,23 +86,28 @@
         }
         retQuad.add(new LiteralQuadruple(annotationUrl, NS.DCTERMS_NS + "created", annot.time, context));
 
-        String[] xpointerSplitted = annot.xpointer.split("#");
-
+        // target (full URL)
+        retQuad.add(new Quadruple(annot.xpointer, NS.RDF_NS + "type", NS.OAC_NS + "Target", context));
+        // is target of annotation
+        retQuad.add(new Quadruple(annotationUrl, NS.OAC_NS + "hasTarget", annot.xpointer, context));
+        
+        // now add the xpointers
+        /* String[] xpointerSplitted = annot.xpointer.split("#");
         if (xpointerSplitted.length > 2) {
             throw new XPointerError();
         }
-
-        // now add the xpointers
-        retQuad.add(new Quadruple(annotationUrl, NS.MPIWG_annot + "annotatesDocuviewerText", xpointerSplitted[0], context));
-        retQuad.add(new Quadruple(annotationUrl, NS.MPIWG_annot + "textSelection", annot.xpointer, context));
+        retQuad.add(new Quadruple(annotationUrl, NS.MPIWG_ANNOT_URL + "annotatesDocuviewerText", xpointerSplitted[0], context));
+        retQuad.add(new Quadruple(annotationUrl, NS.MPIWG_ANNOT_URL + "textSelection", annot.xpointer, context));
+        */
 
-        String annotationtext = createRessourceURL("annotText:");
-
-        retQuad.add(new Quadruple(annotationUrl, NS.ANNOTATION_NS + "body", annotationtext, context));
+        // annotation body
+        String annotationtext = createRessourceURL("annotationBody:");
+        
+        retQuad.add(new Quadruple(annotationUrl, NS.OAC_NS + "Body", annotationtext, context));
 
-        retQuad.add(new Quadruple(annotationtext, NS.RDF + "type", NS.MPIWG_annot + "StandardTextNote", context));
+        retQuad.add(new Quadruple(annotationtext, NS.RDF_NS + "type", NS.MPIWG_ANNOT_URL + "StandardTextNote", context));
 
-        retQuad.add(new LiteralQuadruple(annotationtext, NS.MPIWG_annot + "containsText", annot.text, context));
+        retQuad.add(new LiteralQuadruple(annotationtext, NS.MPIWG_ANNOT_URL + "containsText", annot.text, context));
 
         for (Quadruple ret : retQuad) {
             logger.debug(ret.toString());
@@ -145,17 +152,17 @@
         }
 
         // TODO: check type
-        retQuad.add(new Quadruple(annotation, NS.RDF + "type", NS.ANNOTATION_TYPE + annot.type, context));
+        retQuad.add(new Quadruple(annotation, NS.RDF_NS + "type", NS.ANNOTATION_TYPE + annot.type, context));
 
         // add author
         if (annot.creator.startsWith("http")) {
-            retQuad.add(new Quadruple(annotation, NS.ANNOTATION_NS + "author", annot.creator, context));
+            retQuad.add(new Quadruple(annotation, NS.OAC_NS + "author", annot.creator, context));
         } else {
-            retQuad.add(new LiteralQuadruple(annotation, NS.ANNOTATION_NS + "author", annot.creator, context));
+            retQuad.add(new LiteralQuadruple(annotation, NS.OAC_NS + "author", annot.creator, context));
         }
 
         // creation time
-        retQuad.add(new LiteralQuadruple(annotation, NS.ANNOTATION_NS + "created", annot.time, context));
+        retQuad.add(new LiteralQuadruple(annotation, NS.OAC_NS + "created", annot.time, context));
 
         String[] xpointerSplitted = annot.xpointer.split("#");
 
@@ -164,14 +171,14 @@
         }
 
         // now add the xpointers
-        retQuad.add(new Quadruple(annotation, NS.MPIWG_annot + "annotatesDocuviewerText", xpointerSplitted[0], context));
-        retQuad.add(new Quadruple(annotation, NS.MPIWG_annot + "textSelection", annot.xpointer, context));
+        retQuad.add(new Quadruple(annotation, NS.MPIWG_ANNOT_URL + "annotatesDocuviewerText", xpointerSplitted[0], context));
+        retQuad.add(new Quadruple(annotation, NS.MPIWG_ANNOT_URL + "textSelection", annot.xpointer, context));
 
         // String annotationtext =createRessourceURL("annotText:");
 
-        retQuad.add(new Quadruple(annotation, NS.ANNOTATION_NS + "body", annot.url, context));
+        retQuad.add(new Quadruple(annotation, NS.OAC_NS + "body", annot.url, context));
 
-        retQuad.add(new Quadruple(annot.url, NS.RDF + "type", NS.MPIWG_annot + "ExtendedAnnotation", context));
+        retQuad.add(new Quadruple(annot.url, NS.RDF_NS + "type", NS.MPIWG_ANNOT_URL + "ExtendedAnnotation", context));
 
         for (Quadruple ret : retQuad) {
             logger.debug(ret.toString());
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AddAndReadAnnotations.java	Wed Apr 25 18:02:44 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AddAndReadAnnotations.java	Thu Apr 26 11:44:57 2012 +0200
@@ -154,8 +154,8 @@
 			RestServer restServer = (RestServer) getApplication();
 			
 			String userID= annot.creator;
-			if (userID.startsWith(NS.MPIWG_PERSONS)){
-				userID=userID.replace(NS.MPIWG_PERSONS, ""); //entferne NAMESPACE
+			if (userID.startsWith(NS.MPIWG_PERSONS_URL)){
+				userID=userID.replace(NS.MPIWG_PERSONS_URL, ""); //entferne NAMESPACE
 			}
 			String userName=restServer.getUserNameFromLdap(userID);
 			userObject.put("name",userName);
@@ -502,7 +502,7 @@
 		//username should be a URI, if not it will set to the MPIWG namespace defined in de.mpiwg.itgroup.annotationManager.Constants.NS
 		String usernameOrig=username;
 		if (!username.startsWith("http"))
-			username=NS.MPIWG_PERSONS+username;
+			username=NS.MPIWG_PERSONS_URL+username;
 		
 		if (mode.equals("complexAnnotation")){// Annotation mit text in externer ressource
 			
@@ -590,7 +590,7 @@
 
 		//username should be a URI, if not it will set to the MPIWG namespace defined in de.mpiwg.itgroup.annotationManager.Constants.NS
 		if (!username.startsWith("http"))
-			username=NS.MPIWG_PERSONS+username;
+			username=NS.MPIWG_PERSONS_URL+username;
 		
 		return new Annotation(xpointer, username, null, text, type, url);
 	}
@@ -675,7 +675,7 @@
 		
 		//username should be a URI, if not it will set to the MPIWG namespace defined in de.mpiwg.itgroup.annotationManager.Constants.NS
 		if (!username.startsWith("http"))
-			username=NS.MPIWG_PERSONS+username;
+			username=NS.MPIWG_PERSONS_URL+username;
 		
 		return new Annotation(xpointer, username, null, text, null);
 	}
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorAnnotations.java	Wed Apr 25 18:02:44 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorAnnotations.java	Thu Apr 26 11:44:57 2012 +0200
@@ -253,7 +253,7 @@
         // de.mpiwg.itgroup.annotationManager.Constants.NS
         String usernameOrig = username;
         if (!username.startsWith("http"))
-            username = NS.MPIWG_PERSONS + username;
+            username = NS.MPIWG_PERSONS_URL + username;
 
         if (mode.equals("complexAnnotation")) {// Annotation mit text in externer ressource
 
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorResourceImpl.java	Wed Apr 25 18:02:44 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorResourceImpl.java	Thu Apr 26 11:44:57 2012 +0200
@@ -175,8 +175,8 @@
                 userObject.put("uri", annot.creator);
                 // make short user id
                 String userID = annot.creator;
-                if (userID.startsWith(NS.MPIWG_PERSONS)) {
-                    userID = userID.replace(NS.MPIWG_PERSONS, ""); // entferne NAMESPACE
+                if (userID.startsWith(NS.MPIWG_PERSONS_URL)) {
+                    userID = userID.replace(NS.MPIWG_PERSONS_URL, ""); // entferne NAMESPACE
                 }
                 // save as id
                 userObject.put("id", userID);
@@ -321,7 +321,7 @@
             if (username.startsWith("http")) {
                 userUri = username;
             } else {
-                userUri = NS.MPIWG_PERSONS + username;
+                userUri = NS.MPIWG_PERSONS_URL + username;
             }
         }
         // TODO: should we overwrite the creator?
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/SearchAnnotations.java	Wed Apr 25 18:02:44 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/restlet/SearchAnnotations.java	Thu Apr 26 11:44:57 2012 +0200
@@ -150,8 +150,8 @@
 			RestServer restServer = (RestServer) getApplication();
 			
 			String userID= annot.creator;
-			if (userID.startsWith(NS.MPIWG_PERSONS)){
-				userID=userID.replace(NS.MPIWG_PERSONS, ""); //entferne NAMESPACE
+			if (userID.startsWith(NS.MPIWG_PERSONS_URL)){
+				userID=userID.replace(NS.MPIWG_PERSONS_URL, ""); //entferne NAMESPACE
 			}
 			String userName=restServer.getUserNameFromLdap(userID);
 			userObject.put("name",userName);
@@ -365,7 +365,7 @@
 		//username should be a URI, if not it will set to the MPIWG namespace defined in de.mpiwg.itgroup.annotationManager.Constants.NS
 		String usernameOrig=username;
 		if (!username.startsWith("http"))
-			username=NS.MPIWG_PERSONS+username;
+			username=NS.MPIWG_PERSONS_URL+username;
 		
 		if (mode.equals("complexAnnotation")){// Annotation mit text in externer ressource
 			
@@ -448,7 +448,7 @@
 
 		//username should be a URI, if not it will set to the MPIWG namespace defined in de.mpiwg.itgroup.annotationManager.Constants.NS
 		if (!username.startsWith("http"))
-			username=NS.MPIWG_PERSONS+username;
+			username=NS.MPIWG_PERSONS_URL+username;
 		
 		return new Annotation(xpointer, username, null, text, type, url);
 	}
@@ -533,7 +533,7 @@
 		
 		//username should be a URI, if not it will set to the MPIWG namespace defined in de.mpiwg.itgroup.annotationManager.Constants.NS
 		if (!username.startsWith("http"))
-			username=NS.MPIWG_PERSONS+username;
+			username=NS.MPIWG_PERSONS_URL+username;
 		
 		return new Annotation(xpointer, username, null, text, null);
 	}