Search in sources :

Example 1 with ValidatingMigrationInstructionImpl

use of org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl in project camunda-bpm-platform by camunda.

the class CreateMigrationPlanCmd method wrapMigrationInstructions.

protected ValidatingMigrationInstructions wrapMigrationInstructions(MigrationPlan migrationPlan, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, MigrationPlanValidationReportImpl planReport) {
    ValidatingMigrationInstructions validatingMigrationInstructions = new ValidatingMigrationInstructions();
    for (MigrationInstruction migrationInstruction : migrationPlan.getInstructions()) {
        MigrationInstructionValidationReportImpl instructionReport = new MigrationInstructionValidationReportImpl(migrationInstruction);
        String sourceActivityId = migrationInstruction.getSourceActivityId();
        String targetActivityId = migrationInstruction.getTargetActivityId();
        if (sourceActivityId != null && targetActivityId != null) {
            ActivityImpl sourceActivity = sourceProcessDefinition.findActivity(sourceActivityId);
            ActivityImpl targetActivity = targetProcessDefinition.findActivity(migrationInstruction.getTargetActivityId());
            if (sourceActivity != null && targetActivity != null) {
                validatingMigrationInstructions.addInstruction(new ValidatingMigrationInstructionImpl(sourceActivity, targetActivity, migrationInstruction.isUpdateEventTrigger()));
            } else {
                if (sourceActivity == null) {
                    instructionReport.addFailure("Source activity '" + sourceActivityId + "' does not exist");
                }
                if (targetActivity == null) {
                    instructionReport.addFailure("Target activity '" + targetActivityId + "' does not exist");
                }
            }
        } else {
            if (sourceActivityId == null) {
                instructionReport.addFailure("Source activity id is null");
            }
            if (targetActivityId == null) {
                instructionReport.addFailure("Target activity id is null");
            }
        }
        if (instructionReport.hasFailures()) {
            planReport.addInstructionReport(instructionReport);
        }
    }
    return validatingMigrationInstructions;
}
Also used : MigrationInstructionValidationReportImpl(org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationInstructionValidationReportImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) MigrationInstruction(org.camunda.bpm.engine.migration.MigrationInstruction) ValidatingMigrationInstruction(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction) ValidatingMigrationInstructionImpl(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl) ValidatingMigrationInstructions(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions)

Example 2 with ValidatingMigrationInstructionImpl

use of org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl in project camunda-bpm-platform by camunda.

the class DefaultMigrationInstructionGenerator method generateInstructionsForActivities.

protected List<ValidatingMigrationInstruction> generateInstructionsForActivities(Collection<ActivityImpl> sourceActivities, Collection<ActivityImpl> targetActivities, boolean updateEventTriggers, ValidatingMigrationInstructions existingInstructions) {
    List<ValidatingMigrationInstruction> generatedInstructions = new ArrayList<ValidatingMigrationInstruction>();
    for (ActivityImpl sourceActivity : sourceActivities) {
        if (!existingInstructions.containsInstructionForSourceScope(sourceActivity)) {
            for (ActivityImpl targetActivity : targetActivities) {
                if (isValidActivity(sourceActivity) && isValidActivity(targetActivity) && migrationActivityMatcher.matchActivities(sourceActivity, targetActivity)) {
                    // for conditional events the update event trigger must be set
                    boolean updateEventTriggersForInstruction = sourceActivity.getActivityBehavior() instanceof ConditionalEventBehavior || updateEventTriggers && UpdateEventTriggersValidator.definesPersistentEventTrigger(sourceActivity);
                    ValidatingMigrationInstruction generatedInstruction = new ValidatingMigrationInstructionImpl(sourceActivity, targetActivity, updateEventTriggersForInstruction);
                    generatedInstructions.add(generatedInstruction);
                }
            }
        }
    }
    return generatedInstructions;
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ValidatingMigrationInstructionImpl(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl) ArrayList(java.util.ArrayList) ConditionalEventBehavior(org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior) ValidatingMigrationInstruction(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)

Aggregations

ValidatingMigrationInstruction (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)2 ValidatingMigrationInstructionImpl (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl)2 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 ArrayList (java.util.ArrayList)1 ConditionalEventBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ConditionalEventBehavior)1 MigrationInstructionValidationReportImpl (org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationInstructionValidationReportImpl)1 ValidatingMigrationInstructions (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1