Mercurial > hg > AnnotationManagerN4J
changeset 12:5928c5d9aae8
more work on permissions...
author | casties |
---|---|
date | Fri, 13 Jul 2012 15:02:06 +0200 |
parents | bc90aaeb925d |
children | abe25edf2178 |
files | src/main/java/de/mpiwg/itgroup/annotations/Group.java src/main/java/de/mpiwg/itgroup/annotations/Person.java src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java |
diffstat | 3 files changed, 424 insertions(+), 365 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/Group.java Fri Jul 13 11:24:39 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/Group.java Fri Jul 13 15:02:06 2012 +0200 @@ -10,9 +10,16 @@ public class Group extends Actor { public Group(String id) { + super(); this.id = id; } + public Group(String uri, String name) { + super(); + this.uri = uri; + this.name = name; + } + @Override public boolean isGroup() { return true;
--- a/src/main/java/de/mpiwg/itgroup/annotations/Person.java Fri Jul 13 11:24:39 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/Person.java Fri Jul 13 15:02:06 2012 +0200 @@ -9,19 +9,20 @@ */ public class Person extends Actor { + public Person() { + } + + public Person(String id) { + super(); + this.id = id; + } + public Person(String uri, String name) { super(); this.uri = uri; this.name = name; } - public Person() { - } - - public Person(String id) { - this.id = id; - } - @Override public boolean isGroup() { return false;
--- a/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Fri Jul 13 11:24:39 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java Fri Jul 13 15:02:06 2012 +0200 @@ -20,6 +20,7 @@ import de.mpiwg.itgroup.annotations.Actor; import de.mpiwg.itgroup.annotations.Annotation; import de.mpiwg.itgroup.annotations.Annotation.FragmentTypes; +import de.mpiwg.itgroup.annotations.Group; import de.mpiwg.itgroup.annotations.Person; /** @@ -28,388 +29,438 @@ */ public class AnnotationStore { - protected static Logger logger = Logger.getLogger(AnnotationStore.class); + protected static Logger logger = Logger.getLogger(AnnotationStore.class); + + protected GraphDatabaseService graphDb; - protected GraphDatabaseService graphDb; - - public static enum NodeTypes { - ANNOTATION, PERSON, TARGET - } + public static enum NodeTypes { + ANNOTATION, PERSON, TARGET + } - protected List<Index<Node>> nodeIndexes; - - public static enum RelationTypes implements RelationshipType { - ANNOTATES, CREATED, PERMITS - } + protected List<Index<Node>> nodeIndexes; - public static String ANNOTATION_URI_BASE = "http://entities.mpiwg-berlin.mpg.de/annotations/"; + public static enum RelationTypes implements RelationshipType { + ANNOTATES, CREATED, PERMITS_ADMIN, PERMITS_DELETE, PERMITS_UPDATE, PERMITS_READ + } + + public static String ANNOTATION_URI_BASE = "http://entities.mpiwg-berlin.mpg.de/annotations/"; - public AnnotationStore(GraphDatabaseService graphDb) { - super(); - this.graphDb = graphDb; - nodeIndexes = new ArrayList<Index<Node>>(3); - // List.set(enum.ordinal(), val) seems not to work. - nodeIndexes.add(NodeTypes.ANNOTATION.ordinal(), graphDb.index().forNodes("annotations")); - nodeIndexes.add(NodeTypes.PERSON.ordinal(), graphDb.index().forNodes("persons")); - nodeIndexes.add(NodeTypes.TARGET.ordinal(), graphDb.index().forNodes("targets")); - } + public AnnotationStore(GraphDatabaseService graphDb) { + super(); + this.graphDb = graphDb; + nodeIndexes = new ArrayList<Index<Node>>(3); + // List.set(enum.ordinal(), val) seems not to work. + nodeIndexes.add(NodeTypes.ANNOTATION.ordinal(), graphDb.index().forNodes("annotations")); + nodeIndexes.add(NodeTypes.PERSON.ordinal(), graphDb.index().forNodes("persons")); + nodeIndexes.add(NodeTypes.TARGET.ordinal(), graphDb.index().forNodes("targets")); + } - protected Index<Node> getNodeIndex(NodeTypes type) { - return nodeIndexes.get(type.ordinal()); - } - - /** - * Returns the Annotation with the given id. - * - * @param id - * @return - */ - public Annotation getAnnotationById(String id) { - Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle(); - Annotation annot = createAnnotationFromNode(annotNode); - return annot; - } + protected Index<Node> getNodeIndex(NodeTypes type) { + return nodeIndexes.get(type.ordinal()); + } + + /** + * Returns the Annotation with the given id. + * + * @param id + * @return + */ + public Annotation getAnnotationById(String id) { + Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle(); + Annotation annot = createAnnotationFromNode(annotNode); + return annot; + } - /** - * Returns an Annotation object from an annotation-Node. - * - * @param annotNode - * @return - */ - public Annotation createAnnotationFromNode(Node annotNode) { - Annotation annot = new Annotation(); - annot.setUri((String) annotNode.getProperty("id", null)); - annot.setBodyText((String) annotNode.getProperty("bodyText", null)); - annot.setBodyUri((String) annotNode.getProperty("bodyUri", null)); - // get annotation target from relation - Iterable<Relationship> targetRels = annotNode - .getRelationships(RelationTypes.ANNOTATES); - for (Relationship targetRel : targetRels) { - Node target = targetRel.getEndNode(); - annot.setTargetBaseUri((String) target.getProperty("uri", null)); - // just the first one - break; - } - annot.setTargetFragment((String) annotNode.getProperty( - "targetFragment", null)); - String ft = (String) annotNode.getProperty("fragmentType", null); - if (ft != null) { - annot.setFragmentType(FragmentTypes.valueOf(ft)); - } - // get creator from relation - Iterable<Relationship> creatorRels = annotNode - .getRelationships(RelationTypes.CREATED); - for (Relationship creatorRel : creatorRels) { - Node creatorNode = creatorRel.getStartNode(); - String uri = (String) creatorNode.getProperty("uri", null); - String name = (String) creatorNode.getProperty("name", null); - Actor creator = new Person(uri, name); + /** + * Returns an Annotation object from an annotation-Node. + * + * @param annotNode + * @return + */ + public Annotation createAnnotationFromNode(Node annotNode) { + Annotation annot = new Annotation(); + annot.setUri((String) annotNode.getProperty("id", null)); + annot.setBodyText((String) annotNode.getProperty("bodyText", null)); + annot.setBodyUri((String) annotNode.getProperty("bodyUri", null)); + // get annotation target from relation + Relationship targetRel = getRelation(annotNode, RelationTypes.ANNOTATES, null); + if (targetRel != null) { + Node target = targetRel.getEndNode(); + annot.setTargetBaseUri((String) target.getProperty("uri", null)); + } else { + logger.error("annotation "+annotNode+" has no target node!"); + } + annot.setTargetFragment((String) annotNode.getProperty("targetFragment", null)); + String ft = (String) annotNode.getProperty("fragmentType", null); + if (ft != null) { + annot.setFragmentType(FragmentTypes.valueOf(ft)); + } + // get creator from relation + Relationship creatorRel = getRelation(annotNode, RelationTypes.CREATED, null); + if (creatorRel != null) { + Node creatorNode = creatorRel.getStartNode(); + Actor creator = createActorFromNode(creatorNode); annot.setCreator(creator); - // just the first one - break; - } - annot.setCreated((String) annotNode.getProperty("created", null)); - return annot; - } + } else { + logger.error("annotation "+annotNode+" has no creator node!"); + } + // get creation date + annot.setCreated((String) annotNode.getProperty("created", null)); + // get permissions + Relationship adminRel = getRelation(annotNode, RelationTypes.PERMITS_ADMIN, null); + if (adminRel != null) { + Node adminNode = adminRel.getEndNode(); + //FIXME + } + + return annot; + } - /** - * Store a new annotation in the store or update an existing one. Returns - * the stored annotation. - * - * @param annot - * @return - */ - public Annotation storeAnnotation(Annotation annot) { - Node annotNode = null; - Transaction tx = graphDb.beginTx(); - try { - /* - * create or get the annotation - */ - String id = annot.getUri(); - if (id == null) { - id = createRessourceURI("annot:"); - } - annotNode = getOrCreateAnnotationNode(id); + /** + * Returns an Actor object from a node. + * + * @param actorNode + * @return + */ + protected Actor createActorFromNode(Node actorNode) { + String uri = (String) actorNode.getProperty("uri", null); + String name = (String) actorNode.getProperty("name", null); + String type = (String) actorNode.getProperty("TYPE", null); + Actor creator = null; + if (type != null && type.equals("PERSON")) { + creator = new Person(uri, name); + } else if (type != null && type.equals("GROUP")) { + creator = new Group(uri, name); + } + return creator; + } - /* - * the annotation body - */ - String bodyText = annot.getBodyText(); - if (bodyText != null) { - annotNode.setProperty("bodyText", bodyText); - } - String bodyUri = annot.getBodyUri(); - if (bodyUri != null) { - annotNode.setProperty("bodyUri", bodyUri); - } + /** + * Store a new annotation in the store or update an existing one. Returns + * the stored annotation. + * + * @param annot + * @return + */ + public Annotation storeAnnotation(Annotation annot) { + Node annotNode = null; + Transaction tx = graphDb.beginTx(); + try { + /* + * create or get the annotation + */ + String id = annot.getUri(); + if (id == null) { + id = createRessourceURI("annot:"); + } + annotNode = getOrCreateAnnotationNode(id); - /* - * the annotation target - */ - String targetBaseUri = annot.getTargetBaseUri(); - if (targetBaseUri != null) { - Node target = getOrCreateTargetNode(targetBaseUri); - getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, target); - } + /* + * the annotation body + */ + String bodyText = annot.getBodyText(); + if (bodyText != null) { + annotNode.setProperty("bodyText", bodyText); + } + String bodyUri = annot.getBodyUri(); + if (bodyUri != null) { + annotNode.setProperty("bodyUri", bodyUri); + } - /* - * The fragment part of the annotation target. - */ - String targetFragment = annot.getTargetFragment(); - FragmentTypes fragmentType = annot.getFragmentType(); - if (targetFragment != null) { - annotNode.setProperty("targetFragment", targetFragment); - annotNode.setProperty("fragmentType", fragmentType.name()); - } + /* + * the annotation target + */ + String targetBaseUri = annot.getTargetBaseUri(); + if (targetBaseUri != null) { + Node target = getOrCreateTargetNode(targetBaseUri); + getOrCreateRelation(annotNode, RelationTypes.ANNOTATES, target); + } - /* - * The creator of this annotation. - */ - Actor creator = annot.getCreator(); - if (creator != null) { - Node creatorNode = getOrCreatePersonNode(creator); - getOrCreateRelation(creatorNode, RelationTypes.CREATED, annotNode); - } + /* + * The fragment part of the annotation target. + */ + String targetFragment = annot.getTargetFragment(); + FragmentTypes fragmentType = annot.getFragmentType(); + if (targetFragment != null) { + annotNode.setProperty("targetFragment", targetFragment); + annotNode.setProperty("fragmentType", fragmentType.name()); + } - /* - * The creation date of this annotation. - */ - String created = annot.getCreated(); - if (created != null) { - annotNode.setProperty("created", created); - } - - /* - * Permissions for this annotation. - */ - Actor admin = annot.getAdminPermission(); - if (admin != null) { - - } + /* + * The creator of this annotation. + */ + Actor creator = annot.getCreator(); + if (creator != null) { + Node creatorNode = getOrCreatePersonNode(creator); + getOrCreateRelation(creatorNode, RelationTypes.CREATED, annotNode); + } + + /* + * The creation date of this annotation. + */ + String created = annot.getCreated(); + if (created != null) { + annotNode.setProperty("created", created); + } - tx.success(); - } finally { - tx.finish(); - } + /* + * Permissions for this annotation. + */ + setPermissionRelation(annotNode, RelationTypes.PERMITS_ADMIN, annot.getAdminPermission()); + setPermissionRelation(annotNode, RelationTypes.PERMITS_DELETE, annot.getDeletePermission()); + setPermissionRelation(annotNode, RelationTypes.PERMITS_UPDATE, annot.getUpdatePermission()); + setPermissionRelation(annotNode, RelationTypes.PERMITS_READ, annot.getReadPermission()); - // re-read and return annotation - Annotation storedAnnot = createAnnotationFromNode(annotNode); - return storedAnnot; - } + tx.success(); + } finally { + tx.finish(); + } + + // re-read and return annotation + Annotation storedAnnot = createAnnotationFromNode(annotNode); + return storedAnnot; + } - /** - * Deletes the annotation with the given id. - * - * @param id - */ - public void deleteById(String id) { - Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle(); - if (annotNode != null) { - // delete related objects - Transaction tx = graphDb.beginTx(); - try { - for (Relationship rel : annotNode.getRelationships()) { - // delete relation and the related node if it has no other relations - Node other = rel.getOtherNode(annotNode); - rel.delete(); - if (! other.hasRelationship()) { - deleteNode(other); - } - } - if (! annotNode.hasRelationship()) { - deleteNode(annotNode); - } else { - logger.error("deleteById: unable to delete: Node still has relations."); - } - tx.success(); - } finally { - tx.finish(); - } - } - } + /** + * Deletes the annotation with the given id. + * + * @param id + */ + public void deleteById(String id) { + Node annotNode = getNodeIndex(NodeTypes.ANNOTATION).get("id", id).getSingle(); + if (annotNode != null) { + // delete related objects + Transaction tx = graphDb.beginTx(); + try { + for (Relationship rel : annotNode.getRelationships()) { + // delete relation and the related node if it has no other + // relations + Node other = rel.getOtherNode(annotNode); + rel.delete(); + if (!other.hasRelationship()) { + deleteNode(other); + } + } + if (!annotNode.hasRelationship()) { + deleteNode(annotNode); + } else { + logger.error("deleteById: unable to delete: Node still has relations."); + } + tx.success(); + } finally { + tx.finish(); + } + } + } - /** - * Returns all annotations with the given uri and/or user. - * - * @param uri - * @param userUri - * @param limit - * @param offset - * @return - */ - public List<Annotation> searchByUriUser(String targetUri, String userUri, - String limit, String offset) { - List<Annotation> annotations = new ArrayList<Annotation>(); - if (targetUri != null) { - // there should be only one - Node target = getNodeIndex(NodeTypes.TARGET).get("uri", targetUri).getSingle(); - if (target != null) { - Iterable<Relationship> relations = target - .getRelationships(RelationTypes.ANNOTATES); - for (Relationship relation : relations) { - Node ann = relation.getStartNode(); - if (ann.getProperty("TYPE", "").equals("ANNOTATION")) { - Annotation annot = createAnnotationFromNode(ann); - annotations.add(annot); - } else { - logger.error("ANNOTATES relation does not start with ANNOTATION: " - + ann); - } - } - } - } - if (userUri != null) { - // there should be only one - Node person = getNodeIndex(NodeTypes.PERSON).get("uri", userUri).getSingle(); - if (person != null) { - Iterable<Relationship> relations = person - .getRelationships(RelationTypes.CREATED); - for (Relationship relation : relations) { - Node ann = relation.getEndNode(); - if (ann.getProperty("TYPE", "").equals("ANNOTATION")) { - Annotation annot = createAnnotationFromNode(ann); - annotations.add(annot); - } else { - logger.error("CREATED relation does not end with ANNOTATION: " - + ann); - } - } - } - } - return annotations; - } + /** + * Returns all annotations with the given uri and/or user. + * + * @param uri + * @param userUri + * @param limit + * @param offset + * @return + */ + public List<Annotation> searchByUriUser(String targetUri, String userUri, String limit, String offset) { + List<Annotation> annotations = new ArrayList<Annotation>(); + if (targetUri != null) { + // there should be only one + Node target = getNodeIndex(NodeTypes.TARGET).get("uri", targetUri).getSingle(); + if (target != null) { + Iterable<Relationship> relations = target.getRelationships(RelationTypes.ANNOTATES); + for (Relationship relation : relations) { + Node ann = relation.getStartNode(); + if (ann.getProperty("TYPE", "").equals("ANNOTATION")) { + Annotation annot = createAnnotationFromNode(ann); + annotations.add(annot); + } else { + logger.error("ANNOTATES relation does not start with ANNOTATION: " + ann); + } + } + } + } + if (userUri != null) { + // there should be only one + Node person = getNodeIndex(NodeTypes.PERSON).get("uri", userUri).getSingle(); + if (person != null) { + Iterable<Relationship> relations = person.getRelationships(RelationTypes.CREATED); + for (Relationship relation : relations) { + Node ann = relation.getEndNode(); + if (ann.getProperty("TYPE", "").equals("ANNOTATION")) { + Annotation annot = createAnnotationFromNode(ann); + annotations.add(annot); + } else { + logger.error("CREATED relation does not end with ANNOTATION: " + ann); + } + } + } + } + return annotations; + } - protected Relationship getOrCreateRelation(Node start, - RelationshipType type, Node end) { - if (start.hasRelationship()) { - // there are relations - Iterable<Relationship> rels = start.getRelationships(type, - Direction.OUTGOING); - for (Relationship rel : rels) { - if (rel.getEndNode().equals(end)) { - // relation exists - return rel; - } - } - } - // create new one - Relationship rel; - Transaction tx = graphDb.beginTx(); - try { - rel = start.createRelationshipTo(end, type); - tx.success(); - } finally { - tx.finish(); - } - return rel; - } + protected Relationship getOrCreateRelation(Node start, RelationshipType type, Node end) { + if (start.hasRelationship()) { + // there are relations + Iterable<Relationship> rels = start.getRelationships(type, Direction.OUTGOING); + for (Relationship rel : rels) { + if (rel.getEndNode().equals(end)) { + // relation exists + return rel; + } + } + } + // create new one + Relationship rel; + Transaction tx = graphDb.beginTx(); + try { + rel = start.createRelationshipTo(end, type); + tx.success(); + } finally { + tx.finish(); + } + return rel; + } + + protected Node getOrCreateAnnotationNode(String id) { + Index<Node> idx = getNodeIndex(NodeTypes.ANNOTATION); + IndexHits<Node> annotations = idx.get("id", id); + Node annotation = annotations.getSingle(); + if (annotation == null) { + // does not exist yet + Transaction tx = graphDb.beginTx(); + try { + annotation = graphDb.createNode(); + annotation.setProperty("TYPE", NodeTypes.ANNOTATION.name()); + annotation.setProperty("id", id); + idx.add(annotation, "id", id); + tx.success(); + } finally { + tx.finish(); + } + } + return annotation; + } - protected Node getOrCreateAnnotationNode(String id) { - Index<Node> idx = getNodeIndex(NodeTypes.ANNOTATION); - IndexHits<Node> annotations = idx.get("id", id); - Node annotation = annotations.getSingle(); - if (annotation == null) { - // does not exist yet - Transaction tx = graphDb.beginTx(); - try { - annotation = graphDb.createNode(); - annotation.setProperty("TYPE", NodeTypes.ANNOTATION.name()); - annotation.setProperty("id", id); - idx.add(annotation, "id", id); - tx.success(); - } finally { - tx.finish(); - } - } - return annotation; - } + protected Node getOrCreateTargetNode(String uri) { + Index<Node> idx = getNodeIndex(NodeTypes.TARGET); + IndexHits<Node> targets = idx.get("uri", uri); + Node target = targets.getSingle(); + if (target == null) { + // does not exist yet + Transaction tx = graphDb.beginTx(); + try { + target = graphDb.createNode(); + target.setProperty("TYPE", NodeTypes.TARGET.name()); + target.setProperty("uri", uri); + idx.add(target, "uri", uri); + tx.success(); + } finally { + tx.finish(); + } + } + return target; + } - protected Node getOrCreateTargetNode(String uri) { - Index<Node> idx = getNodeIndex(NodeTypes.TARGET); - IndexHits<Node> targets = idx.get("uri", uri); - Node target = targets.getSingle(); - if (target == null) { - // does not exist yet - Transaction tx = graphDb.beginTx(); - try { - target = graphDb.createNode(); - target.setProperty("TYPE", NodeTypes.TARGET.name()); - target.setProperty("uri", uri); - idx.add(target, "uri", uri); - tx.success(); - } finally { - tx.finish(); - } - } - return target; - } + protected Node getOrCreatePersonNode(Actor actor) { + /* + * // Person is identified by URI Index<Node> idx = + * getNodeIndex(NodeTypes.PERSON); IndexHits<Node> persons = + * idx.get("uri", uri); Node person = persons.getSingle(); if (person == + * null) { // does not exist yet Transaction tx = graphDb.beginTx(); try + * { person = graphDb.createNode(); person.setProperty("TYPE", + * NodeTypes.PERSON.name()); person.setProperty("uri", uri); + * idx.add(person, "uri", uri); if (name != null) { + * person.setProperty("name", name); } tx.success(); } finally { + * tx.finish(); } } return person; + */ + return null; + } - protected Node getOrCreatePersonNode(Actor actor) { - /* - // Person is identified by URI - Index<Node> idx = getNodeIndex(NodeTypes.PERSON); - IndexHits<Node> persons = idx.get("uri", uri); - Node person = persons.getSingle(); - if (person == null) { - // does not exist yet - Transaction tx = graphDb.beginTx(); - try { - person = graphDb.createNode(); - person.setProperty("TYPE", NodeTypes.PERSON.name()); - person.setProperty("uri", uri); - idx.add(person, "uri", uri); - if (name != null) { - person.setProperty("name", name); - } - tx.success(); - } finally { - tx.finish(); - } - } - return person; - */ - return null; - } + /** + * Create or update permissions relations for an annotation. + * + * @param annotNode + * @param type + * @param annot + */ + protected void setPermissionRelation(Node annotNode, RelationTypes type, Actor actor) { + Node newActorNode = null; + if (actor != null) { + newActorNode = getOrCreatePersonNode(actor); + } + Relationship rel = getRelation(annotNode, type, null); + if (rel != null) { + // relation exists + Node oldActorNode = rel.getEndNode(); + if (!oldActorNode.equals(newActorNode)) { + // new admin is different + rel.delete(); + if (newActorNode != null) { + rel = getOrCreateRelation(annotNode, type, newActorNode); + } + } + } else { + // no relation yet + if (newActorNode != null) { + rel = getOrCreateRelation(annotNode, type, newActorNode); + } + } + } - /** - * Unindexes and deletes given Node if it has no relations. - * @param node - */ - protected void deleteNode(Node node) { - Transaction tx = graphDb.beginTx(); - try { - if (node.hasRelationship()) { - logger.error("deleteNode: unable to delete: Node still has relations."); - } else { - String ts = (String) node.getProperty("TYPE", null); - try { - NodeTypes type = NodeTypes.valueOf(ts); - getNodeIndex(type).remove(node); - } catch (Exception e) { - logger.error("deleteNode: unable to get TYPE of node: "+node); - } - node.delete(); - } - tx.success(); - } finally { - tx.finish(); - } - } - - /** - * Erzeuge eine urn aus der aktuellen Zeit in millis - * - * @return - */ - private String createRessourceURI(String prefix) { + /** + * Unindexes and deletes given Node if it has no relations. + * + * @param node + */ + protected void deleteNode(Node node) { + Transaction tx = graphDb.beginTx(); + try { + if (node.hasRelationship()) { + logger.error("deleteNode: unable to delete: Node still has relations."); + } else { + String ts = (String) node.getProperty("TYPE", null); + try { + NodeTypes type = NodeTypes.valueOf(ts); + getNodeIndex(type).remove(node); + } catch (Exception e) { + logger.error("deleteNode: unable to get TYPE of node: " + node); + } + node.delete(); + } + tx.success(); + } finally { + tx.finish(); + } + } - Calendar cal = Calendar.getInstance(); - - long time = cal.getTimeInMillis(); + protected Relationship getRelation(Node start, RelationTypes type, Direction direction) { + Iterable<Relationship> rels; + if (direction == null) { + // ignore direction + rels = start.getRelationships(type); + } else { + rels = start.getRelationships(type, direction); + } + for (Relationship rel : rels) { + return rel; + } + return null; + } - return String.format("%s%s%s", ANNOTATION_URI_BASE, prefix, time); + /** + * Erzeuge eine urn aus der aktuellen Zeit in millis + * + * @return + */ + private String createRessourceURI(String prefix) { - } + Calendar cal = Calendar.getInstance(); + + long time = cal.getTimeInMillis(); + + return String.format("%s%s%s", ANNOTATION_URI_BASE, prefix, time); + + } }