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; }
@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())); }
@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"); }