Mercurial > hg > AnnotationManagerN4J
changeset 45:707902d468f6
store reads and sends annotations resources now.
author | casties |
---|---|
date | Wed, 26 Sep 2012 17:28:31 +0200 |
parents | 5e9d90461929 |
children | 54a4a96ad0c3 |
files | src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/GroupMembersResource.java src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/PersonsResource.java |
diffstat | 3 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Wed Sep 26 17:01:59 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Wed Sep 26 17:28:31 2012 +0200 @@ -135,7 +135,7 @@ * @return */ @SuppressWarnings("unchecked") - public <T extends Actor> List<T> getActors(String key, String query, NodeTypes type) { + protected <T extends Actor> List<T> getActors(String key, String query, NodeTypes type) { ArrayList<T> actors = new ArrayList<T>(); Index<Node> idx = getNodeIndex(type); if (key == null) { @@ -182,7 +182,7 @@ * @return */ @SuppressWarnings("unchecked") - public <T extends Uri> List<T> getUris(String key, String query, NodeTypes type) { + protected <T extends Uri> List<T> getUris(String key, String query, NodeTypes type) { ArrayList<T> uris = new ArrayList<T>(); Index<Node> idx = getNodeIndex(type); if (key == null) { @@ -481,15 +481,21 @@ annot.setBodyText((String) annotNode.getProperty("bodyText", null)); annot.setBodyUri((String) annotNode.getProperty("bodyUri", null)); /* - * get annotation target from relation + * get annotation target and resource from relation */ - Relationship targetRel = getRelation(annotNode, RelationTypes.ANNOTATES, null); - if (targetRel != null) { - Node target = targetRel.getEndNode(); - annot.setTargetBaseUri((String) target.getProperty("uri", null)); - } else { + for (Relationship rel : annotNode.getRelationships(RelationTypes.ANNOTATES)) { + Node target = rel.getEndNode(); + String type = (String) target.getProperty("TYPE"); + if (type.equals("TARGET")) { + annot.setTargetBaseUri((String) target.getProperty("uri", null)); + } else if (type.equals("RESOURCE")) { + annot.setResourceUri((String) target.getProperty("uri", null)); + } + } + if (annot.getTargetBaseUri() == null) { logger.error("annotation " + annotNode + " has no target node!"); } + // get fragment from attribute annot.setTargetFragment((String) annotNode.getProperty("targetFragment", null)); String ft = (String) annotNode.getProperty("fragmentType", null); if (ft != null) {
--- a/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/GroupMembersResource.java Wed Sep 26 17:01:59 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/GroupMembersResource.java Wed Sep 26 17:28:31 2012 +0200 @@ -57,7 +57,7 @@ result += "</form>\n"; result += String.format("<form method=\"post\" action=\"%s\">\n", thisUrl); result += "<p>Add new member: <select name=\"add_member\">\n"; - for (Actor p : store.getActors("uri", "*", NodeTypes.PERSON)) { + for (Person p : store.getPersons("uri", "*")) { result += String.format("<option value=\"%s\">%s</option>\n", p.getIdString(), p.getName()); } result += "</select>\n";
--- a/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/PersonsResource.java Wed Sep 26 17:01:59 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/PersonsResource.java Wed Sep 26 17:28:31 2012 +0200 @@ -72,8 +72,8 @@ // list all groups result = "<html><body>\n<h1>Persons</h1>\n<table>"; result += "<tr><th>id</th><th>name</th><th>uri</th></tr>"; - List<Actor> persons = store.getActors("uri", "*", NodeTypes.PERSON); - for (Actor person : persons) { + List<Person> persons = store.getPersons("uri", "*"); + for (Person person : persons) { Reference url = this.getReference().clone(); url.addSegment(person.getId()); result += String.format("<tr><td><a href=\"%s\">%s</a></td><td>%s</td><td>%s</td></tr>\n", url,