Exemplo n.º 1
0
        protected internal virtual void ValidateMigrationPlan(CommandContext commandContext,
                                                              MigrationPlanImpl migrationPlan, ProcessDefinitionImpl sourceProcessDefinition,
                                                              ProcessDefinitionImpl targetProcessDefinition)
        {
            var migrationInstructionValidators =
                commandContext.ProcessEngineConfiguration.MigrationInstructionValidators;

            var planReport = new MigrationPlanValidationReportImpl(migrationPlan);
            var validatingMigrationInstructions = WrapMigrationInstructions(migrationPlan, sourceProcessDefinition,
                                                                            targetProcessDefinition, planReport);

            foreach (var validatingMigrationInstruction in validatingMigrationInstructions.Instructions)
            {
                var instructionReport = ValidateInstruction(validatingMigrationInstruction,
                                                            validatingMigrationInstructions, migrationInstructionValidators);
                if (instructionReport.HasFailures())
                {
                    planReport.AddInstructionReport(instructionReport);
                }
            }

            if (planReport.HasInstructionReports())
            {
                throw Log.FailingMigrationPlanValidation(planReport);
            }
        }
Exemplo n.º 2
0
        protected internal virtual ValidatingMigrationInstructions WrapMigrationInstructions(
            IMigrationPlan migrationPlan, ProcessDefinitionImpl sourceProcessDefinition,
            ProcessDefinitionImpl targetProcessDefinition, MigrationPlanValidationReportImpl planReport)
        {
            var validatingMigrationInstructions = new ValidatingMigrationInstructions();

            foreach (var migrationInstruction in migrationPlan.Instructions)
            {
                var instructionReport = new MigrationInstructionValidationReportImpl(migrationInstruction);

                var sourceActivityId = migrationInstruction.SourceActivityId;
                var targetActivityId = migrationInstruction.TargetActivityId;
                if (!ReferenceEquals(sourceActivityId, null) && !ReferenceEquals(targetActivityId, null))
                {
                    IPvmActivity sourceActivity = sourceProcessDefinition.FindActivity(sourceActivityId);
                    IPvmActivity targetActivity = targetProcessDefinition.FindActivity(migrationInstruction.TargetActivityId);

                    if (sourceActivity != null && targetActivity != null)
                    {
                        validatingMigrationInstructions.AddInstruction(new ValidatingMigrationInstructionImpl(sourceActivity, targetActivity, migrationInstruction.UpdateEventTrigger));
                    }
                    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 (ReferenceEquals(sourceActivityId, null))
                    {
                        instructionReport.AddFailure("Source activity id is null");
                    }
                    if (ReferenceEquals(targetActivityId, null))
                    {
                        instructionReport.AddFailure("Target activity id is null");
                    }
                }

                if (instructionReport.HasFailures())
                {
                    planReport.AddInstructionReport(instructionReport);
                }
            }
            return(validatingMigrationInstructions);
        }