Search in sources :

Example 1 with AsyncContinuationConfiguration

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

the class MigratingAsyncJobInstance method updateAsyncBeforeTargetConfiguration.

protected void updateAsyncBeforeTargetConfiguration() {
    AsyncContinuationConfiguration targetConfiguration = new AsyncContinuationConfiguration();
    AsyncContinuationConfiguration currentConfiguration = (AsyncContinuationConfiguration) jobEntity.getJobHandlerConfiguration();
    if (PvmAtomicOperation.PROCESS_START.getCanonicalName().equals(currentConfiguration.getAtomicOperation())) {
        // process start always stays process start
        targetConfiguration.setAtomicOperation(PvmAtomicOperation.PROCESS_START.getCanonicalName());
    } else {
        if (((ActivityImpl) targetScope).getIncomingTransitions().isEmpty()) {
            targetConfiguration.setAtomicOperation(PvmAtomicOperation.ACTIVITY_START_CREATE_SCOPE.getCanonicalName());
        } else {
            targetConfiguration.setAtomicOperation(PvmAtomicOperation.TRANSITION_CREATE_SCOPE.getCanonicalName());
        }
    }
    jobEntity.setJobHandlerConfiguration(targetConfiguration);
}
Also used : AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

Example 2 with AsyncContinuationConfiguration

use of org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration 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)

Example 3 with AsyncContinuationConfiguration

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

the class MigratingAsyncJobInstance method updateAsyncAfterTargetConfiguration.

protected void updateAsyncAfterTargetConfiguration(AsyncContinuationConfiguration currentConfiguration) {
    ActivityImpl targetActivity = (ActivityImpl) targetScope;
    List<PvmTransition> outgoingTransitions = targetActivity.getOutgoingTransitions();
    AsyncContinuationConfiguration targetConfiguration = new AsyncContinuationConfiguration();
    if (outgoingTransitions.isEmpty()) {
        targetConfiguration.setAtomicOperation(PvmAtomicOperation.ACTIVITY_END.getCanonicalName());
    } else {
        targetConfiguration.setAtomicOperation(PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE.getCanonicalName());
        if (outgoingTransitions.size() == 1) {
            targetConfiguration.setTransitionId(outgoingTransitions.get(0).getId());
        } else {
            TransitionImpl matchingTargetTransition = null;
            String currentTransitionId = currentConfiguration.getTransitionId();
            if (currentTransitionId != null) {
                matchingTargetTransition = targetActivity.findOutgoingTransition(currentTransitionId);
            }
            if (matchingTargetTransition != null) {
                targetConfiguration.setTransitionId(matchingTargetTransition.getId());
            } else {
                // should not happen since it is avoided by validation
                throw new ProcessEngineException("Cannot determine matching outgoing sequence flow");
            }
        }
    }
    jobEntity.setJobHandlerConfiguration(targetConfiguration);
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

Example 4 with AsyncContinuationConfiguration

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

the class AsyncContinuationJobHandler method newConfiguration.

@Override
public AsyncContinuationConfiguration newConfiguration(String canonicalString) {
    String[] configParts = tokenizeJobConfiguration(canonicalString);
    AsyncContinuationConfiguration configuration = new AsyncContinuationConfiguration();
    configuration.setAtomicOperation(configParts[0]);
    configuration.setTransitionId(configParts[1]);
    return configuration;
}
Also used : AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

Example 5 with AsyncContinuationConfiguration

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

the class MessageJobDeclaration method resolveJobHandlerConfiguration.

@Override
protected JobHandlerConfiguration resolveJobHandlerConfiguration(AtomicOperationInvocation context) {
    AsyncContinuationConfiguration configuration = new AsyncContinuationConfiguration();
    configuration.setAtomicOperation(context.getOperation().getCanonicalName());
    ExecutionEntity execution = context.getExecution();
    PvmActivity activity = execution.getActivity();
    if (activity != null && activity.isAsyncAfter()) {
        if (execution.getTransition() != null) {
            // store id of selected transition in case this is async after.
            // id is not serialized with the execution -> we need to remember it as
            // job handler configuration.
            configuration.setTransitionId(execution.getTransition().getId());
        }
    }
    return configuration;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) AsyncContinuationConfiguration(org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)

Aggregations

AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)5 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 MigratingJobInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingJobInstance)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)1 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)1