changeset 43:d1bef7952bec

more work on resources and targets.
author casties
date Wed, 26 Sep 2012 16:27:52 +0200
parents aa2bb7ac04d9
children 5e9d90461929
files src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java
diffstat 1 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java	Wed Sep 26 16:12:46 2012 +0200
+++ b/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java	Wed Sep 26 16:27:52 2012 +0200
@@ -95,6 +95,22 @@
     }
 
     /**
+     * @param resourceUri
+     * @return
+     */
+    public Node getResourceNodeByUri(String resourceUri) {
+        return getNodeFromIndex("uri", resourceUri, NodeTypes.RESOURCE);
+    }
+
+    /**
+     * @param targetUri
+     * @return
+     */
+    public Node getTargetNodeByUri(String targetUri) {
+        return getNodeFromIndex("uri", targetUri, NodeTypes.RESOURCE);
+    }
+
+    /**
      * Returns the Node with the given key and value.
      * Key has to be indexed.
      * 
@@ -566,6 +582,23 @@
 
     }
 
+    /**
+     * @param resourceNode
+     * @return
+     */
+    public Resource createResourceFromNode(Node resourceNode) {
+        return (Resource) createUriFromNode(resourceNode);
+    }
+    
+    /**
+     * @param targetNode
+     * @return
+     */
+    public Target createTargetFromNode(Node targetNode) {
+        return (Target) createUriFromNode(targetNode);
+    }
+    
+    
     protected Uri createUriFromNode(Node uriNode) {
         if (uriNode == null) return null;
         String uri = (String) uriNode.getProperty("uri", null);
@@ -1072,8 +1105,12 @@
         Node tag = getNodeFromIndex("uri", resourceUri, NodeTypes.RESOURCE);
         Iterable<Relationship> rels = tag.getRelationships(Direction.INCOMING, RelationTypes.ANNOTATES);
         for (Relationship rel : rels) {
-            Node node = rel.getStartNode();
-            ret.add(createAnnotationFromNode(node));
+            Node an = rel.getStartNode();
+            Node rn = rel.getEndNode();
+            if (rn.getProperty("TYPE", "").equals("RESOURCE")) {
+                logger.error("getAnnotationsByResource got ANNOTATES != RESOURCE");
+            }
+            ret.add(createAnnotationFromNode(an));
         }
         return ret;
     }