Search in sources :

Example 1 with MigratingJobInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance in project camunda-bpm-platform by camunda.

the class IncidentInstanceHandler method handleFailedJobIncident.

protected void handleFailedJobIncident(MigratingInstanceParseContext parseContext, IncidentEntity incident) {
    MigratingJobInstance owningInstance = parseContext.getMigratingJobInstanceById(incident.getConfiguration());
    if (owningInstance != null) {
        parseContext.consume(incident);
        if (owningInstance.migrates()) {
            MigratingIncident migratingIncident = new MigratingIncident(incident, owningInstance.getTargetScope());
            JobDefinitionEntity targetJobDefinitionEntity = owningInstance.getTargetJobDefinitionEntity();
            if (targetJobDefinitionEntity != null) {
                migratingIncident.setTargetJobDefinitionId(targetJobDefinitionEntity.getId());
            }
            owningInstance.addMigratingDependentInstance(migratingIncident);
        }
    }
}
Also used : JobDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity) MigratingIncident(org.camunda.bpm.engine.impl.migration.instance.MigratingIncident) MigratingJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)

Example 2 with MigratingJobInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance 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 MigratingJobInstance

use of org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance in project camunda-bpm-platform by camunda.

the class AsyncAfterMigrationValidator method validate.

@Override
public void validate(MigratingTransitionInstance migratingInstance, MigratingProcessInstance migratingProcessInstance, MigratingTransitionInstanceValidationReportImpl instanceReport) {
    ActivityImpl targetActivity = (ActivityImpl) migratingInstance.getTargetScope();
    if (targetActivity != null && migratingInstance.isAsyncAfter()) {
        MigratingJobInstance jobInstance = migratingInstance.getJobInstance();
        AsyncContinuationConfiguration config = (AsyncContinuationConfiguration) jobInstance.getJobEntity().getJobHandlerConfiguration();
        String sourceTransitionId = config.getTransitionId();
        if (targetActivity.getOutgoingTransitions().size() > 1) {
            if (sourceTransitionId == null) {
                instanceReport.addFailure("Transition instance is assigned to no sequence flow" + " and target activity has more than one outgoing sequence flow");
            } else {
                TransitionImpl matchingOutgoingTransition = targetActivity.findOutgoingTransition(sourceTransitionId);
                if (matchingOutgoingTransition == null) {
                    instanceReport.addFailure("Transition instance is assigned to a sequence flow" + " that cannot be matched in the target activity");
                }
            }
        }
    }
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigratingJobInstance(org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance) AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

Aggregations

MigratingJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)3 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)2 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)1 TimerDeclarationImpl (org.camunda.bpm.engine.impl.jobexecutor.TimerDeclarationImpl)1 MigratingIncident (org.camunda.bpm.engine.impl.migration.instance.MigratingIncident)1 MigratingTimerJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingTimerJobInstance)1 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)1 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1