Java Code Examples for org.camunda.bpm.engine.impl.util.xml.Element#attribute()
The following examples show how to use
org.camunda.bpm.engine.impl.util.xml.Element#attribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomBpmnParse.java From wecube-platform with Apache License 2.0 | 6 votes |
protected void parseErrorEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement, ActivityImpl activity, Element errorEventDefinition) { String errorRef = errorEventDefinition.attribute("errorRef"); if (errorRef == null || "".equals(errorRef)) { errorRef = DEFAULT_ERROR_ID; } org.camunda.bpm.engine.impl.bpmn.parser.Error error = errors.get(errorRef); if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) { error.setErrorCode(DEFAULT_ERROR_CODE); } if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) { addError( "'errorCode' is mandatory on errors referenced by throwing error event definitions, but the error '" + error.getId() + "' does not define one.", errorEventDefinition); } activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_ERROR); if (error != null) { activity.setActivityBehavior(new ErrorEndEventActivityBehavior(error.getErrorCode())); } else { activity.setActivityBehavior(new ErrorEndEventActivityBehavior(errorRef)); } }
Example 2
Source File: CustomBpmnParse.java From wecube-platform with Apache License 2.0 | 6 votes |
protected Condition parseConditionExpression(Element conditionExprElement) { String expression = translateConditionExpressionElementText(conditionExprElement); String type = conditionExprElement.attributeNS(XSI_NS, TYPE); String language = conditionExprElement.attribute(PROPERTYNAME_LANGUAGE); String resource = conditionExprElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_RESOURCE); if (type != null) { String value = type.contains(":") ? resolveName(type) : BpmnParser.BPMN20_NS + ":" + type; if (!value.equals(ATTRIBUTEVALUE_T_FORMAL_EXPRESSION)) { addError("Invalid type, only tFormalExpression is currently supported", conditionExprElement); } } Condition condition = null; if (language == null) { condition = new UelExpressionCondition(expressionManager.createExpression(expression)); } else { try { ExecutableScript script = ScriptUtil.getScript(language, expression, resource, expressionManager); condition = new ScriptCondition(script); } catch (ProcessEngineException e) { addError("Unable to process condition expression:" + e.getMessage(), conditionExprElement); } } return condition; }
Example 3
Source File: BpmnParseUtil.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
/** * Parses a camunda script element. * * @param scriptElement the script element ot parse * @return the generated executable script * @throws BpmnParseException if the a attribute is missing or the script cannot be processed */ public static ExecutableScript parseCamundaScript(Element scriptElement) { String scriptLanguage = scriptElement.attribute("scriptFormat"); if (scriptLanguage == null || scriptLanguage.isEmpty()) { throw new BpmnParseException("Missing attribute 'scriptFormat' for 'script' element", scriptElement); } else { String scriptResource = scriptElement.attribute("resource"); String scriptSource = scriptElement.getText(); try { return ScriptUtil.getScript(scriptLanguage, scriptSource, scriptResource, getExpressionManager()); } catch (ProcessEngineException e) { throw new BpmnParseException("Unable to process script", scriptElement, e); } } }
Example 4
Source File: DefaultFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); } }
Example 5
Source File: DefaultFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); } } } }
Example 6
Source File: TestBPMNParseListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) { // Change activity behavior Element compensateEventDefinitionElement = intermediateEventElement.element(COMPENSATE_EVENT_DEFINITION); if (compensateEventDefinitionElement != null) { final String activityRef = compensateEventDefinitionElement.attribute("activityRef"); CompensateEventDefinition compensateEventDefinition = new CompensateEventDefinition(); compensateEventDefinition.setActivityRef(activityRef); compensateEventDefinition.setWaitForCompletion(false); activity.setActivityBehavior(new TestCompensationEventActivityBehavior(compensateEventDefinition)); } }
Example 7
Source File: CustomBpmnParse.java From wecube-platform with Apache License 2.0 | 5 votes |
@Override protected EventSubscriptionDeclaration parseSignalEventDefinition(Element signalEventDefinitionElement, boolean isThrowing) { logger.debug("parse signal event definition"); String signalRef = signalEventDefinitionElement.attribute("signalRef"); if (signalRef == null) { logger.debug("add default signal {}:{}", DEFAULT_SIGNAL_ID, DEFAULT_SIGNAL_NAME); signalRef = DEFAULT_SIGNAL_ID; } SignalDefinition signalDefinition = signals.get(resolveName(signalRef)); if (signalDefinition == null) { addError("Could not find signal with id '" + signalRef + "'", signalEventDefinitionElement); } EventSubscriptionDeclaration signalEventDefinition; if (isThrowing) { CallableElement payload = new CallableElement(); parseInputParameter(signalEventDefinitionElement, payload); signalEventDefinition = new EventSubscriptionDeclaration(signalDefinition != null ? signalDefinition.getExpression() : null, EventType.SIGNAL, payload); } else { signalEventDefinition = new EventSubscriptionDeclaration(signalDefinition != null ? signalDefinition.getExpression() : null, EventType.SIGNAL); } boolean throwingAsync = TRUE .equals(signalEventDefinitionElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "async", "false")); signalEventDefinition.setAsync(throwingAsync); return signalEventDefinition; }
Example 8
Source File: BpmnParseUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Parses a output parameter and adds it to the {@link IoMapping}. * * @param outputParameterElement the output parameter element * @param ioMapping the mapping to add the element * @throws BpmnParseException if the output parameter element is malformed */ public static void parseOutputParameterElement(Element outputParameterElement, IoMapping ioMapping) { String nameAttribute = outputParameterElement.attribute("name"); if(nameAttribute == null || nameAttribute.isEmpty()) { throw new BpmnParseException("Missing attribute 'name' for outputParameter", outputParameterElement); } ParameterValueProvider valueProvider = parseNestedParamValueProvider(outputParameterElement); // add parameter ioMapping.addOutputParameter(new OutputParameter(nameAttribute, valueProvider)); }
Example 9
Source File: BpmnParseUtil.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * Parses a input parameter and adds it to the {@link IoMapping}. * * @param inputParameterElement the input parameter element * @param ioMapping the mapping to add the element * @throws BpmnParseException if the input parameter element is malformed */ public static void parseInputParameterElement(Element inputParameterElement, IoMapping ioMapping) { String nameAttribute = inputParameterElement.attribute("name"); if(nameAttribute == null || nameAttribute.isEmpty()) { throw new BpmnParseException("Missing attribute 'name' for inputParameter", inputParameterElement); } ParameterValueProvider valueProvider = parseNestedParamValueProvider(inputParameterElement); // add parameter ioMapping.addInputParameter(new InputParameter(nameAttribute, valueProvider)); }
Example 10
Source File: ProblemImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void extractElementDetails(Element element) { if (element != null) { this.line = element.getLine(); this.column = element.getColumn(); String id = element.attribute("id"); if (id != null && id.length() > 0) { this.mainElementId = id; this.elementIds.add(id); } } }
Example 11
Source File: FormTypes.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public AbstractFormFieldType parseFormPropertyType(Element formFieldElement, BpmnParse bpmnParse) { AbstractFormFieldType formType = null; String typeText = formFieldElement.attribute("type"); String datePatternText = formFieldElement.attribute("datePattern"); if (typeText == null && DefaultFormHandler.FORM_FIELD_ELEMENT.equals(formFieldElement.getTagName())) { bpmnParse.addError("form field must have a 'type' attribute", formFieldElement); } if ("date".equals(typeText) && datePatternText!=null) { formType = new DateFormType(datePatternText); } else if ("enum".equals(typeText)) { // ACT-1023: Using linked hashmap to preserve the order in which the entries are defined Map<String, String> values = new LinkedHashMap<String, String>(); for (Element valueElement: formFieldElement.elementsNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS,"value")) { String valueId = valueElement.attribute("id"); String valueName = valueElement.attribute("name"); values.put(valueId, valueName); } formType = new EnumFormType(values); } else if (typeText!=null) { formType = formTypes.get(typeText); if (formType==null) { bpmnParse.addError("unknown type '"+typeText+"'", formFieldElement); } } return formType; }
Example 12
Source File: DefaultFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); } }
Example 13
Source File: DefaultFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
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); } }
Example 14
Source File: DefaultFormHandler.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected void parseFormField(Element formField, BpmnParse bpmnParse, ExpressionManager expressionManager) { FormFieldHandler formFieldHandler = new FormFieldHandler(); // parse Id String id = formField.attribute("id"); if(id == null || id.isEmpty()) { bpmnParse.addError("attribute id must be set for FormFieldGroup and must have a non-empty value", formField); } else { formFieldHandler.setId(id); } if (id.equals(businessKeyFieldId)) { formFieldHandler.setBusinessKey(true); } // parse name String name = formField.attribute("label"); if (name != null) { Expression nameExpression = expressionManager.createExpression(name); formFieldHandler.setLabel(nameExpression); } // parse properties parseProperties(formField, formFieldHandler, bpmnParse, expressionManager); // parse validation parseValidation(formField, formFieldHandler, bpmnParse, expressionManager); // parse type FormTypes formTypes = getFormTypes(); AbstractFormFieldType formType = formTypes.parseFormPropertyType(formField, bpmnParse); formFieldHandler.setType(formType); // parse default value String defaultValue = formField.attribute("defaultValue"); if(defaultValue != null) { Expression defaultValueExpression = expressionManager.createExpression(defaultValue); formFieldHandler.setDefaultValueExpression(defaultValueExpression); } formFieldHandlers.add(formFieldHandler); }
Example 15
Source File: BpmnParseUtil.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * @throws BpmnParseException if the parameter is invalid */ protected static ParameterValueProvider parseParamValueProvider(Element parameterElement) { // LIST if("list".equals(parameterElement.getTagName())) { List<ParameterValueProvider> providerList = new ArrayList<ParameterValueProvider>(); for (Element element : parameterElement.elements()) { // parse nested provider providerList.add(parseParamValueProvider(element)); } return new ListValueProvider(providerList); } // MAP if("map".equals(parameterElement.getTagName())) { TreeMap<ParameterValueProvider, ParameterValueProvider> providerMap = new TreeMap<ParameterValueProvider, ParameterValueProvider>(); for (Element entryElement : parameterElement.elements("entry")) { // entry must provide key String keyAttribute = entryElement.attribute("key"); if(keyAttribute == null || keyAttribute.isEmpty()) { throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement); } // parse nested provider providerMap.put(new ElValueProvider(getExpressionManager().createExpression(keyAttribute)), parseNestedParamValueProvider(entryElement)); } return new MapValueProvider(providerMap); } // SCRIPT if("script".equals(parameterElement.getTagName())) { ExecutableScript executableScript = parseCamundaScript(parameterElement); if (executableScript != null) { return new ScriptValueProvider(executableScript); } else { return new NullValueProvider(); } } String textContent = parameterElement.getText().trim(); if(!textContent.isEmpty()) { // EL return new ElValueProvider(getExpressionManager().createExpression(textContent)); } else { // NULL value return new NullValueProvider(); } }
Example 16
Source File: DeploymentMetadataParse.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * parse a <code><process-engine .../></code> element and add it to the list of parsed elements */ protected void parseProcessEngine(Element element, List<ProcessEngineXml> parsedProcessEngines) { ProcessEngineXmlImpl processEngine = new ProcessEngineXmlImpl(); // set name processEngine.setName(element.attribute(NAME)); // set default String defaultValue = element.attribute(DEFAULT); if(defaultValue == null || defaultValue.isEmpty()) { processEngine.setDefault(false); } else { processEngine.setDefault(Boolean.parseBoolean(defaultValue)); } Map<String, String> properties = new HashMap<String, String>(); List<ProcessEnginePluginXml> plugins = new ArrayList<ProcessEnginePluginXml>(); for (Element childElement : element.elements()) { if(CONFIGURATION.equals(childElement.getTagName())) { processEngine.setConfigurationClass(childElement.getText()); } else if(DATASOURCE.equals(childElement.getTagName())) { processEngine.setDatasource(childElement.getText()); } else if(JOB_ACQUISITION.equals(childElement.getTagName())) { processEngine.setJobAcquisitionName(childElement.getText()); } else if(PROPERTIES.equals(childElement.getTagName())) { parseProperties(childElement, properties); } else if(PLUGINS.equals(childElement.getTagName())) { parseProcessEnginePlugins(childElement, plugins); } } // set collected properties processEngine.setProperties(properties); // set plugins processEngine.setPlugins(plugins); // add the process engine to the list of parsed engines. parsedProcessEngines.add(processEngine); }
Example 17
Source File: FormValidators.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * factory method for creating validator instances * */ public FormFieldValidator createValidator(Element constraint, BpmnParse bpmnParse, ExpressionManager expressionManager) { String name = constraint.attribute("name"); String config = constraint.attribute("config"); if("validator".equals(name)) { // custom validators if(config == null || config.isEmpty()) { bpmnParse.addError("validator configuration needs to provide either a fully " + "qualified classname or an expression resolving to a custom FormFieldValidator implementation.", constraint); } else { if(StringUtil.isExpression(config)) { // expression Expression validatorExpression = expressionManager.createExpression(config); return new DelegateFormFieldValidator(validatorExpression); } else { // classname return new DelegateFormFieldValidator(config); } } } else { // built-in validators Class<? extends FormFieldValidator> validator = validators.get(name); if(validator != null) { FormFieldValidator validatorInstance = createValidatorInstance(validator); return validatorInstance; } else { bpmnParse.addError("Cannot find validator implementation for name '"+name+"'.", constraint); } } return null; }