本文整理汇总了Java中org.apache.taverna.workflow.edits.AddProcessorEdit类的典型用法代码示例。如果您正苦于以下问题:Java AddProcessorEdit类的具体用法?Java AddProcessorEdit怎么用?Java AddProcessorEdit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AddProcessorEdit类属于org.apache.taverna.workflow.edits包,在下文中一共展示了AddProcessorEdit类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pasteProcessor
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
public Processor pasteProcessor(CopiedProcessor copy, Workflow d)
throws
ClassNotFoundException, InstantiationException,
IllegalAccessException, EditException {
Processor result = ProcessorXMLDeserializer.getInstance()
.deserializeProcessor(copy.processor, copy.requiredSubworkflows);
if (result == null)
return null;
String newName = Tools.uniqueProcessorName(result.getName(), d);
List<Edit<?>> editList = new ArrayList<>();
if (!newName.equals(result.getName()))
editList.add(new RenameEdit<>(result, newName));
editList.add(new AddProcessorEdit(d, result));
em.doDataflowEdit(d.getParent(), new CompoundEdit(editList));
return result;
}
示例2: undoAddProcessor
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
@Test
public void undoAddProcessor() throws Exception {
EditManager editManager = new EditManagerImpl();
editManager.addObserver(editManagerObserver);
Edit<Workflow> edit = new AddProcessorEdit(dataflow, processor);
editManager.doDataflowEdit(dataflow.getParent(), edit);
assertFalse("Did not add processor", dataflow.getProcessors().isEmpty());
editManager.undoDataflowEdit(dataflow.getParent());
assertTrue("Did not undo add processor", dataflow.getProcessors()
.isEmpty());
// Should have received the undo event
assertEquals("Incorrect number of events", 2,
editManagerObserver.events.size());
EditManagerEvent event = editManagerObserver.events.get(1);
assertTrue("Event was not a DataflowEditEvent",
event instanceof DataFlowUndoEvent);
DataFlowUndoEvent dataEditEvent = (DataFlowUndoEvent) event;
assertEquals("Event did not have correct workflow", dataflow,
dataEditEvent.getDataFlow().getWorkflows().first());
assertEquals("Event did not have correct edit", edit, dataEditEvent
.getEdit());
assertFalse("Edit was still applied", edit.isApplied());
}
示例3: isChanged
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
@Test
public void isChanged() throws Exception {
WorkflowBundle dataflow = openDataflow();
assertFalse("Dataflow should not have changed", fileManager
.isDataflowChanged(dataflow));
// Do a change
Processor emptyProcessor = new Processor();
Edit<Workflow> addProcessorEdit = new AddProcessorEdit(dataflow.getMainWorkflow(),
emptyProcessor);
editManager.doDataflowEdit(dataflow, addProcessorEdit);
assertTrue("Dataflow should have changed", fileManager
.isDataflowChanged(dataflow));
// Save it with the change
File dataflowFile = File.createTempFile("test", ".t2flow");
dataflowFile.deleteOnExit();
dataflowFile.delete();
fileManager.saveDataflow(dataflow, WF_BUNDLE_FILE_TYPE, dataflowFile, false);
assertFalse("Dataflow should no longer be marked as changed",
fileManager.isDataflowChanged(dataflow));
}
示例4: addProcessor
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
@Test
public void addProcessor() throws Exception {
EditManager editManager = new EditManagerImpl();
editManager.addObserver(editManagerObserver);
Edit<Workflow> edit = new AddProcessorEdit(dataflow, processor);
assertFalse("Edit was already applied", edit.isApplied());
assertTrue("Did already add processor", dataflow.getProcessors()
.isEmpty());
editManager.doDataflowEdit(dataflow.getParent(), edit);
assertTrue("Edit was not applied", edit.isApplied());
assertEquals("Did not add processor", processor, dataflow.getProcessors().first());
// Should have received the edit event
assertEquals("Incorrect number of events", 1,
editManagerObserver.events.size());
EditManagerEvent event = editManagerObserver.events.get(0);
assertTrue("Event was not a DataflowEditEvent",
event instanceof DataflowEditEvent);
DataflowEditEvent dataEditEvent = (DataflowEditEvent) event;
assertEquals("Event did not have correct workflow", dataflow,
dataEditEvent.getDataFlow().getWorkflows().first());
assertEquals("Event did not have correct edit", edit, dataEditEvent
.getEdit());
}
示例5: extraUndoesDoesNotFail
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
@Test
public void extraUndoesDoesNotFail() throws Exception {
EditManager editManager = new EditManagerImpl();
editManager.addObserver(editManagerObserver);
Edit<Workflow> edit = new AddProcessorEdit(dataflow, processor);
editManager.doDataflowEdit(dataflow.getParent(), edit);
assertFalse("Did not add processor", dataflow.getProcessors().isEmpty());
editManager.undoDataflowEdit(dataflow.getParent());
assertTrue("Did not undo add processor", dataflow.getProcessors()
.isEmpty());
editManager.undoDataflowEdit(dataflow.getParent());
}
示例6: getMergeEdit
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
/**
* Make an {@link Edit} that when performed merges the given source dataflow
* into the destination dataflow.
* <p>
* Internally a copy is made of the source dataflow, to avoid modifying the
* links and processors.
*
* @param sourceWorkflow
* Dataflow to merge from
* @param prefix
* A prefix which will be inserted in front of the names for the
* merged workflow components.
* @return An edit that can perform and undo the insertion of the components
* from the source dataflow.
* @throws MergeException
* If the merge cannot be performed.
*/
public CompoundEdit getMergeEdit(Workflow sourceWorkflow, String prefix)
throws MergeException {
List<Edit<?>> compoundEdit = new ArrayList<>();
Workflow workflow = copyWorkflow(sourceWorkflow);
for (InputWorkflowPort input : workflow.getInputPorts()) {
destinationWorkflow.getInputPorts().addWithUniqueName(input);
destinationWorkflow.getInputPorts().remove(input);
compoundEdit.add(new AddWorkflowInputPortEdit(destinationWorkflow, input));
}
for (OutputWorkflowPort output : workflow.getOutputPorts()) {
destinationWorkflow.getOutputPorts().addWithUniqueName(output);
destinationWorkflow.getOutputPorts().remove(output);
compoundEdit.add(new AddWorkflowOutputPortEdit(destinationWorkflow, output));
}
for (Processor processor : workflow.getProcessors()) {
processor.setName(prefix + processor.getName());
compoundEdit.add(new AddProcessorEdit(destinationWorkflow, processor));
}
for (DataLink dataLink : workflow.getDataLinks()) {
compoundEdit.add(new AddDataLinkEdit(destinationWorkflow, dataLink));
}
for (ControlLink controlLink : workflow.getControlLinks()) {
compoundEdit.add(new AddChildEdit<Workflow>(destinationWorkflow, controlLink));
}
return new CompoundEdit(compoundEdit);
}
示例7: isChangedWithUndo
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
@Ignore("Undo support for ischanged not yet implemented")
@Test
public void isChangedWithUndo() throws Exception {
WorkflowBundle dataflow = openDataflow();
// Do a change
Processor emptyProcessor = new Processor();
Edit<Workflow> addProcessorEdit = new AddProcessorEdit(dataflow.getMainWorkflow(),
emptyProcessor);
editManager.doDataflowEdit(dataflow, addProcessorEdit);
assertTrue("Dataflow should have changed", fileManager
.isDataflowChanged(dataflow));
editManager.undoDataflowEdit(dataflow);
assertFalse(
"Dataflow should no longer be marked as changed after undo",
fileManager.isDataflowChanged(dataflow));
editManager.redoDataflowEdit(dataflow);
assertTrue("Dataflow should have changed after redo before save",
fileManager.isDataflowChanged(dataflow));
// Save it with the change
File dataflowFile = File.createTempFile("test", ".t2flow");
dataflowFile.deleteOnExit();
dataflowFile.delete();
fileManager.saveDataflow(dataflow, WF_BUNDLE_FILE_TYPE, dataflowFile, false);
assertFalse("Dataflow should no longer be marked as changed",
fileManager.isDataflowChanged(dataflow));
editManager.undoDataflowEdit(dataflow);
assertTrue("Dataflow should have changed after undo", fileManager
.isDataflowChanged(dataflow));
fileManager.saveDataflow(dataflow, WF_BUNDLE_FILE_TYPE, dataflowFile, false);
editManager.redoDataflowEdit(dataflow);
assertTrue("Dataflow should have changed after redo after save",
fileManager.isDataflowChanged(dataflow));
}
示例8: actionPerformed
import org.apache.taverna.workflow.edits.AddProcessorEdit; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
try {
Activity activity = new Activity();
activity.setType(STRING_CONSTANT);
Configuration configuration = new Configuration();
configuration.setType(STRING_CONSTANT.resolve("#Config"));
configuration.getJsonAsObjectNode().put("string", "");
configuration.setConfigures(activity);
StringConstantConfigView configView = new StringConstantConfigView(activity,
configuration, serviceRegistry);
int answer = JOptionPane.showConfirmDialog(component, configView,
"Text constant value", JOptionPane.OK_CANCEL_OPTION);
if (answer != JOptionPane.CANCEL_OPTION) {
configView.noteConfiguration();
configuration.setJson(configView.getJson());
Profile profile = selectionManager.getSelectedProfile();
Processor processor = new Processor();
processor.setName(inputPort.getName() + "_value");
CrossProduct crossProduct = new CrossProduct();
crossProduct.setParent(processor.getIterationStrategyStack());
ProcessorBinding processorBinding = new ProcessorBinding();
processorBinding.setBoundProcessor(processor);
processorBinding.setBoundActivity(activity);
// create activity port
OutputActivityPort activityPort = new OutputActivityPort(activity, "value");
activityPort.setDepth(0);
activityPort.setGranularDepth(0);
// create processor port
OutputProcessorPort processorPort = new OutputProcessorPort(processor,
activityPort.getName());
processorPort.setDepth(0);
processorPort.setGranularDepth(0);
// add a new port binding
new ProcessorOutputPortBinding(processorBinding, activityPort, processorPort);
// Add a data link between the string constant processor's output port
// and the processor containing the passed inputPort.
DataLink datalink = new DataLink();
datalink.setReceivesFrom(processorPort);
datalink.setSendsTo(inputPort);
List<Edit<?>> editList = new ArrayList<Edit<?>>();
editList.add(new AddChildEdit<Profile>(profile, activity));
editList.add(new AddChildEdit<Profile>(profile, configuration));
editList.add(new AddChildEdit<Profile>(profile, processorBinding));
editList.add(new AddProcessorEdit(dataflow, processor));
editList.add(new AddDataLinkEdit(dataflow, datalink));
editManager.doDataflowEdit(dataflow.getParent(), new CompoundEdit(editList));
}
} catch (EditException ex) {
logger.error("Adding default value for input port failed", ex);
}
}