# HG changeset patch # User casties # Date 1393017563 -3600 # Node ID 875a97f8b8daf1ce1954f02fdd2683bdbd089756 # Parent 5b568de5ee0d302efbf7e8e3a42b9e6d3f99a0a1 more quick fixes for neo4j 2.0. diff -r 5b568de5ee0d -r 875a97f8b8da src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java --- a/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Wed Feb 19 14:38:31 2014 +0100 +++ b/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Fri Feb 21 22:19:23 2014 +0100 @@ -62,8 +62,7 @@ this.graphDb = graphDb; nodeIndexes = new ArrayList>(5); // List.set(enum.ordinal(), val) seems not to work. - try ( Transaction tx = graphDb.beginTx() ) - { + try ( Transaction tx = graphDb.beginTx() ) { nodeIndexes.add(NodeTypes.ANNOTATION.ordinal(), graphDb.index().forNodes("annotations")); nodeIndexes.add(NodeTypes.PERSON.ordinal(), graphDb.index().forNodes("persons")); nodeIndexes.add(NodeTypes.TARGET.ordinal(), graphDb.index().forNodes("targets")); @@ -120,7 +119,11 @@ */ public Node getNodeFromIndex(String key, String value, NodeTypes type) { if (key == null || value == null) return null; - Node node = getNodeIndex(type).get(key, value).getSingle(); + Node node = null; + try (Transaction tx = graphDb.beginTx()) { + node = getNodeIndex(type).get(key, value).getSingle(); + tx.success(); + } return node; } @@ -311,13 +314,17 @@ Node pn = getPersonNodeByUri(person.getUriString()); if (pn == null) return false; // optimized version of getGroupsForPersonNode + try (Transaction tx = graphDb.beginTx()) { Iterable rels = pn.getRelationships(RelationTypes.MEMBER_OF); for (Relationship rel : rels) { Node gn = rel.getEndNode(); if (gn.getProperty("uri", "").equals(group.getUriString()) || gn.getProperty("id", "").equals(group.getId())) { + tx.success(); return true; } } + tx.success(); + } return false; } @@ -474,8 +481,12 @@ * @return */ public Annotation getAnnotationById(String id) { + Annotation annot = null; + try ( Transaction tx = graphDb.beginTx() ) { Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle(); - Annotation annot = createAnnotationFromNode(annotNode); + annot = createAnnotationFromNode(annotNode); + tx.success(); + } return annot; } @@ -487,6 +498,7 @@ */ public Annotation createAnnotationFromNode(Node annotNode) { Annotation annot = new Annotation(); + try ( Transaction tx = graphDb.beginTx() ) { annot.setUri((String) annotNode.getProperty("id", null)); annot.setBodyText((String) annotNode.getProperty("bodyText", null)); annot.setBodyUri((String) annotNode.getProperty("bodyUri", null)); @@ -564,7 +576,9 @@ } } annot.setTags(tags); - + + tx.success(); + } return annot; } @@ -813,6 +827,7 @@ // there should be only one Node target = getNodeFromIndex("uri", targetUri, NodeTypes.TARGET); if (target != null) { + try ( Transaction tx = graphDb.beginTx() ) { Iterable relations = target.getRelationships(RelationTypes.ANNOTATES); for (Relationship relation : relations) { Node ann = relation.getStartNode(); @@ -823,6 +838,8 @@ logger.error("ANNOTATES relation does not start with ANNOTATION: " + ann); } } + tx.success(); + } } } if (userUri != null) { diff -r 5b568de5ee0d -r 875a97f8b8da src/main/webapp/annotationBrowser/js/annotation-core.js --- a/src/main/webapp/annotationBrowser/js/annotation-core.js Wed Feb 19 14:38:31 2014 +0100 +++ b/src/main/webapp/annotationBrowser/js/annotation-core.js Fri Feb 21 22:19:23 2014 +0100 @@ -17,13 +17,14 @@ } function createLinkFromURI(uri){ + if (uri == null) return ""; var docUri = uri.replace(docNamespace,viewerAddress); docUri = docUri.replace("?pn","&pn"); return docUri; } function getDCdata(path,obj){ - + if (path == null) return; var splitted = path.split("?"); var docUri=splitted[0];