Search in sources :

Example 1 with Resource

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

the class ResourceParser method parse.

public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception {
    String resourceId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
    String resourceName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
    Resource resource;
    if (model.containsResourceId(resourceId)) {
        resource = model.getResource(resourceId);
        resource.setName(resourceName);
        for (org.activiti.bpmn.model.Process process : model.getProcesses()) {
            for (FlowElement fe : process.getFlowElements()) {
                if (fe instanceof UserTask && ((UserTask) fe).getCandidateGroups().contains(resourceId)) {
                    ((UserTask) fe).getCandidateGroups().remove(resourceId);
                    ((UserTask) fe).getCandidateGroups().add(resourceName);
                }
            }
        }
    } else {
        resource = new Resource(resourceId, resourceName);
        model.addResource(resource);
    }
    BpmnXMLUtil.addXMLLocation(resource, xtr);
}
Also used : FlowElement(org.activiti.bpmn.model.FlowElement) Resource(org.activiti.bpmn.model.Resource) UserTask(org.activiti.bpmn.model.UserTask)

Aggregations

FlowElement (org.activiti.bpmn.model.FlowElement)1 Resource (org.activiti.bpmn.model.Resource)1 UserTask (org.activiti.bpmn.model.UserTask)1