try {
workflows = client.getWorkflows();
if (workflows != null) {
for (Iterator i = workflows.iterator(); i.hasNext();) {
Workflow w = (Workflow) i.next();
System.out.println("Workflow: [id=" + w.getId()
+ ", name=" + w.getName() + ", numTasks="
+ w.getTasks().size() + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getTaskById")) {
String taskId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
taskId = args[++i];
}
}
if (taskId == null) {
System.err.println(getTaskByIdOperation);
System.exit(1);
}
// create the client
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowTask task = null;
try {
task = client.getTaskById(taskId);
System.out.println("Task: [id=" + task.getTaskId() + ", name="
+ task.getTaskName() + ", order=" + task.getOrder()
+ ", class=" + task.getClass().getName()
+ ", numConditions=" + task.getConditions().size()
+ ", configuration="
+ task.getTaskConfig().getProperties() + "]");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getConditionById")) {
String conditionId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
conditionId = args[++i];
}
}
if (conditionId == null) {
System.err.println(getConditionByIdOperation);
System.exit(1);
}
// create the client
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
WorkflowCondition condition = null;
try {
condition = client.getConditionById(conditionId);
System.out.println("Condition: [id="
+ condition.getConditionId() + ", name="
+ condition.getConditionName() + ", order="
+ condition.getOrder() + ", class="
+ condition.getClass().getName() + "]");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getWorkflowById")) {
String workflowId = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--id")) {
workflowId = args[++i];
}
}
if (workflowId == null) {
System.err.println(getWorkflowByIdOperation);
System.exit(1);
}
// create the client
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
Workflow workflow = null;
try {
workflow = client.getWorkflowById(workflowId);
System.out.println("Workflow: [id=" + workflow.getId()
+ ", name=" + workflow.getName() + ", numTasks="
+ workflow.getTasks().size() + "]");
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getRegisteredEvents")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
List events = null;
try {
events = client.getRegisteredEvents();
if (events != null) {
for (Iterator i = events.iterator(); i.hasNext();) {
String event = (String) i.next();
System.out.println("Event: [name=" + event + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
} else if (operation.equals("--getWorkflowsByEvent")) {
XmlRpcWorkflowManagerClient client = new XmlRpcWorkflowManagerClient(
new URL(url));
List workflows = null;
String eventName = null;
for (int i = 4; i < args.length; i++) {
if (args[i].equals("--eventName")) {
eventName = args[++i];
}
}
if (eventName == null) {
System.err.println(getWorkflowsByEventOperation);
System.exit(1);
}
try {
workflows = client.getWorkflowsByEvent(eventName);
if (workflows != null) {
for (Iterator i = workflows.iterator(); i.hasNext();) {
Workflow w = (Workflow) i.next();
System.out.println("Workflow: [id=" + w.getId()
+ ", name=" + w.getName() + ", numTasks="
+ w.getTasks().size() + "]");
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);