/** * Sets the identifier of the element. * * @param identifier the identifier to set * @return the builder object */ public B id(String identifier) { element.setId(identifier); return myself; }
/** * Finishes the building of a form field. * * @return the parent activity builder */ @SuppressWarnings({ "unchecked" }) public P camundaFormFieldDone() { return (P) parent.builder(); } }
protected <T extends BpmnModelElementInstance> T createSibling(Class<T> typeClass) { T instance = createInstance(typeClass); element.getParentElement().addChildElement(instance); return instance; }
private void addExecutionListener(BaseElement element, String eventName) { ExtensionElements extensionElements = element.getModelInstance().newInstance(ExtensionElements.class); ModelElementInstance executionListener = extensionElements.addExtensionElement(CAMUNDA_NS, "executionListener"); executionListener.setAttributeValueNs(CAMUNDA_NS, "class", ModelExecutionContextExecutionListener.class.getName()); executionListener.setAttributeValueNs(CAMUNDA_NS, "event", eventName); element.setExtensionElements(extensionElements); }
private static JsonObject transformElementToJsonIncludingProcessVariables(BpmnElement element) { final JsonObject obj = new JsonObject(); if (!element.getProcessVariables().isEmpty()) { // elementID obj.addProperty("elementId", element.getBaseElement().getId()); // bpmnFile obj.addProperty(BpmnConstants.VPAV_BPMN_FILE, replace(File.separator, "\\", element.getProcessdefinition())); // element Name if (element.getBaseElement().getAttributeValue("name") != null) obj.addProperty("elementName", element.getBaseElement().getAttributeValue(BpmnConstants.ATTR_NAME)); Function<ProcessVariableOperation, JsonObject> processVariableToJson = o -> { final JsonObject jsonOperation = new JsonObject(); jsonOperation.addProperty("name", o.getName()); jsonOperation.addProperty("fieldType", o.getFieldType().getDescription()); jsonOperation.addProperty("elementChapter", o.getChapter().toString()); return jsonOperation; }; obj.add("read", element.getProcessVariables().values().stream() .filter(o -> o.getOperation() == VariableOperation.READ) .map(processVariableToJson).collect(JsonArray::new, JsonArray::add, JsonArray::addAll)); obj.add("write", element.getProcessVariables().values().stream() .filter(o -> o.getOperation() == VariableOperation.WRITE) .map(processVariableToJson).collect(JsonArray::new, JsonArray::add, JsonArray::addAll)); obj.add("delete", element.getProcessVariables().values().stream() .filter(o -> o.getOperation() == VariableOperation.DELETE) .map(processVariableToJson).collect(JsonArray::new, JsonArray::add, JsonArray::addAll)); } return obj; }
@Override public String toString() { return baseElement.getId(); }
implementationAttr = bpmnScanner.getImplementation(bpmnElement.getId()); taskDelegate = bpmnScanner.getListener(bpmnElement.getId(), BpmnConstants.ATTR_DEL, BpmnConstants.CAMUNDA_TASKLISTENER); taskClass = bpmnScanner.getListener(bpmnElement.getId(), BpmnConstants.ATTR_CLASS, BpmnConstants.CAMUNDA_TASKLISTENER); taskExpression = bpmnScanner.getListener(bpmnElement.getId(), BpmnConstants.ATTR_EX, BpmnConstants.CAMUNDA_TASKLISTENER); if (bpmnElement.getElementType().getTypeName() .equals(BpmnModelConstants.BPMN_ELEMENT_INTERMEDIATE_THROW_EVENT) || bpmnElement.getElementType().getTypeName().equals(BpmnModelConstants.BPMN_ELEMENT_END_EVENT)) { final String tempImp = bpmnScanner.getEventImplementation(bpmnElement.getId()); if (tempImp != null && tempImp.contains("=")) { //$NON-NLS-1$ implementationAttr = tempImp.substring(0, tempImp.indexOf("=")).trim(); //$NON-NLS-1$ executionDelegate = bpmnScanner.getListener(bpmnElement.getId(), BpmnConstants.ATTR_DEL, BpmnConstants.CAMUNDA_EXECUTIONLISTENER); executionClass = bpmnScanner.getListener(bpmnElement.getId(), BpmnConstants.ATTR_CLASS, BpmnConstants.CAMUNDA_EXECUTIONLISTENER); executionExpression = bpmnScanner.getListener(bpmnElement.getId(), BpmnConstants.ATTR_EX, BpmnConstants.CAMUNDA_EXECUTIONLISTENER); final String classAttr = bpmnElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_CLASS); final String delegateExprAttr = bpmnElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_DEL); final String exprAttr = bpmnElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_EX);
/** * exit condition for path finding (ur anomaly) * * @param startNode * @param anomaly * @param currentPath * @param invalidPaths * @param in * @param out */ private List<Path> exitConditionUrAnomaly(final BpmnElement startNode, final AnomalyContainer anomaly, final LinkedList<BpmnElement> currentPath, final List<Path> invalidPaths, final Map<String, InOutState> in, final Map<String, InOutState> out) { // go back to the node, where the variable was deleted // or go back to the start if (anomaly.getAnomaly() == Anomaly.UR && (variableDeleted(anomaly, in, out) || ((startNode.getBaseElement().getElementType().getTypeName().equals(BpmnConstants.STARTEVENT) && startNode.getBaseElement().getParentElement().getElementType().getTypeName() .equals(BpmnConstants.PROCESS))))) { final List<BpmnElement> newPath = new ArrayList<BpmnElement>(currentPath); invalidPaths.add(new Path(newPath)); currentPath.remove(startNode); return invalidPaths; } return null; }
private void enableSetVariable(BaseElement element) { CamundaExecutionListener executionListener = element.getModelInstance().newInstance(CamundaExecutionListener.class); executionListener.setCamundaEvent("end"); executionListener.setCamundaClass(VariableSetterDelegate.class.getName()); // extension elements should exist because we have camunda:properties element.getExtensionElements().addChildElement(executionListener); }
@Override public Collection<CheckerIssue> check(BpmnElement element) { final Collection<CheckerIssue> issues = new ArrayList<CheckerIssue>(); final BaseElement bpmnElement = element.getBaseElement(); final Map<String, Setting> settings = rule.getSettings(); final ArrayList<String> whiteList = rule.getWhiteList(); final Map<String, String> keyPairs = new HashMap<String, String>(); final ArrayList<Setting> optionalSettings = new ArrayList<Setting>(); final ArrayList<Setting> mandatorySettings = new ArrayList<Setting>(); // Retrieve extension key pair from bpmn model keyPairs.putAll(bpmnScanner.getKeyPairs(bpmnElement.getId())); // Create ArrayList for easier manipulation for (Map.Entry<String, Setting> settingsEntry : settings.entrySet()) { if (settingsEntry.getValue().getRequired()) { mandatorySettings.add(settingsEntry.getValue()); } else { optionalSettings.add(settingsEntry.getValue()); } } if (whiteList.contains(bpmnElement.getElementType().getInstanceType().getSimpleName())) { // Check for all mandatory extension pairs according to ruleset issues.addAll(checkManExtension(whiteList, mandatorySettings, keyPairs, bpmnElement, element)); // Check for all optional extension pairs issues.addAll(checkOptExtension(whiteList, optionalSettings, keyPairs, bpmnElement, element)); } checkMisconfiguration(); return issues; }
public static Optional<String> readCamundaProperty(BaseElement modelElementInstance, String propertyName) { if (modelElementInstance.getExtensionElements() == null) { return Optional.empty(); } return queryCamundaPropertyValues(modelElementInstance, propertyName).findFirst(); }
BpmnModelElementInstance scopeElement = baseElement.getScope(); final String t_expression = baseElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_EX); if (t_expression != null) { final String t_delegateExpression = baseElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_DEL); if (t_delegateExpression != null) { .getFieldInjectionExpression(baseElement.getId()); if (t_fieldInjectionExpressions != null && !t_fieldInjectionExpressions.isEmpty()) { for (String t_fieldInjectionExpression : t_fieldInjectionExpressions) final String t_resultVariable = baseElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.RESULT_VARIABLE); if (t_resultVariable != null && t_resultVariable.trim().length() > 0) { if (baseElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_CLASS) != null) { processVariables.putAll(context.readJavaDelegate(fileScanner, baseElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.ATTR_CLASS), element, ElementChapter.Details, KnownElementFieldType.Class, scopeId)); final String t_decisionRef = baseElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnConstants.DECISIONREF); if (t_decisionRef != null && t_decisionRef.trim().length() > 0 && decisionRefToPathMap != null) {
if (bpmnElement instanceof BusinessRuleTask) { final String implementationAttr = bpmnScanner.getImplementation(bpmnElement.getId()); final String dmnAttr = bpmnElement.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, BpmnModelConstants.CAMUNDA_ATTRIBUTE_DECISION_REF); if (implementationAttr != null) {
final LinkedHashMap<String, ProcessVariableOperation> processVariables = new LinkedHashMap<String, ProcessVariableOperation>(); final BaseElement baseElement = element.getBaseElement(); final BpmnModelElementInstance scopeElement = baseElement.getScope(); ArrayList<String> outVar = bpmnScanner.getOutputVariables(element.getBaseElement().getId()); ArrayList<String> inVar = bpmnScanner.getInputVariables(element.getBaseElement().getId()); ArrayList<String> varValues = bpmnScanner.getInOutputVariablesValue(element.getBaseElement().getId());
final BpmnModelElementInstance scopeElement = baseElement.getScope(); String scopeElementId = null; if (scopeElement != null) { scopeElementId = scopeElement.getAttributeValue(BpmnConstants.ATTR_ID); final ExtensionElements extensionElements = baseElement.getExtensionElements(); if (extensionElements != null) {
private void addServiceTaskCompensationHandler(BpmnModelInstance modelInstance, String boundaryEventId, String compensationHandlerId) { BoundaryEvent boundaryEvent = modelInstance.getModelElementById(boundaryEventId); BaseElement scope = (BaseElement) boundaryEvent.getParentElement(); ServiceTask compensationHandler = modelInstance.newInstance(ServiceTask.class); compensationHandler.setId(compensationHandlerId); compensationHandler.setForCompensation(true); compensationHandler.setCamundaClass(IncreaseCurrentTimeServiceTask.class.getName()); scope.addChildElement(compensationHandler); Association association = modelInstance.newInstance(Association.class); association.setAssociationDirection(AssociationDirection.One); association.setSource(boundaryEvent); association.setTarget(compensationHandler); scope.addChildElement(association); }
/** * Transforms a process variable to a json object * * @param processVariable * @return */ private static JsonObject transformProcessVariablesToJson(final ProcessVariable processVariable) { final JsonObject obj = new JsonObject(); obj.addProperty("name", processVariable.getName()); if (processVariable.getOperations().size() > 0) { String bpmnFile = processVariable.getOperations().get(0).getElement().getProcessdefinition(); obj.addProperty(BpmnConstants.VPAV_BPMN_FILE, replace(File.separator, "\\", bpmnFile)); } Function<ProcessVariableOperation, JsonObject> processVariableToJson = o -> { final JsonObject jsonOperation = new JsonObject(); jsonOperation.addProperty("elementId", o.getElement().getBaseElement().getId()); jsonOperation.addProperty("elementName", o.getElement().getBaseElement().getAttributeValue("name")); jsonOperation.addProperty("fieldType", o.getFieldType().getDescription()); jsonOperation.addProperty("elementChapter", o.getChapter().toString()); return jsonOperation; }; obj.add("read", processVariable.getReads().stream().map(processVariableToJson).collect(JsonArray::new, JsonArray::add, JsonArray::addAll)); obj.add("write", processVariable.getWrites().stream().map(processVariableToJson).collect(JsonArray::new, JsonArray::add, JsonArray::addAll)); obj.add("delete", processVariable.getDeletes().stream().map(processVariableToJson).collect(JsonArray::new, JsonArray::add, JsonArray::addAll)); return obj; }
@Override public int hashCode() { return baseElement.getId().hashCode(); }
final boolean isGateway = startNode.getBaseElement().getElementType().getBaseType() .getTypeName().equals(BpmnModelConstants.BPMN_ELEMENT_GATEWAY); final boolean isNodeParallelGateway = startNode.getBaseElement().getElementType().getTypeName() .equals(BpmnModelConstants.BPMN_ELEMENT_PARALLEL_GATEWAY); final boolean isEndEvent = startNode.getBaseElement().getElementType().getTypeName() .equals(BpmnConstants.ENDEVENT) && startNode.getBaseElement().getParentElement().getElementType().getTypeName() .equals(BpmnConstants.PROCESS);