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);
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
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());
}
Aggregations