org.activiti.bpmn.model.Process类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(15.5k)|赞(0)|评价(0)|浏览(401)

本文整理了Java中org.activiti.bpmn.model.Process类的一些代码示例,展示了Process类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Process类的具体详情如下:
包路径:org.activiti.bpmn.model.Process
类名称:Process

Process介绍

暂无

代码示例

代码示例来源:origin: Activiti/Activiti

xtw.writeAttribute(ATTRIBUTE_ID, process.getId());
if (StringUtils.isNotEmpty(process.getName())) {
 xtw.writeAttribute(ATTRIBUTE_NAME, process.getName());
xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable()));
if (!process.getCandidateStarterUsers().isEmpty()) {
 xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_USERS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers()));
if (!process.getCandidateStarterGroups().isEmpty()) {
 xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_PROCESS_CANDIDATE_GROUPS, BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterGroups()));
BpmnXMLUtil.writeCustomAttributes(process.getAttributes().values(), xtw, defaultProcessAttributes);
if (StringUtils.isNotEmpty(process.getDocumentation())) {
 xtw.writeCharacters(process.getDocumentation());
 xtw.writeEndElement();

代码示例来源:origin: Activiti/Activiti

public BpmnModel convertToBpmnModel(XMLStreamReader xtr) {
 BpmnModel model = new BpmnModel();
 model.setStartEventFormTypes(startEventFormTypes);
 model.setUserTaskFormTypes(userTaskFormTypes);
 try {
  Process activeProcess = null;
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
     model.addError(xtr.getAttributeValue(null, ATTRIBUTE_ID), xtr.getAttributeValue(null, ATTRIBUTE_ERROR_CODE));
  for (Process process : model.getProcesses()) {
   for (Pool pool : model.getPools()) {
    if (process.getId().equals(pool.getProcessRef())) {
     pool.setExecutable(process.isExecutable());
   processFlowElements(process.getFlowElements(), process);

代码示例来源:origin: Activiti/Activiti

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;
 }
}

代码示例来源:origin: Activiti/Activiti

protected void handleProcessConstraints(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 if (process.getId() != null && process.getId().length() > Constraints.PROCESS_DEFINITION_ID_MAX_LENGTH) {
  addError(errors, Problems.PROCESS_DEFINITION_ID_TOO_LONG, process,
    "The id of the process definition must not contain more than " + Constraints.PROCESS_DEFINITION_ID_MAX_LENGTH + " characters");
 }
 if (process.getName() != null && process.getName().length() > Constraints.PROCESS_DEFINITION_NAME_MAX_LENGTH) {
  addError(errors, Problems.PROCESS_DEFINITION_NAME_TOO_LONG, process,
    "The name of the process definition must not contain more than " + Constraints.PROCESS_DEFINITION_NAME_MAX_LENGTH + " characters");
 }
 if (process.getDocumentation() != null && process.getDocumentation().length() > Constraints.PROCESS_DEFINITION_DOCUMENTATION_MAX_LENGTH) {
  addError(errors, Problems.PROCESS_DEFINITION_DOCUMENTATION_TOO_LONG, process,
    "The documentation of the process definition must not contain more than " + Constraints.PROCESS_DEFINITION_DOCUMENTATION_MAX_LENGTH + " characters");
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 List<EventGateway> eventGateways = process.findFlowElementsOfType(EventGateway.class);
 for (EventGateway eventGateway : eventGateways) {
  for (SequenceFlow sequenceFlow : eventGateway.getOutgoingFlows()) {
   FlowElement flowElement = process.getFlowElement(sequenceFlow.getTargetRef(), true);
   if (flowElement != null && !(flowElement instanceof IntermediateCatchEvent)) {
    addError(errors, Problems.EVENT_GATEWAY_ONLY_CONNECTED_TO_INTERMEDIATE_EVENTS, process, eventGateway, "Event based gateway can only be connected to elements of type intermediateCatchEvent");
   }
  }
 }
}

代码示例来源:origin: Activiti/Activiti

protected void executeParse(BpmnParse bpmnParse, Process process) {
 if (process.isExecutable() == false) {
  LOGGER.info("Ignoring non-executable process with id='" + process.getId() + "'. Set the attribute isExecutable=\"true\" to deploy this process.");
 } else {
  bpmnParse.getProcessDefinitions().add(transformProcess(bpmnParse, process));
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 List<SendTask> sendTasks = process.findFlowElementsOfType(SendTask.class);
 for (SendTask sendTask : sendTasks) {
  // Verify implementation
  if (StringUtils.isEmpty(sendTask.getType()) && !ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType())) {
   addError(errors, Problems.SEND_TASK_INVALID_IMPLEMENTATION, process, sendTask, "One of the attributes 'type' or 'operation' is mandatory on sendTask");
  }
  // Verify type
  if (StringUtils.isNotEmpty(sendTask.getType())) {
   if (!sendTask.getType().equalsIgnoreCase("mail") && !sendTask.getType().equalsIgnoreCase("mule") && !sendTask.getType().equalsIgnoreCase("camel")) {
    addError(errors, Problems.SEND_TASK_INVALID_TYPE, process, sendTask, "Invalid or unsupported type for send task");
   }
   if (sendTask.getType().equalsIgnoreCase("mail")) {
    validateFieldDeclarationsForEmail(process, sendTask, sendTask.getFieldExtensions(), errors);
   }
  }
  // Web service
  verifyWebservice(bpmnModel, process, sendTask, errors);
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 // Gather data objects
 List<ValuedDataObject> allDataObjects = new ArrayList<ValuedDataObject>();
 allDataObjects.addAll(process.getDataObjects());
 List<SubProcess> subProcesses = process.findFlowElementsOfType(SubProcess.class, true);
 for (SubProcess subProcess : subProcesses) {
  allDataObjects.addAll(subProcess.getDataObjects());
 }
 // Validate
 for (ValuedDataObject dataObject : allDataObjects) {
  if (StringUtils.isEmpty(dataObject.getName())) {
   addError(errors, Problems.DATA_OBJECT_MISSING_NAME, process, dataObject, "Name is mandatory for a data object");
  }
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 List<ScriptTask> scriptTasks = process.findFlowElementsOfType(ScriptTask.class);
 for (ScriptTask scriptTask : scriptTasks) {
  if (StringUtils.isEmpty(scriptTask.getScript())) {
   addError(errors, Problems.SCRIPT_TASK_MISSING_SCRIPT, process, scriptTask, "No script provided for script task");
  }
 }
}

代码示例来源:origin: Activiti/Activiti

@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
 List<SequenceFlow> sequenceFlows = process.findFlowElementsOfType(SequenceFlow.class);
 for (SequenceFlow sequenceFlow : sequenceFlows) {
  String sourceRef = sequenceFlow.getSourceRef();
  String targetRef = sequenceFlow.getTargetRef();
  if (StringUtils.isEmpty(sourceRef)) {
   addError(errors, Problems.SEQ_FLOW_INVALID_SRC, process, sequenceFlow, "Invalid source for sequenceflow");
  if (StringUtils.isEmpty(targetRef)) {
   addError(errors, Problems.SEQ_FLOW_INVALID_TARGET, process, sequenceFlow, "Invalid target for sequenceflow");
  FlowElement source = process.getFlowElement(sourceRef, true);
  FlowElement target = process.getFlowElement(targetRef, true);
   FlowElementsContainer sourceContainer = process.getFlowElementsContainer(source.getId());
   FlowElementsContainer targetContainer = process.getFlowElementsContainer(target.getId());

代码示例来源:origin: Activiti/Activiti

if (StringUtils.isNotEmpty(mainProcess.getId())) {
  propertiesNode.put(PROPERTY_PROCESS_ID,
            mainProcess.getId());
if (StringUtils.isNotEmpty(mainProcess.getName())) {
  propertiesNode.put(PROPERTY_NAME,
            mainProcess.getName());
if (StringUtils.isNotEmpty(mainProcess.getDocumentation())) {
  propertiesNode.put(PROPERTY_DOCUMENTATION,
            mainProcess.getDocumentation());
if (!mainProcess.isExecutable()) {
  propertiesNode.put(PROPERTY_PROCESS_EXECUTABLE,
            "No");
BpmnJsonConverterUtil.convertListenersToJson(mainProcess.getExecutionListeners(),
                       true,
                       propertiesNode);
BpmnJsonConverterUtil.convertEventListenersToJson(mainProcess.getEventListeners(),
                         propertiesNode);
BpmnJsonConverterUtil.convertSignalDefinitionsToJson(model,
if (CollectionUtils.isNotEmpty(mainProcess.getDataObjects())) {
  BpmnJsonConverterUtil.convertDataPropertiesToJson(mainProcess.getDataObjects(),
                           propertiesNode);
    if (process != null) {
      Map<String, ArrayNode> laneMap = new HashMap<String, ArrayNode>();

代码示例来源:origin: Activiti/Activiti

protected FlowNode getFlowNodeFromScope(String elementId, BaseElement scope) {
 FlowNode flowNode = null;
 if (StringUtils.isNotEmpty(elementId)) {
  if (scope instanceof Process) {
   flowNode = (FlowNode) ((Process) scope).getFlowElement(elementId);
  } else if (scope instanceof SubProcess) {
   flowNode = (FlowNode) ((SubProcess) scope).getFlowElement(elementId);
  }
 }
 return flowNode;
}

代码示例来源:origin: Activiti/Activiti

if (!model.getPools().isEmpty()) {
 processId = "Collaboration";
} else {
 processId = model.getMainProcess().getId();
xtw.writeAttribute(ATTRIBUTE_ID, "BPMNPlane_" + processId);
for (String elementId : model.getLocationMap().keySet()) {
 if (model.getFlowElement(elementId) != null || model.getArtifact(elementId) != null || model.getPool(elementId) != null || model.getLane(elementId) != null) {
  if (flowElement != null && StringUtils.isNotEmpty(flowElement.getName())) {
   hasName = true;
  } else if (messageFlow != null && StringUtils.isNotEmpty(messageFlow.getName())) {
   hasName = true;

代码示例来源:origin: Activiti/Activiti

public static void writeLanes(Process process, XMLStreamWriter xtw) throws Exception {
  if (!process.getLanes().isEmpty()) {
   xtw.writeStartElement(ELEMENT_LANESET);
   xtw.writeAttribute(ATTRIBUTE_ID, "laneSet_" + process.getId());
   for (Lane lane : process.getLanes()) {
    xtw.writeStartElement(ELEMENT_LANE);
    xtw.writeAttribute(ATTRIBUTE_ID, lane.getId());

    if (StringUtils.isNotEmpty(lane.getName())) {
     xtw.writeAttribute(ATTRIBUTE_NAME, lane.getName());
    }

    boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(lane, false, xtw);
    if (didWriteExtensionStartElement) {
     xtw.writeEndElement();
    }

    for (String flowNodeRef : lane.getFlowReferences()) {
     xtw.writeStartElement(ELEMENT_FLOWNODE_REF);
     xtw.writeCharacters(flowNodeRef);
     xtw.writeEndElement();
    }

    xtw.writeEndElement();
   }
   xtw.writeEndElement();
  }
 }
}

代码示例来源:origin: Activiti/Activiti

Process process = new Process();
  process.setId(pool.getProcessRef());
  process.setName(pool.getName());
  process.setExecutable(pool.isExecutable());
                                  laneNode));
      lane.setParentProcess(process);
      process.getLanes().add(lane);
Process process = new Process();
bpmnModel.getProcesses().add(process);
process.setId(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_ID,
                               modelNode));
process.setName(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_NAME,
                                modelNode));
String namespace = BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_PROCESS_NAMESPACE,
                                 modelNode);
if (StringUtils.isNotEmpty(namespace)) {
process.setDocumentation(BpmnJsonConverterUtil.getPropertyValueAsString(PROPERTY_DOCUMENTATION,
                                    modelNode));
JsonNode processExecutableNode = JsonConverterUtil.getProperty(PROPERTY_PROCESS_EXECUTABLE,
  process.setExecutable(JsonConverterUtil.getPropertyValueAsBoolean(PROPERTY_PROCESS_EXECUTABLE,
                                   modelNode));
  List<ValuedDataObject> dataObjects = BpmnJsonConverterUtil.convertJsonToDataProperties(processDataPropertiesNode,
                                              process);
  process.setDataObjects(dataObjects);

代码示例来源:origin: Activiti/Activiti

activeProcess.addArtifact(currentArtifact);
 if (StringUtils.isNotEmpty(defaultFlow)) {
  activity.setDefaultFlow(defaultFlow);
 if (StringUtils.isNotEmpty(defaultFlow)) {
  gateway.setDefaultFlow(defaultFlow);
 subProcess.getDataObjects().add((ValuedDataObject) parsedElement);
} else {
 activeProcess.getDataObjects().add((ValuedDataObject) parsedElement);
activeProcess.addFlowElement(currentFlowElement);

代码示例来源:origin: Activiti/Activiti

AdhocSubProcess adhocSubProcess = new AdhocSubProcess();
 String orderingAttributeValue = xtr.getAttributeValue(null, ATTRIBUTE_ORDERING);
 if (StringUtils.isNotEmpty(orderingAttributeValue)) {
  adhocSubProcess.setOrdering(orderingAttributeValue);
subProcess.setNotExclusive(notExclusive);
subProcess.setForCompensation(forCompensation);
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT))) {
 subProcess.setDefaultFlow(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT));
 activeProcess.addFlowElement(subProcess);

代码示例来源:origin: Activiti/Activiti

elementNode);
  if (StringUtils.isNotEmpty(multiInstanceType) && !"none".equalsIgnoreCase(multiInstanceType)) {
  ((Process) parentElement).addFlowElement(flowElement);
} else if (parentElement instanceof SubProcess) {
  ((SubProcess) parentElement).addFlowElement(flowElement);
  Lane lane = (Lane) parentElement;
  lane.getFlowReferences().add(flowElement.getId());
  lane.getParentProcess().addFlowElement(flowElement);
  ((Process) parentElement).addArtifact(artifact);
} else if (parentElement instanceof SubProcess) {
  ((SubProcess) parentElement).addArtifact(artifact);
  Lane lane = (Lane) parentElement;
  lane.getFlowReferences().add(artifact.getId());
  lane.getParentProcess().addArtifact(artifact);

代码示例来源:origin: org.activiti/activiti-simple-workflow

/**
 * Add a sequence-flow to the current process from source to target.
 * Sequence-flow name is set to a user-friendly name, containing an
 * incrementing number.
 *
 * @param conversion
 * @param sourceActivityId
 * @param targetActivityId
 * @param condition
 */
protected SequenceFlow addSequenceFlow(WorkflowDefinitionConversion conversion, String sourceActivityId, 
  String targetActivityId, String condition) {
 
 SequenceFlow sequenceFlow = new SequenceFlow();
 sequenceFlow.setId(conversion.getUniqueNumberedId(getSequenceFlowPrefix()));
 sequenceFlow.setSourceRef(sourceActivityId);
 sequenceFlow.setTargetRef(targetActivityId);
 
 if (StringUtils.isNotEmpty(condition)) {
  sequenceFlow.setConditionExpression(condition);
 }
 conversion.getProcess().addFlowElement(sequenceFlow);
 return sequenceFlow;
}

代码示例来源:origin: Activiti/Activiti

List<ExtensionElement> localizationElements = process.getExtensionElements().get("localization");
if (localizationElements != null) {
  for (ExtensionElement localizationElement : localizationElements) {
      if (documentationElements != null) {
        for (ExtensionElement documentationElement : documentationElements) {
          documentation = StringUtils.trimToNull(documentationElement.getElementText());
          break;
      String processId = process.getId();
      if (!isEqualToCurrentLocalizationValue(locale,
                         processId,
boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(),
                                infoNode);
boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(),
                                   infoNode);
if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {

相关文章