Exemple #1
0
        protected internal virtual ValidatingMigrationInstructions wrapMigrationInstructions(MigrationPlan migrationPlan, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, MigrationPlanValidationReportImpl planReport)
        {
            ValidatingMigrationInstructions validatingMigrationInstructions = new ValidatingMigrationInstructions();

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

                string sourceActivityId = migrationInstruction.SourceActivityId;
                string targetActivityId = migrationInstruction.TargetActivityId;
                if (!string.ReferenceEquals(sourceActivityId, null) && !string.ReferenceEquals(targetActivityId, null))
                {
                    ActivityImpl sourceActivity = sourceProcessDefinition.findActivity(sourceActivityId);
                    ActivityImpl 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 (string.ReferenceEquals(sourceActivityId, null))
                    {
                        instructionReport.addFailure("Source activity id is null");
                    }
                    if (string.ReferenceEquals(targetActivityId, null))
                    {
                        instructionReport.addFailure("Target activity id is null");
                    }
                }

                if (instructionReport.hasFailures())
                {
                    planReport.addInstructionReport(instructionReport);
                }
            }
            return(validatingMigrationInstructions);
        }
Exemple #2
0
        protected internal virtual void validateMigrationPlan(CommandContext commandContext, MigrationPlanImpl migrationPlan, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition)
        {
            IList <MigrationInstructionValidator> migrationInstructionValidators = commandContext.ProcessEngineConfiguration.MigrationInstructionValidators;

            MigrationPlanValidationReportImpl planReport = new MigrationPlanValidationReportImpl(migrationPlan);
            ValidatingMigrationInstructions   validatingMigrationInstructions = wrapMigrationInstructions(migrationPlan, sourceProcessDefinition, targetProcessDefinition, planReport);

            foreach (ValidatingMigrationInstruction validatingMigrationInstruction in validatingMigrationInstructions.Instructions)
            {
                MigrationInstructionValidationReportImpl instructionReport = validateInstruction(validatingMigrationInstruction, validatingMigrationInstructions, migrationInstructionValidators);
                if (instructionReport.hasFailures())
                {
                    planReport.addInstructionReport(instructionReport);
                }
            }

            if (planReport.hasInstructionReports())
            {
                throw LOG.failingMigrationPlanValidation(planReport);
            }
        }