use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class GetFormKeyCmd method execute.
public String execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadProcessDefinition(processDefinition);
}
Expression formKeyExpression = null;
if (taskDefinitionKey == null) {
// TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
FormHandler formHandler = processDefinition.getStartFormHandler();
if (formHandler instanceof DelegateStartFormHandler) {
DelegateStartFormHandler delegateFormHandler = (DelegateStartFormHandler) formHandler;
formHandler = delegateFormHandler.getFormHandler();
}
// form handler (for a startForm) has always to extend the DefaultStartFormHandler!
if (formHandler instanceof DefaultStartFormHandler) {
DefaultStartFormHandler startFormHandler = (DefaultStartFormHandler) formHandler;
formKeyExpression = startFormHandler.getFormKey();
}
} else {
TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
formKeyExpression = taskDefinition.getFormKey();
}
String formKey = null;
if (formKeyExpression != null) {
formKey = formKeyExpression.getExpressionText();
}
return formKey;
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class SentryHandler method initializeIfPart.
protected void initializeIfPart(IfPart ifPart, CmmnSentryDeclaration sentryDeclaration, CmmnHandlerContext context) {
if (ifPart == null) {
return;
}
Collection<ConditionExpression> conditions = ifPart.getConditions();
if (conditions.size() > 1) {
String id = sentryDeclaration.getId();
LOG.multipleIgnoredConditions(id);
}
ExpressionManager expressionManager = context.getExpressionManager();
ConditionExpression condition = conditions.iterator().next();
Expression conditionExpression = expressionManager.createExpression(condition.getText());
CmmnIfPartDeclaration ifPartDeclaration = new CmmnIfPartDeclaration();
ifPartDeclaration.setCondition(conditionExpression);
sentryDeclaration.setIfPart(ifPartDeclaration);
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class TaskDecorator method initializeTaskCandidateGroups.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void initializeTaskCandidateGroups(TaskEntity task, VariableScope variableScope) {
Set<Expression> candidateGroupIdExpressions = taskDefinition.getCandidateGroupIdExpressions();
for (Expression groupIdExpr : candidateGroupIdExpressions) {
Object value = groupIdExpr.getValue(variableScope);
if (value instanceof String) {
List<String> candiates = extractCandidates((String) value);
task.addCandidateGroups(candiates);
} else if (value instanceof Collection) {
task.addCandidateGroups((Collection) value);
} else {
throw new ProcessEngineException("Expression did not resolve to a string or collection of strings");
}
}
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class CmmnExecution method isSentryPartsSatisfied.
protected boolean isSentryPartsSatisfied(String sentryId, List<? extends CmmnSentryPart> sentryParts) {
// if part will be evaluated in the end
CmmnSentryPart ifPart = null;
if (sentryParts != null && !sentryParts.isEmpty()) {
for (CmmnSentryPart sentryPart : sentryParts) {
if (PLAN_ITEM_ON_PART.equals(sentryPart.getType())) {
if (!sentryPart.isSatisfied()) {
return false;
}
} else if (VARIABLE_ON_PART.equals(sentryPart.getType())) {
if (!sentryPart.isSatisfied()) {
return false;
}
} else {
/* IF_PART.equals(sentryPart.getType) == true */
ifPart = sentryPart;
// once the ifPart has been satisfied the whole sentry is satisfied
if (ifPart.isSatisfied()) {
return true;
}
}
}
}
if (ifPart != null) {
CmmnExecution execution = ifPart.getCaseExecution();
ensureNotNull("Case execution of sentry '" + ifPart.getSentryId() + "': is null", execution);
CmmnActivity activity = ifPart.getCaseExecution().getActivity();
ensureNotNull("Case execution '" + id + "': has no current activity", "activity", activity);
CmmnSentryDeclaration sentryDeclaration = activity.getSentry(sentryId);
ensureNotNull("Case execution '" + id + "': has no declaration for sentry '" + sentryId + "'", "sentryDeclaration", sentryDeclaration);
CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
ensureNotNull("Sentry declaration '" + sentryId + "' has no definied ifPart, but there should be one defined for case execution '" + id + "'.", "ifPartDeclaration", ifPartDeclaration);
Expression condition = ifPartDeclaration.getCondition();
ensureNotNull("A condition was expected for ifPart of Sentry declaration '" + sentryId + "' for case execution '" + id + "'.", "condition", condition);
Object result = condition.getValue(this);
ensureInstanceOf("condition expression returns non-Boolean", "result", result, Boolean.class);
Boolean booleanResult = (Boolean) result;
ifPart.setSatisfied(booleanResult);
return booleanResult;
}
// ifPart then the whole sentry is satisfied.
return true;
}
use of org.camunda.bpm.engine.delegate.Expression in project camunda-bpm-platform by camunda.
the class HumanTaskItemHandler method initializeTaskDefinitionName.
protected void initializeTaskDefinitionName(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
String name = getName(element);
if (name == null) {
HumanTask definition = getDefinition(element);
name = definition.getName();
}
if (name != null) {
ExpressionManager expressionManager = context.getExpressionManager();
Expression nameExpression = expressionManager.createExpression(name);
taskDefinition.setNameExpression(nameExpression);
}
}
Aggregations