Changeset 48:0e00bf8e27fb in AnnotationManagerN4J


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.

Location:
src/main/java/de/mpiwg/itgroup/annotations
Files:
3 edited

Legend:

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

    r40 r48  
    2929   
    3030    /**
    31      * The base URI of the annotation target.
    32      */
    33     protected String targetBaseUri;
     31     * The annotation target.
     32     */
     33    protected Target target;
    3434   
    3535    /**
     
    5353   
    5454    /**
    55      * The uri of the resource that is annotated e.g. a book.
     55     * The Resource that is annotated e.g. a book.
    5656     * The target is part of this resource e.g. a page of a book.
    5757     */
    58     protected String resourceUri;
     58    protected Resource resource;
    5959   
    6060    /**
     
    189189
    190190    /**
     191     * @return the target
     192     */
     193    public Target getTarget() {
     194        return target;
     195    }
     196
     197    /**
     198     * @param target the target to set
     199     */
     200    public void setTarget(Target target) {
     201        this.target = target;
     202    }
     203
     204    /**
    191205     * @return the targetBaseUri
    192206     */
    193207    public String getTargetBaseUri() {
    194         return targetBaseUri;
    195     }
    196 
    197     /**
    198      * @param targetBaseUri the targetBaseUri to set
    199      */
    200     public void setTargetBaseUri(String targetBaseUri) {
    201         this.targetBaseUri = targetBaseUri;
     208        if (target == null) return null;
     209        return target.getUri();
    202210    }
    203211
     
    231239
    232240    /**
     241     * @return the resource
     242     */
     243    public Resource getResource() {
     244        return resource;
     245    }
     246
     247    /**
     248     * @param resource the resource to set
     249     */
     250    public void setResource(Resource resource) {
     251        this.resource = resource;
     252    }
     253
     254    /**
    233255     * @return the resourceUri
    234256     */
    235257    public String getResourceUri() {
    236         return resourceUri;
    237     }
    238 
    239     /**
    240      * @param resourceUri the resourceUri to set
    241      */
    242     public void setResourceUri(String resourceUri) {
    243         this.resourceUri = resourceUri;
     258        if (resource == null) return null;
     259        return resource.getUri();
    244260    }
    245261
  • 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);
  • src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java

    r40 r48  
    4040import de.mpiwg.itgroup.annotations.NS;
    4141import de.mpiwg.itgroup.annotations.Person;
     42import de.mpiwg.itgroup.annotations.Resource;
     43import de.mpiwg.itgroup.annotations.Target;
    4244import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore;
    4345
     
    442444         */
    443445        if (jo.has("uri")) {
    444             annot.setTargetBaseUri(jo.getString("uri"));
     446            annot.setTarget(new Target(jo.getString("uri")));
    445447        }
    446448        /*
     
    448450         */
    449451        if (jo.has("resource")) {
    450             annot.setResourceUri(jo.getString("resource"));
     452            annot.setResource(new Resource(jo.getString("resource")));
    451453        }
    452454        /*
Note: See TracChangeset for help on using the changeset viewer.