use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DefaultJobManager method scheduleTimerJob.
@Override
public void scheduleTimerJob(TimerJobEntity timerJob) {
if (timerJob == null) {
throw new ActivitiException("Empty timer job can not be scheduled");
}
processEngineConfiguration.getTimerJobEntityManager().insert(timerJob);
CommandContext commandContext = Context.getCommandContext();
ActivitiEventDispatcher eventDispatcher = commandContext.getEventDispatcher();
if (eventDispatcher.isEnabled()) {
eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TIMER_SCHEDULED, timerJob));
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DefaultJobManager method restoreExtraData.
protected void restoreExtraData(JobEntity timerEntity, VariableScope variableScope) {
String activityId = timerEntity.getJobHandlerConfiguration();
if (timerEntity.getJobHandlerType().equalsIgnoreCase(TimerStartEventJobHandler.TYPE) || timerEntity.getJobHandlerType().equalsIgnoreCase(TriggerTimerEventJobHandler.TYPE)) {
activityId = TimerEventHandler.getActivityIdFromConfiguration(timerEntity.getJobHandlerConfiguration());
String endDateExpressionString = TimerEventHandler.getEndDateFromConfiguration(timerEntity.getJobHandlerConfiguration());
if (endDateExpressionString != null) {
Expression endDateExpression = processEngineConfiguration.getExpressionManager().createExpression(endDateExpressionString);
String endDateString = null;
BusinessCalendar businessCalendar = processEngineConfiguration.getBusinessCalendarManager().getBusinessCalendar(getBusinessCalendarName(TimerEventHandler.geCalendarNameFromConfiguration(timerEntity.getJobHandlerConfiguration()), variableScope));
if (endDateExpression != null) {
Object endDateValue = endDateExpression.getValue(variableScope);
if (endDateValue instanceof String) {
endDateString = (String) endDateValue;
} else if (endDateValue instanceof Date) {
timerEntity.setEndDate((Date) endDateValue);
} else {
throw new ActivitiException("Timer '" + ((ExecutionEntity) variableScope).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 (timerEntity.getEndDate() == null) {
timerEntity.setEndDate(businessCalendar.resolveEndDate(endDateString));
}
}
}
}
int maxIterations = 1;
if (timerEntity.getProcessDefinitionId() != null) {
org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(timerEntity.getProcessDefinitionId());
maxIterations = getMaxIterations(process, activityId);
if (maxIterations <= 1) {
maxIterations = getMaxIterations(process, activityId);
}
}
timerEntity.setMaxIterations(maxIterations);
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DestroyScopeOperation method run.
@Override
public void run() {
// Find the actual scope that needs to be destroyed.
// This could be the incoming execution, or the first parent execution where isScope = true
// Find parent scope execution
ExecutionEntity scopeExecution = execution.isScope() ? execution : findFirstParentScopeExecution(execution);
if (scopeExecution == null) {
throw new ActivitiException("Programmatic error: no parent scope execution found for boundary event");
}
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
deleteAllChildExecutions(executionEntityManager, scopeExecution);
// Delete all scope tasks
TaskEntityManager taskEntityManager = commandContext.getTaskEntityManager();
deleteAllScopeTasks(scopeExecution, taskEntityManager);
// Delete all scope jobs
TimerJobEntityManager timerJobEntityManager = commandContext.getTimerJobEntityManager();
deleteAllScopeJobs(scopeExecution, timerJobEntityManager);
// Remove variables associated with this scope
VariableInstanceEntityManager variableInstanceEntityManager = commandContext.getVariableInstanceEntityManager();
removeAllVariablesFromScope(scopeExecution, variableInstanceEntityManager);
commandContext.getHistoryManager().recordActivityEnd(scopeExecution, scopeExecution.getDeleteReason());
executionEntityManager.delete(scopeExecution);
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class BoundaryEventActivityBehavior method executeInterruptingBehavior.
protected void executeInterruptingBehavior(ExecutionEntity executionEntity, CommandContext commandContext) {
// The destroy scope operation will look for the parent execution and
// destroy the whole scope, and leave the boundary event using this parent execution.
//
// The take outgoing seq flows operation below (the non-interrupting else clause) on the other hand uses the
// child execution to leave, which keeps the scope alive.
// Which is what we need here.
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
ExecutionEntity attachedRefScopeExecution = executionEntityManager.findById(executionEntity.getParentId());
ExecutionEntity parentScopeExecution = null;
ExecutionEntity currentlyExaminedExecution = executionEntityManager.findById(attachedRefScopeExecution.getParentId());
while (currentlyExaminedExecution != null && parentScopeExecution == null) {
if (currentlyExaminedExecution.isScope()) {
parentScopeExecution = currentlyExaminedExecution;
} else {
currentlyExaminedExecution = executionEntityManager.findById(currentlyExaminedExecution.getParentId());
}
}
if (parentScopeExecution == null) {
throw new ActivitiException("Programmatic error: no parent scope execution found for boundary event");
}
deleteChildExecutions(attachedRefScopeExecution, executionEntity, commandContext);
// set new parent for boundary event execution
executionEntity.setParent(parentScopeExecution);
Context.getAgenda().planTakeOutgoingSequenceFlowsOperation(executionEntity, true);
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DbSqlSession method flushUpdates.
protected void flushUpdates() {
for (Entity updatedObject : updatedObjects) {
String updateStatement = dbSqlSessionFactory.getUpdateStatement(updatedObject);
updateStatement = dbSqlSessionFactory.mapStatement(updateStatement);
if (updateStatement == null) {
throw new ActivitiException("no update statement for " + updatedObject.getClass() + " in the ibatis mapping files");
}
log.debug("updating: {}", updatedObject);
int updatedRecords = sqlSession.update(updateStatement, updatedObject);
if (updatedRecords == 0) {
throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently");
}
// See https://activiti.atlassian.net/browse/ACT-1290
if (updatedObject instanceof HasRevision) {
((HasRevision) updatedObject).setRevision(((HasRevision) updatedObject).getRevisionNext());
}
}
updatedObjects.clear();
}
Aggregations