use of org.vcell.workflow.Task in project vcell by virtualcell.
the class WorkflowObjectsTableModel method computeData.
/**
* Insert the method's description here.
* Creation date: (9/23/2003 1:24:52 PM)
* @return cbit.vcell.model.Parameter
* @param row int
*/
protected List<WorkflowObject> computeData() {
ArrayList<WorkflowObject> allWorkflowObjectList = new ArrayList<WorkflowObject>();
if (taskContext == null) {
return null;
}
Workflow workflow = taskContext.getWorkflow();
if (bTasks) {
allWorkflowObjectList.addAll(workflow.getTasks());
}
if (bParameters) {
allWorkflowObjectList.addAll(workflow.getParameters());
}
if (bTaskInputs) {
for (Task task : workflow.getTasks()) {
allWorkflowObjectList.addAll(task.getInputs());
}
}
if (bTaskOutputs) {
for (Task task : workflow.getTasks()) {
allWorkflowObjectList.addAll(task.getOutputs());
}
}
boolean bSearchInactive = searchText == null || searchText.length() == 0;
String lowerCaseSearchText = bSearchInactive ? null : searchText.toLowerCase();
ArrayList<WorkflowObject> workflowObjectList = new ArrayList<WorkflowObject>();
for (WorkflowObject workflowObject : allWorkflowObjectList) {
if (bSearchInactive || getValue(workflowObject).toLowerCase().contains(lowerCaseSearchText) || getName(workflowObject).toLowerCase().contains(lowerCaseSearchText) || getType(workflowObject).toLowerCase().contains(lowerCaseSearchText) || getStatus(taskContext, workflowObject).toLowerCase().contains(lowerCaseSearchText)) {
workflowObjectList.add(workflowObject);
}
}
return workflowObjectList;
}
use of org.vcell.workflow.Task in project vcell by virtualcell.
the class WorkflowObjectsTableModel method propertyChange.
@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
super.propertyChange(evt);
if (evt.getSource() instanceof WorkflowObject) {
int changeRow = getRowIndex((WorkflowObject) evt.getSource());
if (changeRow >= 0) {
fireTableRowsUpdated(changeRow, changeRow);
}
} else {
String propertyName = evt.getPropertyName();
if (evt.getSource() == taskContext.getWorkflow()) {
if (propertyName.equals(Workflow.PROPERTY_NAME_PARAMETERS)) {
WorkflowParameter[] oldValue = (WorkflowParameter[]) evt.getOldValue();
if (oldValue != null) {
for (WorkflowParameter parameter : oldValue) {
parameter.removePropertyChangeListener(this);
}
}
WorkflowParameter[] newValue = (WorkflowParameter[]) evt.getNewValue();
if (newValue != null) {
for (WorkflowParameter parameter : newValue) {
parameter.addPropertyChangeListener(this);
}
}
refreshData();
} else if (propertyName.equals(Workflow.PROPERTY_NAME_TASKS)) {
Task[] oldValue = (Task[]) evt.getOldValue();
if (oldValue != null) {
for (Task task : oldValue) {
task.removePropertyChangeListener(this);
for (DataInput dataInput : task.getInputs()) {
dataInput.removePropertyChangeListener(this);
}
for (DataOutput dataOutput : task.getOutputs()) {
dataOutput.removePropertyChangeListener(this);
}
}
}
Task[] newValue = (Task[]) evt.getNewValue();
if (newValue != null) {
for (Task task : newValue) {
task.addPropertyChangeListener(this);
for (DataInput dataInput : task.getInputs()) {
dataInput.addPropertyChangeListener(this);
}
for (DataOutput dataOutput : task.getOutputs()) {
dataOutput.addPropertyChangeListener(this);
}
}
}
refreshData();
}
}
}
}
use of org.vcell.workflow.Task in project vcell by virtualcell.
the class WorkflowJGraphProxy method addCells.
private void addCells(mxEventObject event) {
try {
// remove an existing connection
Object[] cells = (Object[]) event.getProperty("cells");
// add tasks first
for (Object cellObject : cells) {
if (cellObject instanceof WorkflowObjectCell) {
WorkflowObjectCell cell = (WorkflowObjectCell) cellObject;
if (!cell.isEdge()) {
// don't know how to add an object through an event yet ...
WorkflowObject addedTask = cell.workflowObject;
if (cell.workflowObject instanceof Task) {
Task task = (Task) cell.workflowObject;
task.setName(context.getWorkflow().getNextAvailableTaskName(task.getName()));
context.getWorkflow().addTask((Task) cell.workflowObject);
cell.setId(cell.workflowObject.getName());
cell.setGraph(graph);
} else {
// not a task, not an edge, and not already added ... can't handle this now
System.err.println("can't handle this now ... non-edge cell (id=" + cell.getId() + ") added to jGraphX but not already added to workflow");
}
}
}
}
// add edges next
for (Object cellObject : cells) {
if (cellObject instanceof mxCell) {
mxCell cell = (mxCell) cellObject;
if (cell.isEdge()) {
mxICell source = cell.getSource();
mxICell target = cell.getTarget();
if ((source instanceof WorkflowObjectCell) && (target instanceof WorkflowObjectCell)) {
String validationError = validateConnection(source, target);
if (validationError == null) {
WorkflowObject workflowSourceObject = ((WorkflowObjectCell) source).workflowObject;
WorkflowObject workflowTargetObject = ((WorkflowObjectCell) target).workflowObject;
if (workflowSourceObject instanceof DataOutput && workflowTargetObject instanceof DataInput) {
DataInput input = (DataInput) workflowTargetObject;
if (context.getWorkflow().getConnectorSource(input) != null) {
System.out.println("don't add this connection, a connection already exists");
} else {
DataOutput output = (DataOutput) workflowSourceObject;
context.getWorkflow().connect2(output, input);
System.out.println("added edge from " + workflowSourceObject.getPath() + " to " + workflowTargetObject.getPath());
}
}
} else {
System.out.println("didn't connect, " + validationError);
}
}
}
}
}
} finally {
context.getWorkflow().refreshStatus();
}
}
use of org.vcell.workflow.Task in project vcell by virtualcell.
the class WorkflowGraphModel method refreshAll.
/**
* Insert the method's description here.
* Creation date: (7/8/2003 9:11:57 AM)
*/
@Override
public void refreshAll() {
clearAllShapes();
if (getWorkflow() == null) {
fireGraphChanged(new GraphEvent(this));
return;
}
ContainerShape containerShape = new SimpleContainerShape(new Object(), this, "workflow-container");
addShape(containerShape);
//
for (Task task : getWorkflow().getTasks()) {
TaskShape taskShape = new TaskShape(task, this);
containerShape.addChildShape(taskShape);
addShape(taskShape);
//
for (DataOutput<? extends Object> output : task.getOutputs()) {
if (!output.getName().equals("displayed")) {
DataHolderShape dataHolderShape = new DataHolderShape(output, this);
containerShape.addChildShape(dataHolderShape);
addShape(dataHolderShape);
WorkflowEdgeShape workflowEdgeShape = new WorkflowEdgeShape(task.getName() + ":" + output.getName(), taskShape, dataHolderShape, this, true, false);
containerShape.addChildShape(workflowEdgeShape);
addShape(workflowEdgeShape);
}
}
// //
// // add a DataInputShape for each input and connect to TaskShape with an edge
// //
// for (DataInput<? extends Object> input : task.getInputs()){
// DataInputShape dataInputShape = new DataInputShape(input,this);
// containerShape.addChildShape(dataInputShape);
// addShape(dataInputShape);
//
// WorkflowEdgeShape workflowEdgeShape = new WorkflowEdgeShape("input:"+task.getName()+":"+input.name,dataInputShape, taskShape, this, true, false);
// containerShape.addChildShape(workflowEdgeShape);
// addShape(workflowEdgeShape);
// }
}
//
for (Task task : getWorkflow().getTasks()) {
for (DataInput<? extends Object> input : task.getInputs()) {
DataObject<? extends Object> source = getWorkflow().getConnectorSource(input);
if (source instanceof DataOutput) {
DataHolderShape dataHolderShape = (DataHolderShape) getShapeFromModelObject(source);
TaskShape taskShape = (TaskShape) getShapeFromModelObject(task);
WorkflowEdgeShape workflowEdgeShape = new WorkflowEdgeShape("connection:" + input.getName(), dataHolderShape, taskShape, this, true, false);
containerShape.addChildShape(workflowEdgeShape);
addShape(workflowEdgeShape);
}
}
}
fireGraphChanged(new GraphEvent(this));
}
use of org.vcell.workflow.Task in project vcell by virtualcell.
the class WorkflowModelPanel method main.
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
JFrame frame = new javax.swing.JFrame();
WorkflowModelPanel aWorkflowModelPanel;
aWorkflowModelPanel = new WorkflowModelPanel();
frame.setContentPane(aWorkflowModelPanel);
frame.setSize(aWorkflowModelPanel.getSize());
frame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
LocalWorkspace localWorkspace = new LocalWorkspace(new File("C:\\temp"));
Workflow workflow = new Workflow("temp");
class Task1 extends Task {
final DataInput<Double> in = new DataInput<Double>(Double.class, "in", this);
final DataOutput<Double> out = new DataOutput<Double>(Double.class, "out", this);
public Task1() {
super("t1");
addInput(in);
addOutput(out);
}
@Override
protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
System.out.println("executing task " + getName());
}
}
;
class Task2 extends Task {
final DataInput<Double> in = new DataInput<Double>(Double.class, "in", this);
final DataOutput<Double> out = new DataOutput<Double>(Double.class, "out", this);
public Task2() {
super("t2");
addInput(in);
addOutput(out);
}
@Override
protected void compute0(TaskContext context, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
System.out.println("executing task " + getName());
}
}
;
Task1 task1 = new Task1();
workflow.addTask(task1);
Task2 task2 = new Task2();
workflow.addTask(task2);
workflow.connect2(task1.out, task2.in);
aWorkflowModelPanel.setWorkflow(workflow);
frame.setVisible(true);
java.awt.Insets insets = frame.getInsets();
frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
frame.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JPanel");
exception.printStackTrace(System.out);
}
}
Aggregations