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);
}
}
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);
}
}
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);
}
}
}
}
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);
}
}
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);
}
}
Aggregations