throws RepositoryException, EngineException {
if (taskIds == null || (taskIds != null && taskIds.size() == 0))
throw new RepositoryException(
"Must specify task identifiers to build dynamic workflows!");
Workflow dynamicWorkflow = new Workflow();
for (String taskId : taskIds) {
WorkflowTask task = this.repo.getWorkflowTaskById(taskId);
if (task == null)
throw new RepositoryException("Dynamic workflow task: [" + taskId
+ "] is not defined!");
dynamicWorkflow.getTasks().add(task);
}
dynamicWorkflow.setId(this.repo.addWorkflow(dynamicWorkflow));
dynamicWorkflow.setName("Dynamic Workflow-" + dynamicWorkflow.getId());
Metadata met = new Metadata();
met.addMetadata(metadata);
WorkflowInstance inst = this.engine.startWorkflow(dynamicWorkflow, met);