/** * Gets the standard path for the resource in the bundle associated with * this annotation. The resource will be expected to contain a TTL-encoded * RDF model. * * @return a resource path. */ public String getResourcePath() { return "annotation/" + getName() + ".ttl"; }
public Annotation(WorkflowBean target) { setTarget(target); }
@Override public boolean equals(Object obj) { if (!(obj instanceof Revision)) return false; Revision other = (Revision) obj; if (getIdentifier() == null) return obj == this; return getIdentifier().equals(other.getIdentifier()); }
@Override protected void cloneInto(WorkflowBean clone, Cloning cloning) { super.cloneInto(clone, cloning); Annotation cloneAnnotation = (Annotation) clone; if (getAnnotatedAt() != null) cloneAnnotation.setAnnotatedAt((Calendar) getAnnotatedAt().clone()); cloneAnnotation.setAnnotatedBy(getAnnotatedBy()); cloneAnnotation.setBody(getBody()); if (getSerializedAt() != null) cloneAnnotation.setSerializedAt((Calendar) getSerializedAt() .clone()); cloneAnnotation.setSerializedBy(getSerializedBy()); cloneAnnotation.setTarget(cloning.cloneOrOriginal(getTarget())); }
protected boolean accept(Visitor visitor, HashSet<Revision> visited) { if (!visited.add(this)) // Ignore this Revision, visitor has already seen it return true; boolean recurse = visitor.visitEnter(this); if (recurse) { if (getPreviousRevision() != null) recurse = getPreviousRevision().accept(visitor, visited); for (Revision rev : getHadOriginalSources()) { if (!recurse) break; recurse = rev.accept(visitor, visited); } } return visitor.visitLeave(this); }
@Override public Revision newRevision(URI revisionIdentifier) { GregorianCalendar created = null; if (revisionIdentifier == null) { revisionIdentifier = generateNewIdentifier(); created = new GregorianCalendar(); } Revision newRevision = new Revision(revisionIdentifier, getCurrentRevision()); newRevision.setGeneratedAtTime(created); setCurrentRevision(newRevision); return newRevision; }
private Revision addOrExisting(URI uri, Map<URI, Revision> revisions) { Revision rev = revisions.get(uri); if (rev != null) return rev; rev = new Revision(uri, null); revisions.put(uri, rev); return rev; }
/** * Gets the content of this annotation. Note that this method does not cache * the value it reads. * * @return a TTL-encoded RDF model. * @throws IOException * If anything goes wrong reading the resource */ public String getRDFContent() throws IOException { return getParent().getResources() .getResourceAsString(getResourcePath()); } }
public List<Annotation> annotationsFor(WorkflowBean bean, WorkflowBundle bundle) { ArrayList<Annotation> annotations = new ArrayList<>(); if (bundle == null) return annotations; for (Annotation ann : bundle.getAnnotations()) if (ann.getTarget().equals(bean)) annotations.add(ann); return annotations; }
public void addAnnotation() { WorkflowBundle wfBundle = new WorkflowBundle(); Annotation ann = new Annotation(); wfBundle.getAnnotations().add(ann); }
/** * Get the URI of this revision. * * @return The absolute URI. * @see URITools#uriForBean(WorkflowBean) */ public URI getURI() { return getUriTools().uriForBean(this); }
@Override public boolean accept(Visitor visitor) { return accept(visitor, new HashSet<Revision>()); }
protected void addRevisions(Revisioned revisioned, String path, WorkflowBundle wfBundle) throws WriterException { @SuppressWarnings("unused") URI uriBase = uriTools.uriForBean(wfBundle).resolve(path); Revision currentRevision = revisioned.getCurrentRevision(); if (currentRevision == null) return; // try { // wfBundle.getResources() // .addResource(visitor.getDoc(), path, APPLICATION_RDF_XML); // } catch (IOException e) { // throw new WriterException("Can't write revisions to " + path, e); // } }
@Override public int hashCode() { if (getIdentifier() == null) return 0x01234567; return 0x01234567 ^ getIdentifier().hashCode(); }
/** * Set the identifier. * <p> * This will delete any previous revisions in {@link #getCurrentRevision()} * * @see #getIdentifier() * @see #getCurrentRevision() * @param identifier * the identifier */ @Override public void setIdentifier(URI identifier) { setCurrentRevision(new Revision(identifier, null)); } }
/** * Get the URI of this revision relative to another workflow element. * * @return The relative URI. * @see URITools#relativeUriForBean(WorkflowBean,WorflowBean) */ public URI getRelativeURI(WorkflowBean relativeTo) { return getUriTools().relativeUriForBean(this, relativeTo); } }
@Override public String toString() { return getClass().getSimpleName() + " " + getIdentifier(); }
/** * Returns the identifier. * <p> * The the default identifier is based on #getIdentifierRoot() plus a random * UUID. * * @see {@link #setIdentifier(URI)} * @return the identifier */ @Override public URI getIdentifier() { if (getCurrentRevision() == null) return null; return getCurrentRevision().getIdentifier(); }
@Test public void revisionURIs() { Revision r1 = wfBundle.newRevision(); assertEquals(r1.getIdentifier(), uriTools.uriForBean(r1)); // assertEquals(r1, uriTools.resolveUri(r3.getIdentifier(), wfBundle)); }
@Ignore @Test public void resolveRevisions() { Revision r1 = wfBundle.newRevision(); Revision r2 = wfBundle.newRevision(); Revision r3 = wfBundle.newRevision(); assertEquals(wfBundle, uriTools.resolveUri(r3.getIdentifier(), wfBundle)); assertEquals(r2, uriTools.resolveUri(r2.getIdentifier(), wfBundle)); assertEquals(r1, uriTools.resolveUri(r1.getIdentifier(), wfBundle)); }