Search in sources :

Example 1 with ValidatingMigrationInstructions

use of org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions 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 ValidatingMigrationInstructions

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

the class CreateMigrationPlanCmd method validateMigrationPlan.

protected void validateMigrationPlan(CommandContext commandContext, MigrationPlanImpl migrationPlan, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition) {
    List<MigrationInstructionValidator> migrationInstructionValidators = commandContext.getProcessEngineConfiguration().getMigrationInstructionValidators();
    MigrationPlanValidationReportImpl planReport = new MigrationPlanValidationReportImpl(migrationPlan);
    ValidatingMigrationInstructions validatingMigrationInstructions = wrapMigrationInstructions(migrationPlan, sourceProcessDefinition, targetProcessDefinition, planReport);
    for (ValidatingMigrationInstruction validatingMigrationInstruction : validatingMigrationInstructions.getInstructions()) {
        MigrationInstructionValidationReportImpl instructionReport = validateInstruction(validatingMigrationInstruction, validatingMigrationInstructions, migrationInstructionValidators);
        if (instructionReport.hasFailures()) {
            planReport.addInstructionReport(instructionReport);
        }
    }
    if (planReport.hasInstructionReports()) {
        throw LOG.failingMigrationPlanValidation(planReport);
    }
}
Also used : MigrationInstructionValidator(org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationInstructionValidator) MigrationInstructionValidationReportImpl(org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationInstructionValidationReportImpl) ValidatingMigrationInstructions(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions) MigrationPlanValidationReportImpl(org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationPlanValidationReportImpl) ValidatingMigrationInstruction(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)

Example 3 with ValidatingMigrationInstructions

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

the class DefaultMigrationInstructionGenerator method generate.

public ValidatingMigrationInstructions generate(ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, boolean updateEventTriggers) {
    ValidatingMigrationInstructions migrationInstructions = new ValidatingMigrationInstructions();
    generate(sourceProcessDefinition, targetProcessDefinition, sourceProcessDefinition, targetProcessDefinition, migrationInstructions, updateEventTriggers);
    return migrationInstructions;
}
Also used : ValidatingMigrationInstructions(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions)

Example 4 with ValidatingMigrationInstructions

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

the class CreateMigrationPlanCmd method generateInstructions.

protected List<MigrationInstruction> generateInstructions(CommandContext commandContext, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, boolean updateEventTriggers) {
    ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration();
    // generate instructions
    MigrationInstructionGenerator migrationInstructionGenerator = processEngineConfiguration.getMigrationInstructionGenerator();
    ValidatingMigrationInstructions generatedInstructions = migrationInstructionGenerator.generate(sourceProcessDefinition, targetProcessDefinition, updateEventTriggers);
    // filter only valid instructions
    generatedInstructions.filterWith(processEngineConfiguration.getMigrationInstructionValidators());
    return generatedInstructions.asMigrationInstructions();
}
Also used : MigrationInstructionGenerator(org.camunda.bpm.engine.impl.migration.MigrationInstructionGenerator) ValidatingMigrationInstructions(org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Aggregations

ValidatingMigrationInstructions (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructions)4 MigrationInstructionValidationReportImpl (org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationInstructionValidationReportImpl)2 ValidatingMigrationInstruction (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstruction)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 MigrationInstructionGenerator (org.camunda.bpm.engine.impl.migration.MigrationInstructionGenerator)1 MigrationInstructionValidator (org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationInstructionValidator)1 MigrationPlanValidationReportImpl (org.camunda.bpm.engine.impl.migration.validation.instruction.MigrationPlanValidationReportImpl)1 ValidatingMigrationInstructionImpl (org.camunda.bpm.engine.impl.migration.validation.instruction.ValidatingMigrationInstructionImpl)1 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)1 MigrationInstruction (org.camunda.bpm.engine.migration.MigrationInstruction)1