Changeset 40:03e0f7574224 in AnnotationManagerN4J
- Timestamp:
- Sep 26, 2012, 12:56:42 PM (12 years ago)
- Branch:
- default
- Location:
- src/main/java/de/mpiwg/itgroup/annotations
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/de/mpiwg/itgroup/annotations/Annotation.java
r20 r40 39 39 40 40 /** 41 * The types of annotation target s.41 * The types of annotation target fragments. 42 42 * 43 43 */ … … 50 50 */ 51 51 protected FragmentTypes fragmentType; 52 53 54 /** 55 * The uri of the resource that is annotated e.g. a book. 56 * The target is part of this resource e.g. a page of a book. 57 */ 58 protected String resourceUri; 52 59 53 60 /** … … 224 231 225 232 /** 233 * @return the resourceUri 234 */ 235 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; 244 } 245 246 /** 226 247 * @return the creator 227 248 */ -
src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java
r36 r40 528 528 */ 529 529 String targetBaseUri = annot.getTargetBaseUri(); 530 Node targetNode = null; 530 531 if (targetBaseUri != null) { 531 Node target = getOrCreateTargetNode(targetBaseUri);532 getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, target );532 targetNode = getOrCreateTargetNode(targetBaseUri, NodeTypes.TARGET); 533 getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, targetNode); 533 534 } 534 535 … … 541 542 annotNode.setProperty("targetFragment", targetFragment); 542 543 annotNode.setProperty("fragmentType", fragmentType.name()); 544 } 545 546 /* 547 * the annotation resource 548 */ 549 String resourceUri = annot.getResourceUri(); 550 if (resourceUri != null) { 551 Node resource = getOrCreateTargetNode(resourceUri, NodeTypes.RESOURCE); 552 getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, resource); 553 getOrCreateRelation(targetNode, RelationTypes.PART_OF, resource); 543 554 } 544 555 … … 712 723 */ 713 724 protected Relationship getOrCreateRelation(Node start, RelationshipType type, Node end) { 725 if (start == null || end == null) return null; 714 726 if (start.hasRelationship()) { 715 727 // there are relations … … 754 766 } 755 767 756 protected Node getOrCreateTargetNode(String uri ) {757 Index<Node> idx = getNodeIndex( NodeTypes.TARGET);768 protected Node getOrCreateTargetNode(String uri, NodeTypes type) { 769 Index<Node> idx = getNodeIndex(type); 758 770 IndexHits<Node> targets = idx.get("uri", uri); 759 771 Node target = targets.getSingle(); … … 763 775 try { 764 776 target = graphDb.createNode(); 765 target.setProperty("TYPE", NodeTypes.TARGET.name());777 target.setProperty("TYPE", type.name()); 766 778 target.setProperty("uri", uri); 767 779 idx.add(target, "uri", uri); -
src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java
r34 r40 24 24 import de.mpiwg.itgroup.annotations.Annotation; 25 25 import de.mpiwg.itgroup.annotations.Person; 26 import de.mpiwg.itgroup.annotations.Tag;27 26 import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore; 28 27 import de.mpiwg.itgroup.annotations.restlet.utils.JSONObjectComparator; -
src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java
r22 r40 188 188 jo.put("text", annot.getBodyText()); 189 189 jo.put("uri", annot.getTargetBaseUri()); 190 if (annot.getResourceUri() != null) { 191 jo.put("resource", annot.getResourceUri()); 192 } 190 193 191 194 /* … … 442 445 } 443 446 /* 447 * resource uri 448 */ 449 if (jo.has("resource")) { 450 annot.setResourceUri(jo.getString("resource")); 451 } 452 /* 444 453 * annotation text 445 454 */
Note: See TracChangeset
for help on using the changeset viewer.