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; }
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; }
protected void validateFieldDeclarationsForEmail(org.flowable.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) { boolean toDefined = false; boolean textOrHtmlDefined = false; for (FieldExtension fieldExtension : fieldExtensions) { if (fieldExtension.getFieldName().equals("to")) { toDefined = true; } if (fieldExtension.getFieldName().equals("html")) { textOrHtmlDefined = true; } if (fieldExtension.getFieldName().equals("htmlVar")) { textOrHtmlDefined = true; } if (fieldExtension.getFieldName().equals("text")) { textOrHtmlDefined = true; } if (fieldExtension.getFieldName().equals("textVar")) { textOrHtmlDefined = true; } } if (!toDefined) { addError(errors, Problems.MAIL_TASK_NO_RECIPIENT, process, task, "No recipient is defined on the mail activity"); } if (!textOrHtmlDefined) { addError(errors, Problems.MAIL_TASK_NO_CONTENT, process, task, "Text, html, textVar or htmlVar field should be provided"); } }
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 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"); } }
protected void addFieldExtensions(List<FieldExtension> extensions, ObjectNode propertiesNode) { ObjectNode fieldExtensionsNode = objectMapper.createObjectNode(); ArrayNode itemsNode = objectMapper.createArrayNode(); for (FieldExtension extension : extensions) { ObjectNode propertyItemNode = objectMapper.createObjectNode(); propertyItemNode.put(PROPERTY_SERVICETASK_FIELD_NAME, extension.getFieldName()); if (StringUtils.isNotEmpty(extension.getStringValue())) { propertyItemNode.put(PROPERTY_SERVICETASK_FIELD_STRING_VALUE, extension.getStringValue()); } if (StringUtils.isNotEmpty(extension.getExpression())) { propertyItemNode.put(PROPERTY_SERVICETASK_FIELD_EXPRESSION, extension.getExpression()); } itemsNode.add(propertyItemNode); } fieldExtensionsNode.set("fields", itemsNode); propertiesNode.set(PROPERTY_SERVICETASK_FIELDS, fieldExtensionsNode); }
if (StringUtils.isNotEmpty(fieldExtension.getFieldName())) { BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_FIELD_NAME, fieldExtension.getFieldName(), xtw);
public List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList) { List<FieldDeclaration> fieldDeclarations = new ArrayList<>(); for (FieldExtension fieldExtension : fieldList) { FieldDeclaration fieldDeclaration = null; if (StringUtils.isNotEmpty(fieldExtension.getExpression())) { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), expressionManager.createExpression(fieldExtension.getExpression())); } else { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), new FixedValue(fieldExtension.getStringValue())); } fieldDeclarations.add(fieldDeclaration); } return fieldDeclarations; }
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 List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList) { List<FieldDeclaration> fieldDeclarations = new ArrayList<>(); for (FieldExtension fieldExtension : fieldList) { FieldDeclaration fieldDeclaration = null; if (StringUtils.isNotEmpty(fieldExtension.getExpression())) { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), expressionManager.createExpression(fieldExtension.getExpression())); } else { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), new FixedValue(fieldExtension.getStringValue())); } fieldDeclarations.add(fieldDeclaration); } return fieldDeclarations; }
protected List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList, ProcessEngineConfigurationImpl processEngineConfiguration) { List<FieldDeclaration> fieldDeclarations = new ArrayList<>(); for (FieldExtension fieldExtension : fieldList) { FieldDeclaration fieldDeclaration; if (StringUtils.isNotEmpty(fieldExtension.getExpression())) { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), processEngineConfiguration.getExpressionManager().createExpression(fieldExtension.getExpression())); } else { fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), new FixedValue(fieldExtension.getStringValue())); } fieldDeclarations.add(fieldDeclaration); } return fieldDeclarations; }
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 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 List<DmnDecisionTable> getDecisionTablesFromModel(BpmnModel bpmnModel, ProcessDefinition processDefinition) { Set<String> decisionTableKeys = new HashSet<>(); List<DmnDecisionTable> decisionTables = new ArrayList<>(); List<ServiceTask> serviceTasks = bpmnModel.getMainProcess().findFlowElementsOfType(ServiceTask.class, true); for (ServiceTask serviceTask : serviceTasks) { if ("dmn".equals(serviceTask.getType())) { if (serviceTask.getFieldExtensions() != null && serviceTask.getFieldExtensions().size() > 0) { for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) { if ("decisionTableReferenceKey".equals(fieldExtension.getFieldName())) { String decisionTableReferenceKey = fieldExtension.getStringValue(); if (!decisionTableKeys.contains(decisionTableReferenceKey)) { addDecisionTableToCollection(decisionTables, decisionTableReferenceKey, processDefinition); decisionTableKeys.add(decisionTableReferenceKey); } break; } } } } } return decisionTables; }
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); } }
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 ActivityBehavior createHttpActivityBehavior(ServiceTask serviceTask) { try { Class<?> theClass = null; FieldExtension behaviorExtension = null; for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) { if ("httpActivityBehaviorClass".equals(fieldExtension.getFieldName()) && StringUtils.isNotEmpty(fieldExtension.getStringValue())) { theClass = Class.forName(fieldExtension.getStringValue()); behaviorExtension = fieldExtension; break; } } if (behaviorExtension != null) { serviceTask.getFieldExtensions().remove(behaviorExtension); } if (theClass == null) { // Default Http behavior class theClass = Class.forName("org.flowable.http.bpmn.impl.HttpActivityBehaviorImpl"); } List<FieldDeclaration> fieldDeclarations = createFieldDeclarations(serviceTask.getFieldExtensions()); addExceptionMapAsFieldDeclaration(fieldDeclarations, serviceTask.getMapExceptions()); return (ActivityBehavior) ClassDelegate.defaultInstantiateDelegate(theClass, fieldDeclarations, serviceTask); } catch (ClassNotFoundException e) { throw new FlowableException("Could not find org.flowable.http.HttpActivityBehavior: ", e); } }
public void setValues(FieldExtension otherExtension) { setFieldName(otherExtension.getFieldName()); setStringValue(otherExtension.getStringValue()); setExpression(otherExtension.getExpression()); } }
public void setValues(FieldExtension otherExtension) { setFieldName(otherExtension.getFieldName()); setStringValue(otherExtension.getStringValue()); setExpression(otherExtension.getExpression()); } }
/** * Similar to {@link #getFieldExpression(DelegateExecution, String)}, but for use within a {@link TaskListener}. */ public static Expression getFieldExpression(DelegateTask task, String fieldName) { String eventHandlerId = task.getEventHandlerId(); if (eventHandlerId != null && task.getProcessDefinitionId() != null) { org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(task.getProcessDefinitionId()); UserTask userTask = (UserTask) process.getFlowElementMap().get(task.getTaskDefinitionKey()); FlowableListener flowableListener = null; for (FlowableListener f : userTask.getTaskListeners()) { if (f.getId() != null && f.getId().equals(eventHandlerId)) { flowableListener = f; } } if (flowableListener != null) { List<FieldExtension> fieldExtensions = flowableListener.getFieldExtensions(); if (fieldExtensions != null && fieldExtensions.size() > 0) { for (FieldExtension fieldExtension : fieldExtensions) { if (fieldName.equals(fieldExtension.getFieldName())) { return createExpressionForField(fieldExtension); } } } } } return null; }