use of org.activiti.bpmn.model.Process in project Activiti by Activiti.
the class PoolsConverterTest method validateModel.
private void validateModel(BpmnModel model) {
assertEquals(1, model.getPools().size());
Pool pool = model.getPools().get(0);
assertEquals("pool1", pool.getId());
assertEquals("Pool", pool.getName());
Process process = model.getProcess(pool.getId());
assertNotNull(process);
assertEquals(2, process.getLanes().size());
Lane lane = process.getLanes().get(0);
assertEquals("lane1", lane.getId());
assertEquals("Lane 1", lane.getName());
assertEquals(2, lane.getFlowReferences().size());
lane = process.getLanes().get(1);
assertEquals("lane2", lane.getId());
assertEquals("Lane 2", lane.getName());
assertEquals(2, lane.getFlowReferences().size());
FlowElement flowElement = process.getFlowElement("flow1");
assertNotNull(flowElement);
assertTrue(flowElement instanceof SequenceFlow);
}
use of org.activiti.bpmn.model.Process in project Activiti by Activiti.
the class ProcessParser method parse.
public Process parse(XMLStreamReader xtr, BpmnModel model) throws Exception {
Process process = null;
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
String processId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
process = new Process();
process.setId(processId);
BpmnXMLUtil.addXMLLocation(process, xtr);
process.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE))) {
process.setExecutable(Boolean.parseBoolean(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_EXECUTABLE)));
}
String candidateUsersString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS);
if (StringUtils.isNotEmpty(candidateUsersString)) {
List<String> candidateUsers = BpmnXMLUtil.parseDelimitedList(candidateUsersString);
process.setCandidateStarterUsers(candidateUsers);
}
String candidateGroupsString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_GROUPS);
if (StringUtils.isNotEmpty(candidateGroupsString)) {
List<String> candidateGroups = BpmnXMLUtil.parseDelimitedList(candidateGroupsString);
process.setCandidateStarterGroups(candidateGroups);
}
BpmnXMLUtil.addCustomAttributes(xtr, process, ProcessExport.defaultProcessAttributes);
model.getProcesses().add(process);
}
return process;
}
use of org.activiti.bpmn.model.Process in project Activiti by Activiti.
the class IOSpecificationParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (parentElement instanceof Activity == false && parentElement instanceof Process == false)
return;
IOSpecification ioSpecification = new IOSpecification();
BpmnXMLUtil.addXMLLocation(ioSpecification, xtr);
boolean readyWithIOSpecification = false;
try {
while (readyWithIOSpecification == false && xtr.hasNext()) {
xtr.next();
if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) {
DataSpec dataSpec = new DataSpec();
BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
ioSpecification.getDataInputs().add(dataSpec);
} else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) {
DataSpec dataSpec = new DataSpec();
BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
ioSpecification.getDataOutputs().add(dataSpec);
} else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
String dataInputRefs = xtr.getElementText();
if (StringUtils.isNotEmpty(dataInputRefs)) {
ioSpecification.getDataInputRefs().add(dataInputRefs.trim());
}
} else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
String dataOutputRefs = xtr.getElementText();
if (StringUtils.isNotEmpty(dataOutputRefs)) {
ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim());
}
} else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
readyWithIOSpecification = true;
}
}
} catch (Exception e) {
LOGGER.warn("Error parsing ioSpecification child elements", e);
}
if (parentElement instanceof Process) {
((Process) parentElement).setIoSpecification(ioSpecification);
} else {
((Activity) parentElement).setIoSpecification(ioSpecification);
}
}
use of org.activiti.bpmn.model.Process in project Activiti by Activiti.
the class BpmnParseTest method testParseDiagramInterchangeElementsForUnknownModelElements.
@Deployment
public void testParseDiagramInterchangeElementsForUnknownModelElements() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("TestAnnotation").singleResult();
BpmnModel model = repositoryService.getBpmnModel(processDefinition.getId());
Process mainProcess = model.getMainProcess();
assertEquals(0, mainProcess.getExtensionElements().size());
}
use of org.activiti.bpmn.model.Process in project Activiti by Activiti.
the class BpmnModelValidator method validate.
@Override
public void validate(BpmnModel bpmnModel, List<ValidationError> errors) {
// If all process definitions of this bpmnModel are not executable, raise an error
boolean isAtLeastOneExecutable = validateAtLeastOneExecutable(bpmnModel, errors);
// If at least one process definition is executable, show a warning for each of the none-executables
if (isAtLeastOneExecutable) {
for (Process process : bpmnModel.getProcesses()) {
if (!process.isExecutable()) {
addWarning(errors, Problems.PROCESS_DEFINITION_NOT_EXECUTABLE, process, process, "Process definition is not executable. Please verify that this is intentional.");
}
handleProcessConstraints(bpmnModel, process, errors);
}
}
handleBPMNModelConstraints(bpmnModel, errors);
}
Aggregations