use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.
the class AbstractActivityBpmnParseHandler method createMultiInstanceLoopCharacteristics.
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {
MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
// Activity Behavior
MultiInstanceActivityBehavior miActivityBehavior = null;
ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
if (activity == null) {
throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
}
if (loopCharacteristics.isSequential()) {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
} else {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
}
// ActivityImpl settings
activity.setScope(true);
activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
activity.setActivityBehavior(miActivityBehavior);
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
// loopcardinality
if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
}
// completion condition
if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
}
// activiti:collection
if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
if (loopCharacteristics.getInputDataItem().contains("{")) {
miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
} else {
miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
}
}
// activiti:elementVariable
if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
}
// activiti:elementIndexVariable
if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) {
miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable());
}
}
use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.
the class TimerEventDefinitionParseHandler method createTimer.
protected TimerDeclarationImpl createTimer(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) {
TimerDeclarationType type = null;
Expression expression = null;
Expression endDate = null;
Expression calendarName = null;
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDate())) {
// TimeDate
type = TimerDeclarationType.DATE;
expression = expressionManager.createExpression(timerEventDefinition.getTimeDate());
} else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeCycle())) {
// TimeCycle
type = TimerDeclarationType.CYCLE;
expression = expressionManager.createExpression(timerEventDefinition.getTimeCycle());
//support for endDate
if (StringUtils.isNotEmpty(timerEventDefinition.getEndDate())) {
endDate = expressionManager.createExpression(timerEventDefinition.getEndDate());
}
} else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDuration())) {
// TimeDuration
type = TimerDeclarationType.DURATION;
expression = expressionManager.createExpression(timerEventDefinition.getTimeDuration());
}
if (StringUtils.isNotEmpty(timerEventDefinition.getCalendarName())) {
calendarName = expressionManager.createExpression(timerEventDefinition.getCalendarName());
}
// neither date, cycle or duration configured!
if (expression == null) {
logger.warn("Timer needs configuration (either timeDate, timeCycle or timeDuration is needed) (" + timerActivity.getId() + ")");
}
String jobHandlerConfiguration = timerActivity.getId();
if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) {
jobHandlerConfiguration = TimerStartEventJobHandler.createConfiguration(timerActivity.getId(), endDate, calendarName);
}
// Parse the timer declaration
// TODO move the timer declaration into the bpmn activity or next to the
// TimerSession
TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType, endDate, calendarName);
timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration);
timerDeclaration.setExclusive(true);
return timerDeclaration;
}
use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.
the class ProcessParseHandler method transformProcess.
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) {
ProcessDefinitionEntity currentProcessDefinition = new ProcessDefinitionEntity();
bpmnParse.setCurrentProcessDefinition(currentProcessDefinition);
/*
* Mapping object model - bpmn xml: processDefinition.id -> generated by
* activiti engine processDefinition.key -> bpmn id (required)
* processDefinition.name -> bpmn name (optional)
*/
currentProcessDefinition.setKey(process.getId());
currentProcessDefinition.setName(process.getName());
currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace());
currentProcessDefinition.setDescription(process.getDocumentation());
// Kept for backwards compatibility. See ACT-1020
currentProcessDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, process.getDocumentation());
currentProcessDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId());
createExecutionListenersOnScope(bpmnParse, process.getExecutionListeners(), currentProcessDefinition);
createEventListeners(bpmnParse, process.getEventListeners(), currentProcessDefinition);
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
for (String candidateUser : process.getCandidateStarterUsers()) {
currentProcessDefinition.addCandidateStarterUserIdExpression(expressionManager.createExpression(candidateUser));
}
for (String candidateGroup : process.getCandidateStarterGroups()) {
currentProcessDefinition.addCandidateStarterGroupIdExpression(expressionManager.createExpression(candidateGroup));
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey());
}
bpmnParse.setCurrentScope(currentProcessDefinition);
bpmnParse.processFlowElements(process.getFlowElements());
processArtifacts(bpmnParse, process.getArtifacts(), currentProcessDefinition);
// parse out any data objects from the template in order to set up the necessary process variables
Map<String, Object> variables = processDataObjects(bpmnParse, process.getDataObjects(), currentProcessDefinition);
if (null != currentProcessDefinition.getVariables()) {
currentProcessDefinition.getVariables().putAll(variables);
} else {
currentProcessDefinition.setVariables(variables);
}
bpmnParse.removeCurrentScope();
if (process.getIoSpecification() != null) {
IOSpecification ioSpecification = createIOSpecification(bpmnParse, process.getIoSpecification());
currentProcessDefinition.setIoSpecification(ioSpecification);
}
return currentProcessDefinition;
}
use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.
the class DefaultFormHandler method parseConfiguration.
public void parseConfiguration(List<org.activiti.bpmn.model.FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinitionEntity processDefinition) {
this.deploymentId = deployment.getId();
ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
if (StringUtils.isNotEmpty(formKey)) {
this.formKey = expressionManager.createExpression(formKey);
}
FormTypes formTypes = Context.getProcessEngineConfiguration().getFormTypes();
for (org.activiti.bpmn.model.FormProperty formProperty : formProperties) {
FormPropertyHandler formPropertyHandler = new FormPropertyHandler();
formPropertyHandler.setId(formProperty.getId());
formPropertyHandler.setName(formProperty.getName());
AbstractFormType type = formTypes.parseFormPropertyType(formProperty);
formPropertyHandler.setType(type);
formPropertyHandler.setRequired(formProperty.isRequired());
formPropertyHandler.setReadable(formProperty.isReadable());
formPropertyHandler.setWritable(formProperty.isWriteable());
formPropertyHandler.setVariableName(formProperty.getVariable());
if (StringUtils.isNotEmpty(formProperty.getExpression())) {
Expression expression = expressionManager.createExpression(formProperty.getExpression());
formPropertyHandler.setVariableExpression(expression);
}
if (StringUtils.isNotEmpty(formProperty.getDefaultExpression())) {
Expression defaultExpression = expressionManager.createExpression(formProperty.getDefaultExpression());
formPropertyHandler.setDefaultExpression(defaultExpression);
}
formPropertyHandlers.add(formPropertyHandler);
}
}
use of org.activiti.engine.impl.el.ExpressionManager in project Activiti by Activiti.
the class UserTaskActivityBehavior method getActiveValueSet.
protected Set<Expression> getActiveValueSet(Set<Expression> originalValues, String propertyName, ObjectNode taskElementProperties) {
Set<Expression> activeValues = originalValues;
if (taskElementProperties != null) {
JsonNode overrideValuesNode = taskElementProperties.get(propertyName);
if (overrideValuesNode != null) {
if (overrideValuesNode.isNull() || overrideValuesNode.isArray() == false || overrideValuesNode.size() == 0) {
activeValues = null;
} else {
ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager();
activeValues = new HashSet<Expression>();
for (JsonNode valueNode : overrideValuesNode) {
activeValues.add(expressionManager.createExpression(valueNode.asText()));
}
}
}
}
return activeValues;
}
Aggregations