Search in sources :

Example 41 with FlowElement

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

the class ValidatorImpl method addError.

protected void addError(List<ValidationError> validationErrors, String problem, Process process, BaseElement baseElement, String description, boolean isWarning) {
    ValidationError error = new ValidationError();
    error.setWarning(isWarning);
    if (process != null) {
        error.setProcessDefinitionId(process.getId());
        error.setProcessDefinitionName(process.getName());
    }
    if (baseElement != null) {
        error.setXmlLineNumber(baseElement.getXmlRowNumber());
        error.setXmlColumnNumber(baseElement.getXmlColumnNumber());
    }
    error.setProblem(problem);
    error.setDefaultDescription(description);
    if (baseElement instanceof FlowElement) {
        FlowElement flowElement = (FlowElement) baseElement;
        error.setActivityId(flowElement.getId());
        error.setActivityName(flowElement.getName());
    }
    addError(validationErrors, error);
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) ValidationError(org.activiti.validation.ValidationError)

Example 42 with FlowElement

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

the class FlowElementValidator method executeValidation.

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
    for (FlowElement flowElement : process.getFlowElements()) {
        if (flowElement instanceof Activity) {
            Activity activity = (Activity) flowElement;
            handleConstraints(process, activity, errors);
            handleMultiInstanceLoopCharacteristics(process, activity, errors);
            handleDataAssociations(process, activity, errors);
        }
    }
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) Activity(org.activiti.bpmn.model.Activity)

Example 43 with FlowElement

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

the class BaseBpmnXMLConverter method convertToBpmnModel.

public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process activeProcess, List<SubProcess> activeSubProcessList) throws Exception {
    String elementId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
    String elementName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
    boolean async = parseAsync(xtr);
    boolean notExclusive = parseNotExclusive(xtr);
    String defaultFlow = xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT);
    boolean isForCompensation = parseForCompensation(xtr);
    BaseElement parsedElement = convertXMLToElement(xtr, model);
    if (parsedElement instanceof Artifact) {
        Artifact currentArtifact = (Artifact) parsedElement;
        currentArtifact.setId(elementId);
        if (!activeSubProcessList.isEmpty()) {
            activeSubProcessList.get(activeSubProcessList.size() - 1).addArtifact(currentArtifact);
        } else {
            activeProcess.addArtifact(currentArtifact);
        }
    }
    if (parsedElement instanceof FlowElement) {
        FlowElement currentFlowElement = (FlowElement) parsedElement;
        currentFlowElement.setId(elementId);
        currentFlowElement.setName(elementName);
        if (currentFlowElement instanceof FlowNode) {
            FlowNode flowNode = (FlowNode) currentFlowElement;
            flowNode.setAsynchronous(async);
            flowNode.setNotExclusive(notExclusive);
            if (currentFlowElement instanceof Activity) {
                Activity activity = (Activity) currentFlowElement;
                activity.setForCompensation(isForCompensation);
                if (StringUtils.isNotEmpty(defaultFlow)) {
                    activity.setDefaultFlow(defaultFlow);
                }
            }
            if (currentFlowElement instanceof Gateway) {
                Gateway gateway = (Gateway) currentFlowElement;
                if (StringUtils.isNotEmpty(defaultFlow)) {
                    gateway.setDefaultFlow(defaultFlow);
                }
            }
        }
        if (currentFlowElement instanceof DataObject) {
            if (!activeSubProcessList.isEmpty()) {
                activeSubProcessList.get(activeSubProcessList.size() - 1).getDataObjects().add((ValuedDataObject) parsedElement);
            } else {
                activeProcess.getDataObjects().add((ValuedDataObject) parsedElement);
            }
        }
        if (!activeSubProcessList.isEmpty()) {
            activeSubProcessList.get(activeSubProcessList.size() - 1).addFlowElement(currentFlowElement);
        } else {
            activeProcess.addFlowElement(currentFlowElement);
        }
    }
}
Also used : BaseElement(org.activiti.bpmn.model.BaseElement) DataObject(org.activiti.bpmn.model.DataObject) ValuedDataObject(org.activiti.bpmn.model.ValuedDataObject) FlowElement(org.activiti.bpmn.model.FlowElement) Gateway(org.activiti.bpmn.model.Gateway) Activity(org.activiti.bpmn.model.Activity) Artifact(org.activiti.bpmn.model.Artifact) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 44 with FlowElement

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

the class FormPropertiesConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertEquals("formPropertiesProcess", model.getMainProcess().getId());
    assertEquals("User registration", model.getMainProcess().getName());
    assertEquals(true, model.getMainProcess().isExecutable());
    FlowElement startFlowElement = model.getMainProcess().getFlowElement("startNode");
    assertNotNull(startFlowElement);
    assertTrue(startFlowElement instanceof StartEvent);
    StartEvent startEvent = (StartEvent) startFlowElement;
    for (FormProperty formProperty : startEvent.getFormProperties()) {
        assertEquals(true, formProperty.isRequired());
    }
    FlowElement userFlowElement = model.getMainProcess().getFlowElement("userTask");
    assertNotNull(userFlowElement);
    assertTrue(userFlowElement instanceof UserTask);
    UserTask userTask = (UserTask) userFlowElement;
    List<FormProperty> formProperties = userTask.getFormProperties();
    assertNotNull(formProperties);
    assertEquals("Invalid form properties list: ", 8, formProperties.size());
    for (FormProperty formProperty : formProperties) {
        if (formProperty.getId().equals("new_property_1")) {
            checkFormProperty(formProperty, false, false, false);
        } else if (formProperty.getId().equals("new_property_2")) {
            checkFormProperty(formProperty, false, false, true);
        } else if (formProperty.getId().equals("new_property_3")) {
            checkFormProperty(formProperty, false, true, false);
        } else if (formProperty.getId().equals("new_property_4")) {
            checkFormProperty(formProperty, false, true, true);
        } else if (formProperty.getId().equals("new_property_5")) {
            checkFormProperty(formProperty, true, false, false);
            List<Map<String, Object>> formValues = new ArrayList<Map<String, Object>>();
            for (FormValue formValue : formProperty.getFormValues()) {
                Map<String, Object> formValueMap = new HashMap<String, Object>();
                formValueMap.put("id", formValue.getId());
                formValueMap.put("name", formValue.getName());
                formValues.add(formValueMap);
            }
            checkFormPropertyFormValues(formValues);
        } else if (formProperty.getId().equals("new_property_6")) {
            checkFormProperty(formProperty, true, false, true);
        } else if (formProperty.getId().equals("new_property_7")) {
            checkFormProperty(formProperty, true, true, false);
        } else if (formProperty.getId().equals("new_property_8")) {
            checkFormProperty(formProperty, true, true, true);
        }
    }
}
Also used : FormValue(org.activiti.bpmn.model.FormValue) FormProperty(org.activiti.bpmn.model.FormProperty) HashMap(java.util.HashMap) UserTask(org.activiti.bpmn.model.UserTask) ArrayList(java.util.ArrayList) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) HashMap(java.util.HashMap) Map(java.util.Map)

Example 45 with FlowElement

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

the class MapExceptionConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    // check service task with andChildren Set to True
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetaskWithAndTrueAndChildren");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ServiceTask);
    assertEquals("servicetaskWithAndTrueAndChildren", flowElement.getId());
    ServiceTask serviceTask = (ServiceTask) flowElement;
    assertNotNull(serviceTask.getMapExceptions());
    assertEquals(3, serviceTask.getMapExceptions().size());
    // check a normal mapException, with hasChildren == true
    assertEquals("myErrorCode1", serviceTask.getMapExceptions().get(0).getErrorCode());
    assertEquals("com.activiti.Something1", serviceTask.getMapExceptions().get(0).getClassName());
    assertTrue(serviceTask.getMapExceptions().get(0).isAndChildren());
    // check a normal mapException, with hasChildren == false
    assertEquals("myErrorCode2", serviceTask.getMapExceptions().get(1).getErrorCode());
    assertEquals("com.activiti.Something2", serviceTask.getMapExceptions().get(1).getClassName());
    assertFalse(serviceTask.getMapExceptions().get(1).isAndChildren());
    // check a normal mapException, with no hasChildren Defined, default should
    // be false
    assertEquals("myErrorCode3", serviceTask.getMapExceptions().get(2).getErrorCode());
    assertEquals("com.activiti.Something3", serviceTask.getMapExceptions().get(2).getClassName());
    assertFalse(serviceTask.getMapExceptions().get(2).isAndChildren());
    // if no map exception is defined, getMapException should return a not null
    // empty list
    FlowElement flowElement1 = model.getMainProcess().getFlowElement("servicetaskWithNoMapException");
    assertNotNull(flowElement1);
    assertTrue(flowElement1 instanceof ServiceTask);
    assertEquals("servicetaskWithNoMapException", flowElement1.getId());
    ServiceTask serviceTask1 = (ServiceTask) flowElement1;
    assertNotNull(serviceTask1.getMapExceptions());
    assertEquals(0, serviceTask1.getMapExceptions().size());
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FlowElement(org.activiti.bpmn.model.FlowElement)

Aggregations

FlowElement (org.activiti.bpmn.model.FlowElement)77 SubProcess (org.activiti.bpmn.model.SubProcess)27 UserTask (org.activiti.bpmn.model.UserTask)26 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)24 StartEvent (org.activiti.bpmn.model.StartEvent)14 Process (org.activiti.bpmn.model.Process)13 ArrayList (java.util.ArrayList)11 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)11 HashMap (java.util.HashMap)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)9 Activity (org.activiti.bpmn.model.Activity)9 ServiceTask (org.activiti.bpmn.model.ServiceTask)9 Gateway (org.activiti.bpmn.model.Gateway)8 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)7 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)7 Artifact (org.activiti.bpmn.model.Artifact)6 FlowNode (org.activiti.bpmn.model.FlowNode)6 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)6 BpmnModel (org.activiti.bpmn.model.BpmnModel)5 EventDefinition (org.activiti.bpmn.model.EventDefinition)5