Search in sources :

Example 26 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseFormProperties.

protected void parseFormProperties(BpmnParse bpmnParse, ExpressionManager expressionManager, Element extensionElement) {
    FormTypes formTypes = getFormTypes();
    List<Element> formPropertyElements = extensionElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, FORM_PROPERTY_ELEMENT);
    for (Element formPropertyElement : formPropertyElements) {
        FormPropertyHandler formPropertyHandler = new FormPropertyHandler();
        String id = formPropertyElement.attribute("id");
        if (id == null) {
            bpmnParse.addError("attribute 'id' is required", formPropertyElement);
        }
        formPropertyHandler.setId(id);
        String name = formPropertyElement.attribute("name");
        formPropertyHandler.setName(name);
        AbstractFormFieldType type = formTypes.parseFormPropertyType(formPropertyElement, bpmnParse);
        formPropertyHandler.setType(type);
        String requiredText = formPropertyElement.attribute("required", "false");
        Boolean required = bpmnParse.parseBooleanAttribute(requiredText);
        if (required != null) {
            formPropertyHandler.setRequired(required);
        } else {
            bpmnParse.addError("attribute 'required' must be one of {on|yes|true|enabled|active|off|no|false|disabled|inactive}", formPropertyElement);
        }
        String readableText = formPropertyElement.attribute("readable", "true");
        Boolean readable = bpmnParse.parseBooleanAttribute(readableText);
        if (readable != null) {
            formPropertyHandler.setReadable(readable);
        } else {
            bpmnParse.addError("attribute 'readable' must be one of {on|yes|true|enabled|active|off|no|false|disabled|inactive}", formPropertyElement);
        }
        String writableText = formPropertyElement.attribute("writable", "true");
        Boolean writable = bpmnParse.parseBooleanAttribute(writableText);
        if (writable != null) {
            formPropertyHandler.setWritable(writable);
        } else {
            bpmnParse.addError("attribute 'writable' must be one of {on|yes|true|enabled|active|off|no|false|disabled|inactive}", formPropertyElement);
        }
        String variableName = formPropertyElement.attribute("variable");
        formPropertyHandler.setVariableName(variableName);
        String expressionText = formPropertyElement.attribute("expression");
        if (expressionText != null) {
            Expression expression = expressionManager.createExpression(expressionText);
            formPropertyHandler.setVariableExpression(expression);
        }
        String defaultExpressionText = formPropertyElement.attribute("default");
        if (defaultExpressionText != null) {
            Expression defaultExpression = expressionManager.createExpression(defaultExpressionText);
            formPropertyHandler.setDefaultExpression(defaultExpression);
        }
        formPropertyHandlers.add(formPropertyHandler);
    }
}
Also used : FormTypes(org.camunda.bpm.engine.impl.form.type.FormTypes) Expression(org.camunda.bpm.engine.delegate.Expression) Element(org.camunda.bpm.engine.impl.util.xml.Element) AbstractFormFieldType(org.camunda.bpm.engine.impl.form.type.AbstractFormFieldType)

Example 27 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseFormData.

protected void parseFormData(BpmnParse bpmnParse, ExpressionManager expressionManager, Element extensionElement) {
    Element formData = extensionElement.elementNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "formData");
    if (formData != null) {
        this.businessKeyFieldId = formData.attribute(BUSINESS_KEY_ATTRIBUTE);
        parseFormFields(formData, bpmnParse, expressionManager);
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 28 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseValidation.

protected void parseValidation(Element formField, FormFieldHandler formFieldHandler, BpmnParse bpmnParse, ExpressionManager expressionManager) {
    Element validationElement = formField.elementNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "validation");
    if (validationElement != null) {
        List<Element> constraintElements = validationElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "constraint");
        for (Element property : constraintElements) {
            FormFieldValidator validator = Context.getProcessEngineConfiguration().getFormValidators().createValidator(property, bpmnParse, expressionManager);
            String validatorName = property.attribute("name");
            String validatorConfig = property.attribute("config");
            if (validator != null) {
                FormFieldValidationConstraintHandler handler = new FormFieldValidationConstraintHandler();
                handler.setName(validatorName);
                handler.setConfig(validatorConfig);
                handler.setValidator(validator);
                formFieldHandler.getValidationHandlers().add(handler);
            }
        }
    }
}
Also used : FormFieldValidator(org.camunda.bpm.engine.impl.form.validator.FormFieldValidator) Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 29 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseProperties.

protected void parseProperties(Element formField, FormFieldHandler formFieldHandler, BpmnParse bpmnParse, ExpressionManager expressionManager) {
    Element propertiesElement = formField.elementNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "properties");
    if (propertiesElement != null) {
        List<Element> propertyElements = propertiesElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, "property");
        // use linked hash map to preserve item ordering as provided in XML
        Map<String, String> propertyMap = new LinkedHashMap<String, String>();
        for (Element property : propertyElements) {
            String id = property.attribute("id");
            String value = property.attribute("value");
            propertyMap.put(id, value);
        }
        formFieldHandler.setProperties(propertyMap);
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class DefaultFormHandler method parseConfiguration.

public void parseConfiguration(Element activityElement, DeploymentEntity deployment, ProcessDefinitionEntity processDefinition, BpmnParse bpmnParse) {
    this.deploymentId = deployment.getId();
    ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
    Element extensionElement = activityElement.element("extensionElements");
    if (extensionElement != null) {
        // provide support for deprecated form properties
        parseFormProperties(bpmnParse, expressionManager, extensionElement);
        // provide support for new form field metadata
        parseFormData(bpmnParse, expressionManager, extensionElement);
    }
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) Element(org.camunda.bpm.engine.impl.util.xml.Element)

Aggregations

Element (org.camunda.bpm.engine.impl.util.xml.Element)60 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 BpmnParseException (org.camunda.bpm.engine.BpmnParseException)4 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)4 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)3 ProcessEngineXml (org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml)2 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)2 Condition (org.camunda.bpm.engine.impl.Condition)2 IoMapping (org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping)2 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)2 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)2 ScriptCondition (org.camunda.bpm.engine.impl.scripting.ScriptCondition)2 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)2 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)2 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)2 ScriptTaskListener (org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)2 LinkedHashMap (java.util.LinkedHashMap)1 TreeMap (java.util.TreeMap)1 ProcessArchiveXml (org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)1