Search in sources :

Example 26 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class SubProcessConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertTrue(userTask.getCandidateUsers().size() == 1);
    assertTrue(userTask.getCandidateGroups().size() == 1);
    assertTrue(userTask.getFormProperties().size() == 2);
    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertTrue(subProcess.getLoopCharacteristics().isSequential());
    assertEquals("10", subProcess.getLoopCharacteristics().getLoopCardinality());
    assertEquals("${assignee == \"\"}", subProcess.getLoopCharacteristics().getCompletionCondition());
    assertTrue(subProcess.getFlowElements().size() == 5);
    assertEquals(1, subProcess.getExecutionListeners().size());
    ActivitiListener listenerSubProcess = subProcess.getExecutionListeners().get(0);
    assertEquals("SubProcessTestClass", listenerSubProcess.getImplementation());
    assertEquals(ImplementationType.IMPLEMENTATION_TYPE_CLASS, listenerSubProcess.getImplementationType());
    assertEquals("start", listenerSubProcess.getEvent());
    flowElement = model.getMainProcess().getFlowElement("boundaryEvent1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof BoundaryEvent);
    assertEquals("boundaryEvent1", flowElement.getId());
    BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
    assertNotNull(boundaryEvent.getAttachedToRef());
    assertEquals("subprocess1", boundaryEvent.getAttachedToRef().getId());
    assertEquals(1, boundaryEvent.getEventDefinitions().size());
    assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition);
    assertEquals(1, model.getMainProcess().getExecutionListeners().size());
    ActivitiListener listenerMainProcess = model.getMainProcess().getExecutionListeners().get(0);
    assertEquals("TestClass", listenerMainProcess.getImplementation());
    assertEquals(ImplementationType.IMPLEMENTATION_TYPE_CLASS, listenerMainProcess.getImplementationType());
    assertEquals("start", listenerMainProcess.getEvent());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 27 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class CompleteConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("catchsignal");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof IntermediateCatchEvent);
    assertEquals("catchsignal", flowElement.getId());
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertEquals(1, catchEvent.getEventDefinitions().size());
    assertTrue(catchEvent.getEventDefinitions().get(0) instanceof SignalEventDefinition);
    SignalEventDefinition signalEvent = (SignalEventDefinition) catchEvent.getEventDefinitions().get(0);
    assertEquals("testSignal", signalEvent.getSignalRef());
    flowElement = model.getMainProcess().getFlowElement("subprocess");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    flowElement = subProcess.getFlowElement("receiveTask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ReceiveTask);
    assertEquals("receiveTask", flowElement.getId());
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) ReceiveTask(org.activiti.bpmn.model.ReceiveTask) FlowElement(org.activiti.bpmn.model.FlowElement) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition)

Example 28 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class EncodingConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("writeReportTask");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("writeReportTask", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertEquals("writeReportTask", userTask.getId());
    assertEquals("Fazer relatório", userTask.getName());
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask)

Example 29 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class BpmnDeployer method localizeFlowElements.

protected boolean localizeFlowElements(Collection<FlowElement> flowElements, ObjectNode infoNode) {
    boolean localizationValuesChanged = false;
    if (flowElements == null)
        return localizationValuesChanged;
    CommandContext commandContext = Context.getCommandContext();
    DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
    for (FlowElement flowElement : flowElements) {
        if (flowElement instanceof UserTask || flowElement instanceof SubProcess) {
            List<ExtensionElement> localizationElements = flowElement.getExtensionElements().get("localization");
            if (localizationElements != null) {
                for (ExtensionElement localizationElement : localizationElements) {
                    if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
                        String locale = localizationElement.getAttributeValue(null, "locale");
                        String name = localizationElement.getAttributeValue(null, "name");
                        String documentation = null;
                        List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
                        if (documentationElements != null) {
                            for (ExtensionElement documentationElement : documentationElements) {
                                documentation = StringUtils.trimToNull(documentationElement.getElementText());
                                break;
                            }
                        }
                        String flowElementId = flowElement.getId();
                        if (isEqualToCurrentLocalizationValue(locale, flowElementId, "name", name, infoNode) == false) {
                            dynamicBpmnService.changeLocalizationName(locale, flowElementId, name, infoNode);
                            localizationValuesChanged = true;
                        }
                        if (documentation != null && isEqualToCurrentLocalizationValue(locale, flowElementId, "description", documentation, infoNode) == false) {
                            dynamicBpmnService.changeLocalizationDescription(locale, flowElementId, documentation, infoNode);
                            localizationValuesChanged = true;
                        }
                        break;
                    }
                }
            }
            if (flowElement instanceof SubProcess) {
                SubProcess subprocess = (SubProcess) flowElement;
                boolean isFlowElementLocalizationChanged = localizeFlowElements(subprocess.getFlowElements(), infoNode);
                boolean isDataObjectLocalizationChanged = localizeDataObjectElements(subprocess.getDataObjects(), infoNode);
                if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
                    localizationValuesChanged = true;
                }
            }
        }
    }
    return localizationValuesChanged;
}
Also used : SubProcess(org.activiti.bpmn.model.SubProcess) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) DynamicBpmnService(org.activiti.engine.DynamicBpmnService) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) ExtensionElement(org.activiti.bpmn.model.ExtensionElement)

Example 30 with UserTask

use of org.activiti.bpmn.model.UserTask in project Activiti by Activiti.

the class UserTaskXMLConverter method writeAdditionalAttributes.

@Override
@SuppressWarnings("unchecked")
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
    UserTask userTask = (UserTask) element;
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_ASSIGNEE, userTask.getAssignee(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_OWNER, userTask.getOwner(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEUSERS, convertToDelimitedString(userTask.getCandidateUsers()), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEGROUPS, convertToDelimitedString(userTask.getCandidateGroups()), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_DUEDATE, userTask.getDueDate(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_BUSINESS_CALENDAR_NAME, userTask.getBusinessCalendarName(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CATEGORY, userTask.getCategory(), xtw);
    writeQualifiedAttribute(ATTRIBUTE_FORM_FORMKEY, userTask.getFormKey(), xtw);
    if (userTask.getPriority() != null) {
        writeQualifiedAttribute(ATTRIBUTE_TASK_USER_PRIORITY, userTask.getPriority().toString(), xtw);
    }
    if (StringUtils.isNotEmpty(userTask.getExtensionId())) {
        writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_EXTENSIONID, userTask.getExtensionId(), xtw);
    }
    if (userTask.getSkipExpression() != null) {
        writeQualifiedAttribute(ATTRIBUTE_TASK_USER_SKIP_EXPRESSION, userTask.getSkipExpression(), xtw);
    }
    // write custom attributes
    BpmnXMLUtil.writeCustomAttributes(userTask.getAttributes().values(), xtw, defaultElementAttributes, defaultActivityAttributes, defaultUserTaskAttributes);
}
Also used : AlfrescoUserTask(org.activiti.bpmn.model.alfresco.AlfrescoUserTask) UserTask(org.activiti.bpmn.model.UserTask)

Aggregations

UserTask (org.activiti.bpmn.model.UserTask)48 FlowElement (org.activiti.bpmn.model.FlowElement)25 StartEvent (org.activiti.bpmn.model.StartEvent)18 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)11 SubProcess (org.activiti.bpmn.model.SubProcess)11 FormProperty (org.activiti.bpmn.model.FormProperty)7 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)6 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 EndEvent (org.activiti.bpmn.model.EndEvent)6 HashMap (java.util.HashMap)5 BpmnModel (org.activiti.bpmn.model.BpmnModel)5 Process (org.activiti.bpmn.model.Process)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 FormValue (org.activiti.bpmn.model.FormValue)4 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 AlfrescoUserTask (org.activiti.bpmn.model.alfresco.AlfrescoUserTask)4 HumanStepDefinition (org.activiti.workflow.simple.definition.HumanStepDefinition)4 FormDefinition (org.activiti.workflow.simple.definition.form.FormDefinition)4 ArrayList (java.util.ArrayList)3