Ignore:
Timestamp:
Sep 26, 2012, 4:10:47 PM (12 years ago)
Author:
casties
Branch:
default
Message:

targets and resources of Annotation object are objects now.

File:
1 edited

Legend:

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

    r45 r48  
    488488            String type = (String) target.getProperty("TYPE");
    489489            if (type.equals("TARGET")) {
    490                 annot.setTargetBaseUri((String) target.getProperty("uri", null));
     490                annot.setTarget(new Target((String) target.getProperty("uri", null)));
    491491            } else if (type.equals("RESOURCE")) {
    492                 annot.setResourceUri((String) target.getProperty("uri", null));
    493             }
    494         }
    495         if (annot.getTargetBaseUri() == null) {
     492                annot.setResource(new Resource((String) target.getProperty("uri", null)));
     493            }
     494        }
     495        if (annot.getTarget() == null) {
    496496            logger.error("annotation " + annotNode + " has no target node!");
    497497        }
     
    653653             * the annotation target
    654654             */
    655             String targetBaseUri = annot.getTargetBaseUri();
     655            Target target = annot.getTarget();
    656656            Node targetNode = null;
    657             if (targetBaseUri != null) {
    658                 targetNode = getOrCreateTargetNode(targetBaseUri, NodeTypes.TARGET);
     657            if (target != null) {
     658                targetNode = getOrCreateUriNode(target.getUri(), NodeTypes.TARGET);
    659659                getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, targetNode);
    660660            }
     
    673673             * the annotation resource
    674674             */
    675             String resourceUri = annot.getResourceUri();
    676             if (resourceUri != null) {
    677                 Node resource = getOrCreateTargetNode(resourceUri, NodeTypes.RESOURCE);
    678                 getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, resource);
    679                 getOrCreateRelation(targetNode, RelationTypes.PART_OF, resource);
     675            Resource resource = annot.getResource();
     676            if (resource != null) {
     677                Node resourceNode = getOrCreateUriNode(resource.getUri(), NodeTypes.RESOURCE);
     678                getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, resourceNode);
     679                getOrCreateRelation(targetNode, RelationTypes.PART_OF, resourceNode);
    680680            }
    681681
     
    892892    }
    893893
    894     protected Node getOrCreateTargetNode(String uri, NodeTypes type) {
     894    protected Node getOrCreateUriNode(String uri, NodeTypes type) {
    895895        Index<Node> idx = getNodeIndex(type);
    896896        IndexHits<Node> targets = idx.get("uri", uri);
Note: See TracChangeset for help on using the changeset viewer.