use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class EditModelClickListener method showSelectEditorPopupWindow.
protected void showSelectEditorPopupWindow() {
final PopupWindow selectEditorPopupWindow = new PopupWindow();
selectEditorPopupWindow.setModal(true);
selectEditorPopupWindow.setResizable(false);
selectEditorPopupWindow.setWidth("350px");
selectEditorPopupWindow.setHeight("250px");
selectEditorPopupWindow.addStyleName(Reindeer.PANEL_LIGHT);
selectEditorPopupWindow.center();
final SelectEditorComponent selectEditorComponent = new SelectEditorComponent(false);
selectEditorComponent.getModelerDescriptionLabel().setValue(ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_CONVERSION_WARNING_MODELER));
selectEditorComponent.getModelerDescriptionLabel().addStyleName(ExplorerLayout.STYLE_LABEL_RED);
selectEditorComponent.preferTableDrivenEditor();
selectEditorPopupWindow.getContent().addComponent(selectEditorComponent);
selectEditorComponent.setEditorSelectedListener(new EditorSelectedListener() {
public void editorSelectionChanged() {
try {
WorkflowDefinition workflowDefinition = loadWorkflowDefinition();
// When using the modeler, the format must first be converted to the modeler json format
if (selectEditorComponent.isModelerPreferred()) {
WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
conversion.convert();
RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
model.setCategory(null);
ObjectMapper objectMapper = new ObjectMapper();
ObjectNode metaInfoJson = objectMapper.createObjectNode();
metaInfoJson.put("name", model.getName());
model.setMetaInfo(metaInfoJson.toString());
repositoryService.saveModel(model);
BpmnJsonConverter bpmnJsonConverter = new BpmnJsonConverter();
ObjectNode json = bpmnJsonConverter.convertToJson(conversion.getBpmnModel());
repositoryService.addModelEditorSource(model.getId(), json.toString().getBytes("utf-8"));
// Show modeler
showModeler();
} else {
// Load and show table editor
ExplorerApp.get().getViewManager().showSimpleTableProcessEditor(model.getId(), workflowDefinition);
}
} catch (Exception e) {
LOGGER.error("Error showing editor", e);
ExplorerApp.get().getNotificationManager().showErrorNotification(Messages.PROCESS_EDITOR_LOADING_ERROR, e);
} finally {
ExplorerApp.get().getMainWindow().removeWindow(selectEditorPopupWindow);
}
}
});
ExplorerApp.get().getViewManager().showPopupWindow(selectEditorPopupWindow);
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowConversionTest method testMultipleConditionsInChoice.
@Test
public void testMultipleConditionsInChoice() throws Exception {
TaskService taskService = activitiRule.getTaskService();
WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").description("This is a test workflow").inChoice().inList().addCondition("test", "==", "'hello'").addCondition("test2", "==", "'world'").addHumanStep("first task", "kermit").endList().inList().addHumanStep("gonzo task", "gonzo").endList().endChoice();
// Validate
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("test", "hello");
varMap.put("test2", "world");
String definitionKey = convertAndDeploy(workflowDefinition);
ProcessInstance instance = activitiRule.getRuntimeService().startProcessInstanceByKey(definitionKey, varMap);
assertEquals(1, taskService.createTaskQuery().taskAssignee("kermit").count());
assertEquals(0, taskService.createTaskQuery().taskAssignee("gonzo").count());
Task task = taskService.createTaskQuery().singleResult();
assertEquals("first task", task.getName());
taskService.complete(task.getId());
assertEquals(0, activitiRule.getRuntimeService().createProcessInstanceQuery().processInstanceId(instance.getId()).count());
varMap = new HashMap<String, Object>();
varMap.put("test", "world");
varMap.put("test2", "world");
instance = activitiRule.getRuntimeService().startProcessInstanceByKey(definitionKey, varMap);
assertEquals(0, taskService.createTaskQuery().taskAssignee("kermit").count());
assertEquals(1, taskService.createTaskQuery().taskAssignee("gonzo").count());
task = taskService.createTaskQuery().singleResult();
assertEquals("gonzo task", task.getName());
taskService.complete(task.getId());
assertEquals(0, activitiRule.getRuntimeService().createProcessInstanceQuery().processInstanceId(instance.getId()).count());
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowConversionTest method testUserTasksWithOnlyAssignees.
@Test
public void testUserTasksWithOnlyAssignees() {
String[] assignees = new String[] { "kermit", "gonzo", "mispiggy" };
WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").description("This is a test workflow").addHumanStep("first task", assignees[0]).addHumanStep("second step", assignees[1]).addHumanStep("third step", assignees[2]);
// Validate
activitiRule.getRuntimeService().startProcessInstanceByKey(convertAndDeploy(workflowDefinition));
for (String assignee : assignees) {
Task task = activitiRule.getTaskService().createTaskQuery().singleResult();
assertEquals(assignee, task.getAssignee());
activitiRule.getTaskService().complete(task.getId());
}
assertEquals(0, activitiRule.getRuntimeService().createProcessInstanceQuery().count());
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowConversionTest method testFeedbackStepWithUserSelectionAtRuntimeAllFeedbackProvided.
@Test
public void testFeedbackStepWithUserSelectionAtRuntimeAllFeedbackProvided() {
WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").description("This is a test workflow").addFeedbackStep("Test feedback", "kermit");
activitiRule.getRuntimeService().startProcessInstanceByKey(convertAndDeploy(workflowDefinition));
// First, a task should be assigned to kermit to select the people
assertEquals(1, taskService.createTaskQuery().count());
assertEquals(1, taskService.createTaskQuery().taskAssignee("kermit").count());
Task task = taskService.createTaskQuery().singleResult();
// Completing the task using the predefined process variable (normally done through the form)
TaskService taskService = activitiRule.getTaskService();
taskService.complete(task.getId(), CollectionUtil.singletonMap(FeedbackStepDefinitionConverter.VARIABLE_FEEDBACK_PROVIDERS, Arrays.asList("gonzo", "fozzie")));
// Three tasks should be available now
assertEquals(3, taskService.createTaskQuery().count());
assertEquals(1, taskService.createTaskQuery().taskAssignee("kermit").count());
assertEquals(1, taskService.createTaskQuery().taskAssignee("gonzo").count());
assertEquals(1, taskService.createTaskQuery().taskAssignee("fozzie").count());
// Completing the feedback tasks first should only leave the 'gather feedback' task for kermit open
for (Task feedbackTask : taskService.createTaskQuery().list()) {
if (!feedbackTask.getAssignee().equals("kermit")) {
activitiRule.getTaskService().complete(feedbackTask.getId());
}
}
assertEquals(1, taskService.createTaskQuery().count());
assertEquals(1, taskService.createTaskQuery().taskAssignee("kermit").count());
// Completing this last task should finish the process
activitiRule.getTaskService().complete(activitiRule.getTaskService().createTaskQuery().singleResult().getId());
assertEquals(0, activitiRule.getRuntimeService().createProcessInstanceQuery().count());
}
use of org.activiti.workflow.simple.definition.WorkflowDefinition in project Activiti by Activiti.
the class WorkflowConversionTest method testSimplestProcess.
@Test
public void testSimplestProcess() {
WorkflowDefinition workflowDefinition = new WorkflowDefinition().name("testWorkflow").description("This is a test workflow");
// Validate
ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey(convertAndDeploy(workflowDefinition));
assertTrue(processInstance.isEnded());
}
Aggregations