Search in sources :

Example 1 with VariableDeclaration

use of org.camunda.bpm.engine.impl.variable.VariableDeclaration in project camunda-bpm-platform by camunda.

the class BpmnParse method parsePropertyCustomExtensions.

/**
 * Parses the custom extensions for properties.
 *
 * @param activity
 *          The activity where the property declaration is done.
 * @param propertyElement
 *          The 'property' element defining the property.
 * @param propertyName
 *          The name of the property.
 * @param propertyType
 *          The type of the property.
 */
public void parsePropertyCustomExtensions(ActivityImpl activity, Element propertyElement, String propertyName, String propertyType) {
    if (propertyType == null) {
        String type = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, TYPE);
        // default is string
        propertyType = type != null ? type : "string";
    }
    VariableDeclaration variableDeclaration = new VariableDeclaration(propertyName, propertyType);
    addVariableDeclaration(activity, variableDeclaration);
    activity.setScope(true);
    String src = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "src");
    if (src != null) {
        variableDeclaration.setSourceVariableName(src);
    }
    String srcExpr = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "srcExpr");
    if (srcExpr != null) {
        Expression sourceExpression = expressionManager.createExpression(srcExpr);
        variableDeclaration.setSourceExpression(sourceExpression);
    }
    String dst = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "dst");
    if (dst != null) {
        variableDeclaration.setDestinationVariableName(dst);
    }
    String destExpr = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "dstExpr");
    if (destExpr != null) {
        Expression destinationExpression = expressionManager.createExpression(destExpr);
        variableDeclaration.setDestinationExpression(destinationExpression);
    }
    String link = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "link");
    if (link != null) {
        variableDeclaration.setLink(link);
    }
    String linkExpr = propertyElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "linkExpr");
    if (linkExpr != null) {
        Expression linkExpression = expressionManager.createExpression(linkExpr);
        variableDeclaration.setLinkExpression(linkExpression);
    }
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseProperty(propertyElement, variableDeclaration, activity);
    }
}
Also used : VariableDeclaration(org.camunda.bpm.engine.impl.variable.VariableDeclaration)

Example 2 with VariableDeclaration

use of org.camunda.bpm.engine.impl.variable.VariableDeclaration in project camunda-bpm-platform by camunda.

the class ExecutionEntity method initialize.

// scopes ///////////////////////////////////////////////////////////////////
@Override
@SuppressWarnings("unchecked")
public void initialize() {
    LOG.initializeExecution(this);
    ScopeImpl scope = getScopeActivity();
    ensureParentInitialized();
    List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS);
    if (variableDeclarations != null) {
        for (VariableDeclaration variableDeclaration : variableDeclarations) {
            variableDeclaration.initialize(this, parent);
        }
    }
    if (isProcessInstanceExecution()) {
        String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
        if (initiatorVariableName != null) {
            String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId();
            setVariable(initiatorVariableName, authenticatedUserId);
        }
    }
    // create event subscriptions for the current scope
    for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) {
        if (!declaration.isStartEvent()) {
            declaration.createSubscriptionForExecution(this);
        }
    }
}
Also used : VariableDeclaration(org.camunda.bpm.engine.impl.variable.VariableDeclaration) List(java.util.List) ArrayList(java.util.ArrayList) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Aggregations

VariableDeclaration (org.camunda.bpm.engine.impl.variable.VariableDeclaration)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EventSubscriptionDeclaration (org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1