use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class AbstractMigrationCmd method resolveTargetProcessDefinition.
protected ProcessDefinitionEntity resolveTargetProcessDefinition(CommandContext commandContext) {
String targetProcessDefinitionId = executionBuilder.getMigrationPlan().getTargetProcessDefinitionId();
ProcessDefinitionEntity sourceProcessDefinition = getProcessDefinition(commandContext, targetProcessDefinitionId);
EnsureUtil.ensureNotNull("sourceProcessDefinition", sourceProcessDefinition);
return sourceProcessDefinition;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class MigratingJobInstance method migrateState.
public void migrateState() {
// update activity reference
String activityId = targetScope.getId();
jobEntity.setActivityId(activityId);
migrateJobHandlerConfiguration();
if (targetJobDefinitionEntity != null) {
jobEntity.setJobDefinition(targetJobDefinitionEntity);
}
// update process definition reference
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) targetScope.getProcessDefinition();
jobEntity.setProcessDefinitionId(processDefinition.getId());
jobEntity.setProcessDefinitionKey(processDefinition.getKey());
// update deployment reference
jobEntity.setDeploymentId(processDefinition.getDeploymentId());
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class MigratingInstanceParser method parse.
public MigratingProcessInstance parse(String processInstanceId, MigrationPlan migrationPlan, MigratingProcessInstanceValidationReportImpl processInstanceReport) {
CommandContext commandContext = Context.getCommandContext();
List<EventSubscriptionEntity> eventSubscriptions = fetchEventSubscriptions(commandContext, processInstanceId);
List<ExecutionEntity> executions = fetchExecutions(commandContext, processInstanceId);
List<ExternalTaskEntity> externalTasks = fetchExternalTasks(commandContext, processInstanceId);
List<IncidentEntity> incidents = fetchIncidents(commandContext, processInstanceId);
List<JobEntity> jobs = fetchJobs(commandContext, processInstanceId);
List<TaskEntity> tasks = fetchTasks(commandContext, processInstanceId);
List<VariableInstanceEntity> variables = fetchVariables(commandContext, processInstanceId);
ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
processInstance.restoreProcessInstance(executions, eventSubscriptions, variables, tasks, jobs, incidents, externalTasks);
ProcessDefinitionEntity targetProcessDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(migrationPlan.getTargetProcessDefinitionId());
List<JobDefinitionEntity> targetJobDefinitions = fetchJobDefinitions(commandContext, targetProcessDefinition.getId());
final MigratingInstanceParseContext parseContext = new MigratingInstanceParseContext(this, migrationPlan, processInstance, targetProcessDefinition).eventSubscriptions(eventSubscriptions).externalTasks(externalTasks).incidents(incidents).jobs(jobs).tasks(tasks).targetJobDefinitions(targetJobDefinitions).variables(variables);
ActivityInstance activityInstance = engine.getRuntimeService().getActivityInstance(processInstanceId);
ActivityInstanceWalker activityInstanceWalker = new ActivityInstanceWalker(activityInstance);
activityInstanceWalker.addPreVisitor(new TreeVisitor<ActivityInstance>() {
@Override
public void visit(ActivityInstance obj) {
activityInstanceHandler.handle(parseContext, obj);
}
});
activityInstanceWalker.walkWhile();
CompensationEventSubscriptionWalker compensateSubscriptionsWalker = new CompensationEventSubscriptionWalker(parseContext.getMigratingActivityInstances());
compensateSubscriptionsWalker.addPreVisitor(new TreeVisitor<EventSubscriptionEntity>() {
@Override
public void visit(EventSubscriptionEntity obj) {
compensationInstanceHandler.handle(parseContext, obj);
}
});
compensateSubscriptionsWalker.walkWhile();
for (IncidentEntity incidentEntity : incidents) {
incidentHandler.handle(parseContext, incidentEntity);
}
parseContext.validateNoEntitiesLeft(processInstanceReport);
return parseContext.getMigratingProcessInstance();
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class DefaultCorrelationHandler method correlateStartMessageByEventSubscription.
protected List<CorrelationHandlerResult> correlateStartMessageByEventSubscription(CommandContext commandContext, String messageName, CorrelationSet correlationSet) {
List<CorrelationHandlerResult> results = new ArrayList<CorrelationHandlerResult>();
DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();
List<EventSubscriptionEntity> messageEventSubscriptions = findMessageStartEventSubscriptions(commandContext, messageName, correlationSet);
for (EventSubscriptionEntity messageEventSubscription : messageEventSubscriptions) {
if (messageEventSubscription.getConfiguration() != null) {
String processDefinitionId = messageEventSubscription.getConfiguration();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
// only an active process definition will be returned
if (processDefinition != null && !processDefinition.isSuspended()) {
CorrelationHandlerResult result = CorrelationHandlerResult.matchedProcessDefinition(processDefinition, messageEventSubscription.getActivityId());
results.add(result);
} else {
LOG.couldNotFindProcessDefinitionForEventSubscription(messageEventSubscription, processDefinitionId);
}
}
}
return results;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class DefaultCorrelationHandler method correlateStartMessageByProcessDefinitionId.
protected CorrelationHandlerResult correlateStartMessageByProcessDefinitionId(CommandContext commandContext, String messageName, String processDefinitionId) {
DeploymentCache deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentCache();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
// only an active process definition will be returned
if (processDefinition != null && !processDefinition.isSuspended()) {
String startActivityId = findStartActivityIdByMessage(processDefinition, messageName);
if (startActivityId != null) {
return CorrelationHandlerResult.matchedProcessDefinition(processDefinition, startActivityId);
}
}
return null;
}
Aggregations