@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())); }
/** * 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"; }
Annotation annotation = new Annotation(); WorkflowBundle workflowBundle = parserState.get() .getCurrentWorkflowBundle(); annotation.setParent(workflowBundle); String path = "annotation/" + annotation.getName() + ".ttl"; URI bodyURI = URI.create(path); annotation.setTarget(annotatedBean); annotation.setAnnotatedAt(cal); annotation.setSerializedBy(t2flowParserURI); annotation.setSerializedAt(new GregorianCalendar()); URI annotatedSubject = uriTools.relativeUriForBean( annotatedBean, annotation); throw new ReaderException("Could not store annotation body to " + path, e); annotation.setBody(bodyURI);
public void annotation(final Annotation ann) { URI wfBundleURI = uriTools.uriForBean(wfBundle); URI annUri = uriTools.uriForBean(ann); URI bodyURI = ann.getBody(); if (bodyURI == null || bodyURI.isAbsolute()) bodyURI = annUri.resolve(uriTools.validFilename(ann.getName()) + DOT_RDF); URI pathUri = uriTools.relativePath(wfBundleURI, bodyURI); if (ann.getBody() == null || ann.getBody().equals(wfBundleURI.resolve(pathUri))) ann.setBody(pathUri);
@Test public void readWorkflowWithEscapes() throws Exception { URL wfResource = getClass().getResource(WF_ANNOTATION_WITH_BACKSLASH_T2FLOW); assertNotNull("Could not find workflow " + WF_ANNOTATION_WITH_BACKSLASH_T2FLOW, wfResource); T2FlowParser parser = new T2FlowParser(); parser.setValidating(true); parser.setStrict(true); WorkflowBundle wfBundle = parser.parseT2Flow(wfResource.openStream()); Annotation ann = wfBundle.getAnnotations().iterator().next(); String annStr = wfBundle.getResources().getResourceAsString(ann.getBody().toString()); System.out.println(annStr); // """c:\\Program Files\\""" assertTrue(annStr.contains("\"\"\"c:\\\\Program Files\\\\\"\"\"")); }
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 Annotation(WorkflowBean target) { setTarget(target); }
public void addAnnotation() { WorkflowBundle wfBundle = new WorkflowBundle(); Annotation ann = new Annotation(); wfBundle.getAnnotations().add(ann); }
@Test public void readSemanticAnnotations() throws Exception { URL wfResource = getClass().getResource(SEMANTIC_ANNOTATIONS); assertNotNull("Could not find workflow " + SEMANTIC_ANNOTATIONS, wfResource); T2FlowParser parser = new T2FlowParser(); parser.setValidating(true); parser.setStrict(false); WorkflowBundle wfBundle = parser.parseT2Flow(wfResource.openStream()); assertEquals(4, wfBundle.getAnnotations().size()); for (Annotation x : wfBundle.getAnnotations()) { System.out.println(x.getTarget()); // System.out.println(x.getBodyStatements().get(0)); } File f = File.createTempFile("annotation", ".wfbundle"); System.err.println(f); new WorkflowBundleIO().writeBundle(wfBundle, f, "application/vnd.taverna.scufl2.workflow-bundle"); }