WorkflowBundle bundle = profile.getParent(); if (bundle == null) throw new NullPointerException("Parent must be set for " + profile);
private void configuration(Configuration node) { org.apache.taverna.scufl2.xml.Configuration configuration = objectFactory .createConfiguration(); configuration.setConfigure(resource(uri(node.getConfigures()))); configuration.setName(node.getName()); configuration.setType(type(node)); URI configUri = uriTools.relativeUriForBean(node, profile); String jsonPath = configUri.toString().replaceFirst("/$", ".json"); URI profilePath = uriTools.relativeUriForBean(profile, profile.getParent()); String bundlePath = profilePath + jsonPath; UCFPackage bundle = profile.getParent().getResources(); try { bundle.addResource(node.getJsonAsString(), bundlePath, "application/json"); } catch (IOException e) { logger.log(WARNING, "Can't save JSON to " + bundlePath, e); } configuration.setAbout(configUri.toString()); SeeAlso seeAlso = rdfsObjectFactory.createSeeAlso(); seeAlso.setResource(jsonPath); configuration.setSeeAlso(seeAlso); // TODO: No way in API to mark non-activated configurations profileElem.getActivateConfiguration().add(resource(uri(node))); doc.getAny().add(configuration); }
@Ignore @Test public void writeBundleFileSetParents() throws Exception { File bundleFile = tempFile(); // Deliberately orphan a profile and a processor Profile profile = wfBundle.getProfiles().getByName("tavernaWorkbench"); profile.setParent(null); wfBundle.getProfiles().add(profile); processor.setParent(null); workflow.getProcessors().add(processor); assertNull(processor.getParent()); assertNull(profile.getParent()); bundleIO.writeBundle(wfBundle, bundleFile, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertNotNull(processor.getParent()); assertNotNull(profile.getParent()); String bundleTxt = FileUtils.readFileToString(bundleFile, UTF_8); assertTrue(bundleTxt.contains("Processor 'Hello'")); assertTrue(bundleTxt.contains("Profile 'tavernaWorkbench'")); }
@Test public void setParents() throws Exception { // Deliberately orphan a profile and a processor Profile profile = workflowBundle.getProfiles().getByName("tavernaWorkbench"); profile.setParent(null); workflowBundle.getProfiles().add(profile); processor.setParent(null); workflow.getProcessors().add(processor); assertNull(processor.getParent()); assertNull(profile.getParent()); scufl2Tools.setParents(workflowBundle); assertNotNull(processor.getParent()); assertNotNull(profile.getParent()); }
@Test public void cloneProfile() throws Exception { Profile original = originalWfBundle.getMainProfile(); assertEquals(originalWfBundle, original.getParent()); Profile clone = (Profile) original.clone(); assertNull(clone.getParent()); assertEquals(original.getName(), clone.getName()); ProcessorBinding originalBinding = original.getProcessorBindings() .getByName("Hello"); ProcessorBinding cloneBinding = clone.getProcessorBindings().getByName( "Hello"); assertNotSame(originalBinding, cloneBinding); assertNotSame(originalBinding.getBoundActivity(), cloneBinding.getBoundActivity()); // but processor is the same, as we did not clone the workflow assertSame(originalBinding.getBoundProcessor(), cloneBinding.getBoundProcessor()); }
@Test public void createBundle() throws Exception { WorkflowBundle wb = bundleIO.createBundle(); assertEquals(wb, wb.getMainWorkflow().getParent()); assertEquals(wb, wb.getMainProfile().getParent()); assertEquals("bundle1", wb.getName()); assertEquals("workflow1", wb.getMainWorkflow().getName()); assertEquals("profile1", wb.getMainProfile().getName()); assertNotNull(wb.getCurrentRevision()); assertNotNull(wb.getMainWorkflow().getCurrentRevision()); assertNotNull(wb.getMainProfile().getCurrentRevision()); }