Java Code Examples for org.activiti.bpmn.model.Process#getId()

The following examples show how to use org.activiti.bpmn.model.Process#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BpmnModelValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
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");
  }
}
 
Example 2
Source File: CamelBehavior.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected String getProcessDefinitionKey(DelegateExecution execution) {
  Process process = ProcessDefinitionUtil.getProcess(execution.getProcessDefinitionId());
  return process.getId();
}
 
Example 3
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void createLocalizationValues(String processDefinitionId, Process process) {
  if (process == null) return;
  
  CommandContext commandContext = Context.getCommandContext();
  DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
  ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId);

  boolean localizationValuesChanged = false;
  List<ExtensionElement> localizationElements = process.getExtensionElements().get("localization");
  if (localizationElements != null) {
    for (ExtensionElement localizationElement : localizationElements) {
      if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
        String locale = localizationElement.getAttributeValue(null, "locale");
        String name = localizationElement.getAttributeValue(null, "name");
        String documentation = null;
        List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
        if (documentationElements != null) {
          for (ExtensionElement documentationElement : documentationElements) {
            documentation = StringUtils.trimToNull(documentationElement.getElementText());
            break;
          }
        }

        String processId = process.getId();
        if (isEqualToCurrentLocalizationValue(locale, processId, "name", name, infoNode) == false) {
          dynamicBpmnService.changeLocalizationName(locale, processId, name, infoNode);
          localizationValuesChanged = true;
        }
        
        if (documentation != null && isEqualToCurrentLocalizationValue(locale, processId, "description", documentation, infoNode) == false) {
          dynamicBpmnService.changeLocalizationDescription(locale, processId, documentation, infoNode);
          localizationValuesChanged = true;
        }
        
        break;
      }
    }
  }

  boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode);
  boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode);
  if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
    localizationValuesChanged = true;
  }

  if (localizationValuesChanged) {
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
  }
}
 
Example 4
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void createLocalizationValues(String processDefinitionId, Process process) {
  if (process == null) return;
  
  CommandContext commandContext = Context.getCommandContext();
  DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();
  ObjectNode infoNode = dynamicBpmnService.getProcessDefinitionInfo(processDefinitionId);

  boolean localizationValuesChanged = false;
  List<ExtensionElement> localizationElements = process.getExtensionElements().get("localization");
  if (localizationElements != null) {
    for (ExtensionElement localizationElement : localizationElements) {
      if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
        String locale = localizationElement.getAttributeValue(null, "locale");
        String name = localizationElement.getAttributeValue(null, "name");
        String documentation = null;
        List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
        if (documentationElements != null) {
          for (ExtensionElement documentationElement : documentationElements) {
            documentation = StringUtils.trimToNull(documentationElement.getElementText());
            break;
          }
        }

        String processId = process.getId();
        if (isEqualToCurrentLocalizationValue(locale, processId, "name", name, infoNode) == false) {
          dynamicBpmnService.changeLocalizationName(locale, processId, name, infoNode);
          localizationValuesChanged = true;
        }
        
        if (documentation != null && isEqualToCurrentLocalizationValue(locale, processId, "description", documentation, infoNode) == false) {
          dynamicBpmnService.changeLocalizationDescription(locale, processId, documentation, infoNode);
          localizationValuesChanged = true;
        }

        break;
      }
    }
  }

  boolean isFlowElementLocalizationChanged = localizeFlowElements(process.getFlowElements(), infoNode);
  boolean isDataObjectLocalizationChanged = localizeDataObjectElements(process.getDataObjects(), infoNode);
  if (isFlowElementLocalizationChanged || isDataObjectLocalizationChanged) {
    localizationValuesChanged = true;
  }

  if (localizationValuesChanged) {
    dynamicBpmnService.saveProcessDefinitionInfo(processDefinitionId, infoNode);
  }
}