protected Edit<?> makeInsertNestedWorkflowEdit(Dataflow nestedFlow, String name) { List<Edit<?>> editList = new ArrayList<Edit<?>>(); insertedActivity = new DataflowActivity(); editList.add(edits.getConfigureActivityEdit(insertedActivity, nestedFlow)); Processor p = edits.createProcessor(name); editList.add(edits.getDefaultDispatchStackEdit(p)); editList.add(edits.getAddActivityEdit(p, insertedActivity)); editList.add(edits.getAddProcessorEdit(destinationDataflow, p)); CompoundEdit edit = new CompoundEdit(editList); return edit; }
@SuppressWarnings("unchecked") public Processor deserializeProcessor(Element el,Map<String,Element>innerDataflowElements) throws EditException, ActivityConfigurationException, ClassNotFoundException, InstantiationException, IllegalAccessException, DeserializationException { String name=el.getChildText(NAME,T2_WORKFLOW_NAMESPACE); Processor result=edits.createProcessor(name);
@Before public void makeDataflow() throws EditException { List<Edit<?>> compoundEdit = new ArrayList<Edit<?>>(); dataflow = fileManager.newDataflow(); Edits edits = EditsRegistry.getEdits(); proc1 = edits.createProcessor("processor1"); compoundEdit.add(edits.getAddProcessorEdit(dataflow, proc1)); Processor proc2 = edits.createProcessor("processor2"); compoundEdit.add(edits.getAddProcessorEdit(dataflow, proc2)); ProcessorInputPort in1 = edits.createProcessorInputPort(proc1, "in1", 0); compoundEdit.add(edits.getAddProcessorInputPortEdit(proc1, in1)); ProcessorInputPort in2 = edits .createProcessorInputPort(proc1, "in2", 0); compoundEdit.add(edits.getAddProcessorInputPortEdit(proc1, in2)); Activity<EchoConfig> activity = new AsynchEchoActivity(); compoundEdit.add(edits.getConfigureActivityEdit(activity, new EchoConfig())); compoundEdit.add(edits.getAddActivityEdit(proc1, activity)); compoundEdit.add(edits.getDefaultDispatchStackEdit(proc1)); editManager.doDataflowEdit(dataflow, new CompoundEdit(compoundEdit)); activityInputPort = activity.getInputPorts().iterator().next(); } }
private Processor createNestingProcessor(List<Edit<?>> editList) { Processor nestingProcessor = edits.createProcessor(uniqueProcessorName( nameField.getText(), currentDataflow)); if (includedProcessors.size() != 1 || !(includedProcessors.get(0) instanceof Processor)) return nestingProcessor; Processor includedProcessor = (Processor) includedProcessors.get(0); for (Class<?> c : at.getAnnotatingClasses(includedProcessor)) { AnnotationBeanSPI annotation = at.getAnnotation(includedProcessor, AbstractTextualValueAssertion.class); if ((annotation != null) && (annotation instanceof AbstractTextualValueAssertion)) editList.add(at.setAnnotationString(nestingProcessor, c, ((AbstractTextualValueAssertion) annotation).getText())); } return nestingProcessor; }
@SuppressWarnings("unchecked") public Processor deserializeProcessor(Element el,Map<String,Element>innerDataflowElements) throws EditException, ActivityConfigurationException, ClassNotFoundException, InstantiationException, IllegalAccessException, DeserializationException { String name=el.getChildText(NAME,T2_WORKFLOW_NAMESPACE); Processor result=edits.createProcessor(name);
protected Processor createProcessor() { Edits edits = new EditsImpl(); return edits.createProcessor("proc-" + UUID.randomUUID()); }
Processor p=edits.createProcessor(name); editList.add(edits.getDefaultDispatchStackEdit(p)); editList.add(edits.getAddActivityEdit(p, activity));
.createProcessor(name); BiomobyObjectActivity boActivity = new BiomobyObjectActivity(); Edit<?> configureActivityEdit = edits.getConfigureActivityEdit(
EditException, WorkflowTranslationException { Processor t2Processor = edits.createProcessor(t1Processor.getName());
EditException, WorkflowTranslationException { Processor t2Processor = edits.createProcessor(t1Processor.getName());
.createProcessor(name); BiomobyObjectActivity boActivity = new BiomobyObjectActivity(); Edit<?> configureActivityEdit = edits
/** * Adds the selected dataflow to the currently opened one. Create a * processor with the same name as the nested dataflow (ie. the one just * opened). Add the configured dataflow activity to this processor. Then use * the {@link EditManager} to add the processor to the main dataflow so that * any GUI updates are forced * * @param dataflow */ private void addSelectedDataflowToCurrentDataflow(Dataflow dataflow) { createProcessor = EditsRegistry.getEdits().createProcessor( dataflow.getLocalName()); try { EditsRegistry.getEdits().getAddActivityEdit(createProcessor, dataflowActivity).doEdit(); EditManager.getInstance().doDataflowEdit( (Dataflow) ModelMap.getInstance().getModel( ModelMapConstants.CURRENT_DATAFLOW), EditsRegistry.getEdits() .getMapProcessorPortsForActivityEdit( createProcessor)); } catch (EditException e) { logger.error("Could not add nested workflow", e); } }
@Test public void oneLiner() throws Exception { BeanshellActivity activity = new BeanshellActivity(); BeanshellActivityConfigurationBean bean = new BeanshellActivityConfigurationBean(); bean.setScript("System.out.println(\"Hello\");"); activity.configure(bean); Map<String,Object> inputs = new HashMap<String, Object>(); Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>(); ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs); BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker(); assertTrue(healthChecker.canVisit(activity)); ArrayList<Object> ancestors = new ArrayList<Object>(); ancestors.add(edits.createProcessor("beanie")); VisitReport visit = healthChecker.visit(activity, ancestors); assertEquals(Status.OK, visit.getStatus()); }
@Test public void threeLines() throws Exception { BeanshellActivity activity = new BeanshellActivity(); BeanshellActivityConfigurationBean bean = new BeanshellActivityConfigurationBean(); bean.setScript("if (2>1) {\n" + " new Integer(4);\n" + "}"); activity.configure(bean); Map<String,Object> inputs = new HashMap<String, Object>(); Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>(); ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs); BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker(); assertTrue(healthChecker.canVisit(activity)); ArrayList<Object> ancestors = new ArrayList<Object>(); ancestors.add(edits.createProcessor("beanie")); VisitReport visit = healthChecker.visit(activity, ancestors); assertEquals(Status.OK, visit.getStatus()); }
@Test public void oneLinerNoSemicolon() throws Exception { BeanshellActivity activity = new BeanshellActivity(); BeanshellActivityConfigurationBean bean = new BeanshellActivityConfigurationBean(); bean.setScript("a = 5+3"); // Notice lack of ; activity.configure(bean); Map<String,Object> inputs = new HashMap<String, Object>(); Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>(); ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs); BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker(); assertTrue(healthChecker.canVisit(activity)); ArrayList<Object> ancestors = new ArrayList<Object>(); ancestors.add(edits.createProcessor("beanie")); VisitReport visit = healthChecker.visit(activity, ancestors); assertEquals(Status.OK, visit.getStatus()); }
@Test public void strangeWhitespace() throws Exception { BeanshellActivity activity = new BeanshellActivity(); BeanshellActivityConfigurationBean bean = new BeanshellActivityConfigurationBean(); bean.setScript("b = \"fish\";\n" + "a = 2+3\n" + "\n" + "\n" + " +5 "); // Notice lots of whitespace, but still valid activity.configure(bean); Map<String,Object> inputs = new HashMap<String, Object>(); Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>(); ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs); BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker(); assertTrue(healthChecker.canVisit(activity)); ArrayList<Object> ancestors = new ArrayList<Object>(); ancestors.add(edits.createProcessor("beanie")); VisitReport visit = healthChecker.visit(activity, ancestors); System.out.println(visit); assertEquals(Status.OK, visit.getStatus()); } }
@Test public void invalidScript() throws Exception { BeanshellActivity activity = new BeanshellActivity(); BeanshellActivityConfigurationBean bean = new BeanshellActivityConfigurationBean(); bean.setScript("invalid script 5 +"); activity.configure(bean); Map<String,Object> inputs = new HashMap<String, Object>(); Map<String, Class<?>> expectedOutputs = new HashMap<String, Class<?>>(); try { ActivityInvoker.invokeAsyncActivity(activity, inputs, expectedOutputs); fail("Script should not be valid"); } catch (RuntimeException ex) { // expected to fail } BeanshellActivityHealthChecker healthChecker = new BeanshellActivityHealthChecker(); assertTrue(healthChecker.canVisit(activity)); ArrayList<Object> ancestors = new ArrayList<Object>(); ancestors.add(edits.createProcessor("beanie")); VisitReport visit = healthChecker.visit(activity, ancestors); assertEquals(Status.SEVERE, visit.getStatus()); }
/** * Adds the selected dataflow to the currently opened one. Create a * processor with the same name as the nested dataflow (ie. the one just * opened). Add the configured dataflow activity to this processor. Then use * the {@link EditManager} to add the processor to the main dataflow so that * any GUI updates are forced * * @param dataflow */ private void addSelectedDataflowToCurrentDataflow(Dataflow dataflow) { createProcessor = EditsRegistry.getEdits().createProcessor( dataflow.getLocalName()); try { EditsRegistry.getEdits().getAddActivityEdit(createProcessor, dataflowActivity).doEdit(); EditManager.getInstance().doDataflowEdit( (Dataflow) ModelMap.getInstance().getModel( ModelMapConstants.CURRENT_DATAFLOW), EditsRegistry.getEdits() .getMapProcessorPortsForActivityEdit( createProcessor)); } catch (EditException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void makeProcessor() throws EditException { processor = edits.createProcessor("Hello"); Edit<Dataflow> edit = edits.getAddProcessorEdit(currentDataflow, processor); editManager.doDataflowEdit(currentDataflow, edit); editManager.doDataflowEdit(currentDataflow, edits .getDefaultDispatchStackEdit(processor)); BeanshellActivity beanshell = new BeanshellActivity(); BeanshellActivityConfigurationBean beanshellConfig = new BeanshellActivityConfigurationBean(); editManager.doDataflowEdit(currentDataflow, edits .getConfigureActivityEdit(beanshell, beanshellConfig)); editManager.doDataflowEdit(currentDataflow, edits.getAddActivityEdit( processor, beanshell)); }