changeset 29:cf8166ee8918

still working on new annotations...
author casties
date Mon, 07 May 2012 19:50:39 +0200
parents 185db3cac82c
children b37487b756ac
files src/main/java/de/mpiwg/itgroup/annotationManager/Constants/NS.java src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Annotation.java src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java
diffstat 3 files changed, 27 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/Constants/NS.java	Wed May 02 19:31:53 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/Constants/NS.java	Mon May 07 19:50:39 2012 +0200
@@ -8,6 +8,7 @@
     public static final String CNT_NS = "http://www.w3.org/2011/content#";
     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_NS = "http://ontologies.mpiwg-berlin.mpg.de/annotations/";
     public static final String MPIWG_ANNOT_URL = "http://entities.mpiwg-berlin.mpg.de/annotations/";
 
 }
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Annotation.java	Wed May 02 19:31:53 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Annotation.java	Mon May 07 19:50:39 2012 +0200
@@ -9,6 +9,10 @@
  */
 public class Annotation {
 	public String xpointer=null; //if queried xpointer should contain the first xpointer in the xpointers list, if there is more than one.
+	/** page number in text document */
+	public String page=null;
+	/** URL of a display of the page of the document */
+	public String displayUrl=null;
 	public String creator=null;
 	public String time=null;
 	public String text=null;
--- a/src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java	Wed May 02 19:31:53 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java	Mon May 07 19:50:39 2012 +0200
@@ -64,8 +64,6 @@
 
         // 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")) {
@@ -81,20 +79,36 @@
         }
         retQuad.add(new LiteralQuadruple(annotationUrl, NS.DCTERMS_NS + "created", annot.time, context));
 
-        // 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));
+        if (annot.page == null || annot.page == "") {
+            // target without page number (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));
+        } else {
+            // ConstrainedTarget with page number (full URL)
+            retQuad.add(new Quadruple(annot.xpointer, NS.RDF_NS + "type", NS.OAC_NS + "ConstrainedTarget", context));
+            // is target of annotation
+            retQuad.add(new Quadruple(annotationUrl, NS.OAC_NS + "hasTarget", annot.xpointer, context));
+            // constrains Target
+            //retQuad.add(new Quadruple(constraint, NS.OAC_NS + "constrains", annot.xpointer, context));
+            // TextPageConstraint
+            String constraint = createRessourceURL("annotC:");
+            retQuad.add(new Quadruple(constraint, NS.RDF_NS + "type", NS.MPIWG_ANNOT_NS + "TextPageConstraint", context));
+            retQuad.add(new LiteralQuadruple(constraint, NS.MPIWG_ANNOT_NS + "textPage", annot.page, context));
+            // constrains Target
+            retQuad.add(new Quadruple(constraint, NS.OAC_NS + "constrains", annot.xpointer, context));
+            
+        }
 
         // annotation body
         if (annot.url != null && annot.url.startsWith("http://")) {
             // body is resource
-            retQuad.add(new Quadruple(annot.url, NS.RDF_NS + "type", NS.OAC_NS + "Body", context));            
+            retQuad.add(new Quadruple(annot.url, NS.RDF_NS + "type", NS.OAC_NS + "Body", context));
             // is body of annotation
             retQuad.add(new Quadruple(annotationUrl, NS.OAC_NS + "hasBody", annot.url, context));
         } else {
             // body is literal text
-            String annotationtext = createRessourceURL("annotationBody:");
+            String annotationtext = createRessourceURL("annotB:");
             retQuad.add(new Quadruple(annotationtext, NS.RDF_NS + "type", NS.OAC_NS + "Body", context));
             retQuad.add(new Quadruple(annotationtext, NS.RDF_NS + "type", NS.CNT_NS + "ContentAsText", context));
             retQuad.add(new LiteralQuadruple(annotationtext, NS.CNT_NS + "chars", annot.text, context));
@@ -125,7 +139,6 @@
 
     }
 
-
     /**
      * Stores the Annotation in the TripleStore.
      *