Refine search
protected void setPropertyFieldValue(String propertyName, String fieldName, ServiceTask task, ObjectNode propertiesNode) { for (FieldExtension extension : task.getFieldExtensions()) { if (fieldName.equalsIgnoreCase(extension.getFieldName())) { if (StringUtils.isNotEmpty(extension.getStringValue())) { setPropertyValue(propertyName, extension.getStringValue(), propertiesNode); } else if (StringUtils.isNotEmpty(extension.getExpression())) { setPropertyValue(propertyName, extension.getExpression(), propertiesNode); } } } }
protected void addField(String name, JsonNode elementNode, ServiceTask task) { FieldExtension field = new FieldExtension(); field.setFieldName(name.substring(8)); String value = getPropertyValueAsString(name, elementNode); if (StringUtils.isNotEmpty(value)) { if ((value.contains("${") || value.contains("#{")) && value.contains("}")) { field.setExpression(value); } else { field.setStringValue(value); } task.getFieldExtensions().add(field); } }
public void setValues(FieldExtension otherExtension) { setFieldName(otherExtension.getFieldName()); setStringValue(otherExtension.getStringValue()); setExpression(otherExtension.getExpression()); } }
@Override public FieldExtension clone() { FieldExtension clone = new FieldExtension(); clone.setValues(this); return clone; }
listenerNode = validateIfNodeIsTextual(listenerNode); JsonNode eventNode = listenerNode.get(PROPERTY_LISTENER_EVENT); if (eventNode != null && !eventNode.isNull() && StringUtils.isNotEmpty(eventNode.asText())) { if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode))) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS); listener.setImplementation(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode)); } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode))) { listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION); listener.setImplementation(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode)); JsonNode nameNode = fieldNode.get(PROPERTY_FIELD_NAME); if (nameNode != null && !nameNode.isNull() && StringUtils.isNotEmpty(nameNode.asText())) { FieldExtension fieldExtension = new FieldExtension(); fieldExtension.setFieldName(nameNode.asText()); fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING_VALUE, fieldNode)); if (StringUtils.isEmpty(fieldExtension.getStringValue())) { fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING, fieldNode)); if (StringUtils.isEmpty(fieldExtension.getStringValue())) { fieldExtension.setExpression(getValueAsString(PROPERTY_FIELD_EXPRESSION, fieldNode));
protected ActivityBehavior createCamelActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, BpmnModel bpmnModel) { try { Class<?> theClass = null; FieldExtension behaviorExtension = null; for (FieldExtension fieldExtension : fieldExtensions) { if ("camelBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) { theClass = Class.forName(fieldExtension.getStringValue()); behaviorExtension = fieldExtension; break; } } if (behaviorExtension != null) { fieldExtensions.remove(behaviorExtension); } if (theClass == null) { // Default Camel behavior class theClass = Class.forName("org.flowable.camel.impl.CamelBehaviorDefaultImpl"); } List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions); addExceptionMapAsFieldDeclaration(fieldDeclarations, task.getMapExceptions()); return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations); } catch (ClassNotFoundException e) { throw new ActivitiException("Could not find org.flowable.camel.impl.CamelBehaviorDefaultImpl: ", e); } }
/** * Creates an {@link Expression} for the {@link FieldExtension}. */ public static Expression createExpressionForField(FieldExtension fieldExtension) { if (StringUtils.isNotEmpty(fieldExtension.getExpression())) { ExpressionManager expressionManager = CommandContextUtil.getProcessEngineConfiguration().getExpressionManager(); return expressionManager.createExpression(fieldExtension.getExpression()); } else { return new FixedValue(fieldExtension.getStringValue()); } }
protected void applyFallbackToDefaultTenant(DelegateExecution execution, ExecuteDecisionBuilder executeDecisionBuilder) { FieldExtension fallbackfieldExtension = DelegateHelper.getFlowElementField(execution, EXPRESSION_DECISION_TABLE_FALLBACK_TO_DEFAULT_TENANT); if (fallbackfieldExtension != null && ((fallbackfieldExtension.getStringValue() != null && fallbackfieldExtension.getStringValue().length() != 0))) { String fallbackToDefaultTenant = fallbackfieldExtension.getStringValue(); if (StringUtils.isNotEmpty(fallbackToDefaultTenant) && Boolean.parseBoolean(fallbackToDefaultTenant)) { executeDecisionBuilder.fallbackToDefaultTenant(); } } }
protected void validateFieldDeclarationsForDmn(org.flowable.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) { boolean keyDefined = false; for (FieldExtension fieldExtension : fieldExtensions) { String fieldName = fieldExtension.getFieldName(); String fieldValue = fieldExtension.getStringValue(); if (fieldName.equals("decisionTableReferenceKey") && fieldValue != null && fieldValue.length() > 0) { keyDefined = true; } } if (!keyDefined) { addError(errors, Problems.DMN_TASK_NO_KEY, process, task, "No decision table reference key is defined on the dmn activity"); } }
protected void validateFieldDeclarationsForHttp(org.flowable.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) { boolean requestMethodDefined = false; boolean requestUrlDefined = false; for (FieldExtension fieldExtension : fieldExtensions) { String fieldName = fieldExtension.getFieldName(); String fieldValue = fieldExtension.getStringValue(); String fieldExpression = fieldExtension.getExpression(); if (fieldName.equals("requestMethod") && ((fieldValue != null && fieldValue.length() > 0) || (fieldExpression != null && fieldExpression.length() > 0))) { requestMethodDefined = true; } if (fieldName.equals("requestUrl") && ((fieldValue != null && fieldValue.length() > 0) || (fieldExpression != null && fieldExpression.length() > 0))) { requestUrlDefined = true; } } if (!requestMethodDefined) { addError(errors, Problems.HTTP_TASK_NO_REQUEST_METHOD, process, task, "No request method is defined on the http activity"); } if (!requestUrlDefined) { addError(errors, Problems.HTTP_TASK_NO_REQUEST_URL, process, task, "No request url is defined on the http activity"); } }
public static FieldExtension getListenerField(DelegateExecution execution, String fieldName) { List<FieldExtension> fieldExtensions = getListenerFields(execution); if (fieldExtensions == null || fieldExtensions.size() == 0) { return null; } for (FieldExtension fieldExtension : fieldExtensions) { if (fieldExtension.getFieldName() != null && fieldExtension.getFieldName().equals(fieldName)) { return fieldExtension; } } return null; }
@Override protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) { ServiceTask serviceTask = new ServiceTask(); serviceTask.setType(ServiceTask.DMN_TASK); JsonNode decisionTableReferenceNode = getProperty(PROPERTY_DECISIONTABLE_REFERENCE, elementNode); if (decisionTableReferenceNode != null && decisionTableReferenceNode.has("id") && !decisionTableReferenceNode.get("id").isNull()) { String decisionTableId = decisionTableReferenceNode.get("id").asText(); if (decisionTableMap != null) { String decisionTableKey = decisionTableMap.get(decisionTableId); FieldExtension decisionTableKeyField = new FieldExtension(); decisionTableKeyField.setFieldName(PROPERTY_DECISIONTABLE_REFERENCE_KEY); decisionTableKeyField.setStringValue(decisionTableKey); serviceTask.getFieldExtensions().add(decisionTableKeyField); } } boolean decisionTableThrowErrorOnNoHitsNode = getPropertyValueAsBoolean(PROPERTY_DECISIONTABLE_THROW_ERROR_NO_HITS, elementNode); FieldExtension decisionTableThrowErrorOnNoHitsField = new FieldExtension(); decisionTableThrowErrorOnNoHitsField.setFieldName(PROPERTY_DECISIONTABLE_THROW_ERROR_NO_HITS_KEY); decisionTableThrowErrorOnNoHitsField.setStringValue(decisionTableThrowErrorOnNoHitsNode ? "true" : "false"); serviceTask.getFieldExtensions().add(decisionTableThrowErrorOnNoHitsField); boolean fallbackToDefaultTenant = getPropertyValueAsBoolean(PROPERTY_DECISIONTABLE_FALLBACK_TO_DEFAULT_TENANT, elementNode); FieldExtension fallbackToDefaultTenantField = new FieldExtension(); fallbackToDefaultTenantField.setFieldName(PROPERTY_DECISIONTABLE_FALLBACK_TO_DEFAULT_TENANT_KEY); fallbackToDefaultTenantField.setStringValue(fallbackToDefaultTenant ? "true" : "false"); serviceTask.getFieldExtensions().add(fallbackToDefaultTenantField); return serviceTask; }
protected ActivityBehavior createCamelActivityBehavior(TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions) { try { Class<?> theClass = null; FieldExtension behaviorExtension = null; for (FieldExtension fieldExtension : fieldExtensions) { if ("camelBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) { theClass = Class.forName(fieldExtension.getStringValue()); behaviorExtension = fieldExtension; break; } } if (behaviorExtension != null) { fieldExtensions.remove(behaviorExtension); } if (theClass == null) { // Default Camel behavior class theClass = Class.forName(getDefaultCamelBehaviorClassName()); } List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(fieldExtensions); addExceptionMapAsFieldDeclaration(fieldDeclarations, task.getMapExceptions()); return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate( theClass, fieldDeclarations); } catch (ClassNotFoundException e) { throw new FlowableException("Could not find org.flowable.camel.CamelBehavior: ", e); } }
@Override public void execute(DelegateExecution execution) { FieldExtension fieldExtension = DelegateHelper.getFlowElementField(execution, EXPRESSION_DECISION_TABLE_REFERENCE_KEY); if (fieldExtension == null || ((fieldExtension.getStringValue() == null || fieldExtension.getStringValue().length() == 0) && (fieldExtension.getExpression() == null || fieldExtension.getExpression().length() == 0))) { if (fieldExtension.getExpression() != null && fieldExtension.getExpression().length() > 0) { activeDecisionTableKey = fieldExtension.getExpression(); activeDecisionTableKey = fieldExtension.getStringValue(); if (throwErrorFieldExtension != null) { String throwErrorString = null; if (StringUtils.isNotEmpty(throwErrorFieldExtension.getStringValue())) { throwErrorString = throwErrorFieldExtension.getStringValue(); } else if (StringUtils.isNotEmpty(throwErrorFieldExtension.getExpression())) { throwErrorString = throwErrorFieldExtension.getExpression();
public void setValues(FieldExtension otherExtension) { setFieldName(otherExtension.getFieldName()); setStringValue(otherExtension.getStringValue()); setExpression(otherExtension.getExpression()); } }
protected void validateFieldDeclarationsForShell(org.flowable.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) { boolean shellCommandDefined = false; for (FieldExtension fieldExtension : fieldExtensions) { String fieldName = fieldExtension.getFieldName(); String fieldValue = fieldExtension.getStringValue(); if (fieldName.equals("command")) { shellCommandDefined = true; } if ((fieldName.equals("wait") || fieldName.equals("redirectError") || fieldName.equals("cleanEnv")) && !fieldValue.toLowerCase().equals("true") && !fieldValue.toLowerCase().equals("false")) { addError(errors, Problems.SHELL_TASK_INVALID_PARAM, process, task, "Undefined parameter value for shell field"); } } if (!shellCommandDefined) { addError(errors, Problems.SHELL_TASK_NO_COMMAND, process, task, "No shell command is defined on the shell activity"); } }
public static FieldExtension getFlowElementField(DelegateExecution execution, String fieldName) { List<FieldExtension> fieldExtensions = getFlowElementFields(execution); if (fieldExtensions == null || fieldExtensions.size() == 0) { return null; } for (FieldExtension fieldExtension : fieldExtensions) { if (fieldExtension.getFieldName() != null && fieldExtension.getFieldName().equals(fieldName)) { return fieldExtension; } } return null; }
@Override public FieldExtension clone() { FieldExtension clone = new FieldExtension(); clone.setValues(this); return clone; }
protected void setPropertyFieldValue(String name, ServiceTask task, ObjectNode propertiesNode) { for (FieldExtension extension : task.getFieldExtensions()) { if (name.substring(8).equalsIgnoreCase(extension.getFieldName())) { if (StringUtils.isNotEmpty(extension.getStringValue())) { setPropertyValue(name, extension.getStringValue(), propertiesNode); } else if (StringUtils.isNotEmpty(extension.getExpression())) { setPropertyValue(name, extension.getExpression(), propertiesNode); } } } }
protected void addField(String name, String propertyName, String defaultValue, JsonNode elementNode, ServiceTask task) { FieldExtension field = new FieldExtension(); field.setFieldName(name); String value = getPropertyValueAsString(propertyName, elementNode); if (StringUtils.isNotEmpty(value)) { if ((value.contains("${") || value.contains("#{")) && value.contains("}")) { field.setExpression(value); } else { field.setStringValue(value); } task.getFieldExtensions().add(field); } else if (StringUtils.isNotEmpty(defaultValue)) { field.setStringValue(defaultValue); task.getFieldExtensions().add(field); } }