Search in sources :

Example 1 with VariableScope

use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.

the class TimerEntity method restoreExtraData.

protected void restoreExtraData(CommandContext commandContext, String jobHandlerConfiguration) {
    String embededActivityId = jobHandlerConfiguration;
    if (jobHandlerType.equalsIgnoreCase(TimerExecuteNestedActivityJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerCatchIntermediateEventJobHandler.TYPE) || jobHandlerType.equalsIgnoreCase(TimerStartEventJobHandler.TYPE)) {
        embededActivityId = TimerEventHandler.getActivityIdFromConfiguration(jobHandlerConfiguration);
        String endDateExpressionString = TimerEventHandler.getEndDateFromConfiguration(jobHandlerConfiguration);
        if (endDateExpressionString != null) {
            Expression endDateExpression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(endDateExpressionString);
            String endDateString = null;
            BusinessCalendar businessCalendar = Context.getProcessEngineConfiguration().getBusinessCalendarManager().getBusinessCalendar(getBusinessCalendarName(TimerEventHandler.geCalendarNameFromConfiguration(jobHandlerConfiguration)));
            VariableScope executionEntity = null;
            if (executionId != null) {
                executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
            }
            if (executionEntity == null) {
                executionEntity = NoExecutionVariableScope.getSharedInstance();
            }
            if (endDateExpression != null) {
                Object endDateValue = endDateExpression.getValue(executionEntity);
                if (endDateValue instanceof String) {
                    endDateString = (String) endDateValue;
                } else if (endDateValue instanceof Date) {
                    endDate = (Date) endDateValue;
                } else {
                    throw new ActivitiException("Timer '" + ((ExecutionEntity) executionEntity).getActivityId() + "' was not configured with a valid duration/time, either hand in a java.util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'");
                }
                if (endDate == null) {
                    endDate = businessCalendar.resolveEndDate(endDateString);
                }
            }
        }
    }
    if (processDefinitionId != null) {
        ProcessDefinition definition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
        maxIterations = checkStartEventDefinitions(definition, embededActivityId);
        if (maxIterations <= 1) {
            maxIterations = checkBoundaryEventsDefinitions(definition, embededActivityId);
        }
    } else {
        maxIterations = 1;
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Expression(org.activiti.engine.delegate.Expression) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar) BusinessCalendar(org.activiti.engine.impl.calendar.BusinessCalendar) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) VariableScope(org.activiti.engine.delegate.VariableScope) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) Date(java.util.Date)

Example 2 with VariableScope

use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.

the class TimerEntity method getBusinessCalendarName.

protected String getBusinessCalendarName(String calendarName) {
    String businessCalendarName = CycleBusinessCalendar.NAME;
    if (StringUtils.isNotEmpty(calendarName)) {
        VariableScope execution = NoExecutionVariableScope.getSharedInstance();
        if (StringUtils.isNotEmpty(this.executionId)) {
            execution = Context.getCommandContext().getExecutionEntityManager().findExecutionById(this.executionId);
        }
        businessCalendarName = (String) Context.getProcessEngineConfiguration().getExpressionManager().createExpression(calendarName).getValue(execution);
    }
    return businessCalendarName;
}
Also used : VariableScope(org.activiti.engine.delegate.VariableScope) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope)

Example 3 with VariableScope

use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.

the class ScriptEventHandler method handle.

@Override
public void handle(SimulationEvent event) {
    ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
    VariableScope execution = SimulationRunContext.getExecution();
    try {
        scriptingEngines.evaluate((String) event.getProperty(this.scriptPropertyName), language, execution, false);
    } catch (ActivitiException e) {
        log.warn("Exception while executing simulation event " + event + " scriptPropertyName :" + this.scriptPropertyName + "\n script: " + event.getProperty(this.scriptPropertyName) + "\n exception is:" + e.getMessage());
        throw e;
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ScriptingEngines(org.activiti.engine.impl.scripting.ScriptingEngines) VariableScope(org.activiti.engine.delegate.VariableScope)

Example 4 with VariableScope

use of org.activiti.engine.delegate.VariableScope in project Activiti by Activiti.

the class Assignment method evaluate.

public void evaluate(ActivityExecution execution) {
    VariableScope variableScope = (VariableScope) execution;
    Object value = this.fromExpression.getValue(variableScope);
    this.toExpression.setValue(value, variableScope);
}
Also used : VariableScope(org.activiti.engine.delegate.VariableScope)

Example 5 with VariableScope

use of org.activiti.engine.delegate.VariableScope in project CzechIdMng by bcvsolutions.

the class AbstractApprovableEventProcessor method process.

@Override
public EventResult<DTO> process(EntityEvent<DTO> event) {
    Map<String, Object> variables = new HashMap<>();
    variables.put(EntityEvent.EVENT_PROPERTY, event);
    // 
    ProcessInstance processInstance = processInstance(variables);
    // 
    boolean suspend = true;
    if (processInstance.isEnded()) {
        suspend = false;
    } else if (processInstance instanceof VariableScope) {
        Object skipApproving = ((VariableScope) processInstance).getVariable(WF_VARIABLE_SKIP_APPROVING);
        if (skipApproving instanceof Boolean && Boolean.TRUE.equals(skipApproving)) {
            suspend = false;
        }
    }
    // 
    return new DefaultEventResult.Builder<>(event, this).setSuspended(suspend).setResult(getResult(processInstance)).build();
}
Also used : HashMap(java.util.HashMap) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) VariableScope(org.activiti.engine.delegate.VariableScope)

Aggregations

VariableScope (org.activiti.engine.delegate.VariableScope)10 ActivitiException (org.activiti.engine.ActivitiException)3 NoExecutionVariableScope (org.activiti.engine.impl.el.NoExecutionVariableScope)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 BusinessCalendar (org.activiti.engine.impl.calendar.BusinessCalendar)2 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)1 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)1 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)1 SysSyncConfig (eu.bcvsolutions.idm.acc.entity.SysSyncConfig)1 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 Expression (org.activiti.engine.delegate.Expression)1