Changeset 67:875a97f8b8da in AnnotationManagerN4J for src


Ignore:
Timestamp:
Feb 21, 2014, 9:19:23 PM (10 years ago)
Author:
casties
Branch:
default
Message:

more quick fixes for neo4j 2.0.

Location:
src/main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java

    r66 r67  
    6363        nodeIndexes = new ArrayList<Index<Node>>(5);
    6464        // List.set(enum.ordinal(), val) seems not to work.
    65         try ( Transaction tx = graphDb.beginTx() )
    66         {
     65        try ( Transaction tx = graphDb.beginTx() ) {
    6766            nodeIndexes.add(NodeTypes.ANNOTATION.ordinal(), graphDb.index().forNodes("annotations"));
    6867            nodeIndexes.add(NodeTypes.PERSON.ordinal(), graphDb.index().forNodes("persons"));
     
    121120    public Node getNodeFromIndex(String key, String value, NodeTypes type) {
    122121        if (key == null || value == null) return null;
    123         Node node = getNodeIndex(type).get(key, value).getSingle();
     122        Node node = null;
     123        try (Transaction tx = graphDb.beginTx()) {
     124            node = getNodeIndex(type).get(key, value).getSingle();
     125            tx.success();
     126        }
    124127        return node;
    125128    }
     
    312315        if (pn == null) return false;
    313316        // optimized version of getGroupsForPersonNode
     317        try (Transaction tx = graphDb.beginTx()) {
    314318        Iterable<Relationship> rels = pn.getRelationships(RelationTypes.MEMBER_OF);
    315319        for (Relationship rel : rels) {
    316320            Node gn = rel.getEndNode();
    317321            if (gn.getProperty("uri", "").equals(group.getUriString()) || gn.getProperty("id", "").equals(group.getId())) {
     322                tx.success();
    318323                return true;
    319324            }
     325        }
     326        tx.success();
    320327        }
    321328        return false;
     
    475482     */
    476483    public Annotation getAnnotationById(String id) {
     484        Annotation annot = null;
     485        try ( Transaction tx = graphDb.beginTx() ) {
    477486        Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle();
    478         Annotation annot = createAnnotationFromNode(annotNode);
     487        annot = createAnnotationFromNode(annotNode);
     488        tx.success();
     489        }
    479490        return annot;
    480491    }
     
    488499    public Annotation createAnnotationFromNode(Node annotNode) {
    489500        Annotation annot = new Annotation();
     501        try ( Transaction tx = graphDb.beginTx() ) {       
    490502        annot.setUri((String) annotNode.getProperty("id", null));
    491503        annot.setBodyText((String) annotNode.getProperty("bodyText", null));
     
    565577        }
    566578        annot.setTags(tags);
    567 
     579       
     580        tx.success();
     581        }
    568582        return annot;
    569583    }
     
    814828            Node target = getNodeFromIndex("uri", targetUri, NodeTypes.TARGET);
    815829            if (target != null) {
     830                try ( Transaction tx = graphDb.beginTx() ) {
    816831                Iterable<Relationship> relations = target.getRelationships(RelationTypes.ANNOTATES);
    817832                for (Relationship relation : relations) {
     
    823838                        logger.error("ANNOTATES relation does not start with ANNOTATION: " + ann);
    824839                    }
     840                }
     841                tx.success();
    825842                }
    826843            }
  • src/main/webapp/annotationBrowser/js/annotation-core.js

    r56 r67  
    1818
    1919function createLinkFromURI(uri){
     20    if (uri == null) return "";
    2021        var docUri = uri.replace(docNamespace,viewerAddress);
    2122        docUri = docUri.replace("?pn","&pn");
     
    2425
    2526function getDCdata(path,obj){
    26        
     27    if (path == null) return;
    2728        var splitted = path.split("?");
    2829        var docUri=splitted[0];
Note: See TracChangeset for help on using the changeset viewer.