Mercurial > hg > AnnotationManagerN4J
diff src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java @ 48:0e00bf8e27fb
targets and resources of Annotation object are objects now.
author | casties |
---|---|
date | Wed, 26 Sep 2012 18:10:47 +0200 |
parents | 707902d468f6 |
children | e2f86ef9b871 |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Wed Sep 26 17:30:52 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Wed Sep 26 18:10:47 2012 +0200 @@ -487,12 +487,12 @@ Node target = rel.getEndNode(); String type = (String) target.getProperty("TYPE"); if (type.equals("TARGET")) { - annot.setTargetBaseUri((String) target.getProperty("uri", null)); + annot.setTarget(new Target((String) target.getProperty("uri", null))); } else if (type.equals("RESOURCE")) { - annot.setResourceUri((String) target.getProperty("uri", null)); + annot.setResource(new Resource((String) target.getProperty("uri", null))); } } - if (annot.getTargetBaseUri() == null) { + if (annot.getTarget() == null) { logger.error("annotation " + annotNode + " has no target node!"); } // get fragment from attribute @@ -652,10 +652,10 @@ /* * the annotation target */ - String targetBaseUri = annot.getTargetBaseUri(); + Target target = annot.getTarget(); Node targetNode = null; - if (targetBaseUri != null) { - targetNode = getOrCreateTargetNode(targetBaseUri, NodeTypes.TARGET); + if (target != null) { + targetNode = getOrCreateUriNode(target.getUri(), NodeTypes.TARGET); getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, targetNode); } @@ -672,11 +672,11 @@ /* * the annotation resource */ - String resourceUri = annot.getResourceUri(); - if (resourceUri != null) { - Node resource = getOrCreateTargetNode(resourceUri, NodeTypes.RESOURCE); - getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, resource); - getOrCreateRelation(targetNode, RelationTypes.PART_OF, resource); + Resource resource = annot.getResource(); + if (resource != null) { + Node resourceNode = getOrCreateUriNode(resource.getUri(), NodeTypes.RESOURCE); + getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, resourceNode); + getOrCreateRelation(targetNode, RelationTypes.PART_OF, resourceNode); } /* @@ -891,7 +891,7 @@ return annotation; } - protected Node getOrCreateTargetNode(String uri, NodeTypes type) { + protected Node getOrCreateUriNode(String uri, NodeTypes type) { Index<Node> idx = getNodeIndex(type); IndexHits<Node> targets = idx.get("uri", uri); Node target = targets.getSingle();