Mercurial > hg > AnnotationManager
diff src/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java @ 5:0be9d53a6967
editor for annotations
author | dwinter |
---|---|
date | Tue, 13 Dec 2011 17:43:46 +0100 |
parents | e5f0906c107c |
children | 9393c9c9b916 |
line wrap: on
line diff
--- a/src/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java Fri Dec 02 09:25:37 2011 +0100 +++ b/src/de/mpiwg/itgroup/annotationManager/RDFHandling/Convert.java Tue Dec 13 17:43:46 2011 +0100 @@ -15,10 +15,10 @@ import de.mpiwg.itgroup.annotationManager.Constants.NS; import de.mpiwg.itgroup.annotationManager.Errors.TripleStoreStoreError; import de.mpiwg.itgroup.annotationManager.Errors.XPointerError; -import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler.Quadruple; -import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler.LiteralQuadruple; +import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler.LiteralQuadruple; +import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler.Quadruple; /** * @author dwinter @@ -121,6 +121,7 @@ } + /** * @param annot * @return @@ -131,7 +132,7 @@ String annotation = createRessourceURL("annot:"); if (annot.time==null){ - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'"); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); annot.time=format.format(Calendar.getInstance().getTime()); } @@ -193,7 +194,66 @@ } + + /** + * Hier ist die uri der Annotation angegeben. + * @param annot + * @return + */ + private List<Quadruple> rel2quadruple(Annotation annot) { + + List<Quadruple> retQuad = new ArrayList<Quadruple>(); + + String annotation = createRessourceURL("annot:"); + + if (annot.time==null){ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss'Z'"); + annot.time=format.format(Calendar.getInstance().getTime()); + + } + + //TODO: check type + retQuad.add(new Quadruple(annotation, NS.RDF+"type", NS.ANNOTATION_TYPE+annot.type, ctx)); + + //add author + + + if (annot.creator.startsWith("http")){ + retQuad.add(new Quadruple(annotation, NS.ANNOTATION_NS+"author", annot.creator, ctx)); + } else { + retQuad.add(new LiteralQuadruple(annotation, NS.ANNOTATION_NS+"author", annot.creator, ctx)); + } + + // creation time + retQuad.add(new LiteralQuadruple(annotation, NS.ANNOTATION_NS+"created", annot.time, ctx)); + + String[] xpointerSplitted = annot.xpointer.split("#"); + + if (xpointerSplitted.length>2){ + annotUrl=null; + throw new XPointerError(); + } + + // now add the xpointers + retQuad.add(new Quadruple(annotation, NS.MPIWG_annot+"annotatesDocuviewerText", xpointerSplitted[0], ctx)); + retQuad.add(new Quadruple(annotation, NS.MPIWG_annot+"textSelection", annot.xpointer, ctx)); + + //String annotationtext =createRessourceURL("annotText:"); + + retQuad.add(new Quadruple(annotation, NS.ANNOTATION_NS+"body", annot.url, ctx)); + + retQuad.add(new Quadruple(annot.url, NS.RDF+"type", NS.MPIWG_annot+"ExtendedAnnotation", ctx)); + + + for (Quadruple ret:retQuad){ + logger.debug(ret.toString()); + } + + annotUrl=annotation; + return retQuad; + + } /** * gibt nach die nach aufruf eines Converters erzeuge aktuelle url der annotation zurueck * @return @@ -237,8 +297,10 @@ ChildContext context = (ChildContext)Context.getCurrent(); String user = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreUser"); String pw = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreUserPassword"); + String connectionURL = context.getParameters().getFirstValue("de.mpiwg.itgroup.annotationManager.virtuoso.tripleStoreConnectionURL"); - TripleStoreHandler th = new TripleStoreHandler("jdbc:virtuoso://virtuoso.mpiwg-berlin.mpg.de:1111", user, pw); + //TripleStoreHandler th = new TripleStoreHandler("jdbc:virtuoso://virtuoso.mpiwg-berlin.mpg.de:1111", user, pw); + TripleStoreHandler th = new TripleStoreHandler(connectionURL, user, pw); th.write(annots); } catch (RepositoryException e) { @@ -257,9 +319,6 @@ } - private List<Quadruple> rel2quadruple(Annotation annot) { - // TODO Auto-generated method stub - return new ArrayList<TripleStoreHandler.Quadruple>(); - } + }