Search in sources :

Example 1 with TimerDeclarationImpl

use of org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl in project camunda-bpm-platform by camunda.

the class BpmnDeployer method addTimerDeclarations.

@SuppressWarnings("unchecked")
protected void addTimerDeclarations(ProcessDefinitionEntity processDefinition) {
    List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(BpmnParse.PROPERTYNAME_START_TIMER);
    if (timerDeclarations != null) {
        for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
            String deploymentId = processDefinition.getDeploymentId();
            timerDeclaration.createStartTimerInstance(deploymentId);
        }
    }
}
Also used : TimerDeclarationImpl(org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with TimerDeclarationImpl

use of org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl in project camunda-bpm-platform by camunda.

the class ActivityInstanceJobHandler method handle.

@Override
public void handle(MigratingInstanceParseContext parseContext, MigratingActivityInstance activityInstance, List<JobEntity> elements) {
    Map<String, TimerDeclarationImpl> timerDeclarationsInEventScope = getTimerDeclarationsByTriggeringActivity(activityInstance.getTargetScope());
    for (JobEntity job : elements) {
        if (!isTimerJob(job)) {
            // skip non timer jobs
            continue;
        }
        MigrationInstruction migrationInstruction = parseContext.findSingleMigrationInstruction(job.getActivityId());
        ActivityImpl targetActivity = parseContext.getTargetActivity(migrationInstruction);
        if (targetActivity != null && activityInstance.migratesTo(targetActivity.getEventScope())) {
            // the timer job is migrated
            JobDefinitionEntity targetJobDefinitionEntity = parseContext.getTargetJobDefinition(targetActivity.getActivityId(), job.getJobHandlerType());
            TimerDeclarationImpl targetTimerDeclaration = timerDeclarationsInEventScope.remove(targetActivity.getId());
            MigratingJobInstance migratingTimerJobInstance = new MigratingTimerJobInstance(job, targetJobDefinitionEntity, targetActivity, migrationInstruction.isUpdateEventTrigger(), targetTimerDeclaration);
            activityInstance.addMigratingDependentInstance(migratingTimerJobInstance);
            parseContext.submit(migratingTimerJobInstance);
        } else {
            // the timer job is removed
            MigratingJobInstance removingJobInstance = new MigratingTimerJobInstance(job);
            activityInstance.addRemovingDependentInstance(removingJobInstance);
            parseContext.submit(removingJobInstance);
        }
        parseContext.consume(job);
    }
    if (activityInstance.migrates()) {
        addEmergingTimerJobs(activityInstance, timerDeclarationsInEventScope.values());
    }
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) TimerDeclarationImpl(org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl) JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) MigratingJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance) MigratingTimerJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingTimerJobInstance)

Example 3 with TimerDeclarationImpl

use of org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl in project camunda-bpm-platform by camunda.

the class ExecutionEntity method initializeTimerDeclarations.

@Override
public void initializeTimerDeclarations() {
    LOG.initializeTimerDeclaration(this);
    ScopeImpl scope = getScopeActivity();
    Collection<TimerDeclarationImpl> timerDeclarations = TimerDeclarationImpl.getDeclarationsForScope(scope).values();
    for (TimerDeclarationImpl timerDeclaration : timerDeclarations) {
        timerDeclaration.createTimerInstance(this);
    }
}
Also used : TimerDeclarationImpl(org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Aggregations

TimerDeclarationImpl (org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 MigratingJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)1 MigratingTimerJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingTimerJobInstance)1 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1