Beispiel #1
0
        public virtual void Generate(ScopeImpl sourceScope, ScopeImpl targetScope,
                                     ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition,
                                     ValidatingMigrationInstructions existingInstructions, bool updateEventTriggers)
        {
            var flowScopeInstructions =
                GenerateInstructionsForActivities((ICollection <ActivityImpl>)sourceScope.Activities,
                                                  (ICollection <ActivityImpl>)targetScope.Activities,
                                                  updateEventTriggers, existingInstructions);

            existingInstructions.AddAll(flowScopeInstructions);

            var eventScopeInstructions = GenerateInstructionsForActivities(sourceScope.EventActivities,
                                                                           targetScope.EventActivities, updateEventTriggers, existingInstructions);

            existingInstructions.AddAll(eventScopeInstructions);

            existingInstructions.FilterWith(MigrationInstructionValidatorsRenamed);

            foreach (var generatedInstruction in flowScopeInstructions)
            {
                if (existingInstructions.Contains(generatedInstruction))
                {
                    Generate((ScopeImpl)generatedInstruction.SourceActivity, (ScopeImpl)generatedInstruction.TargetActivity,
                             sourceProcessDefinition, targetProcessDefinition, existingInstructions, updateEventTriggers);
                }
            }
        }
Beispiel #2
0
        public virtual ValidatingMigrationInstructions generate(ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, bool updateEventTriggers)
        {
            ValidatingMigrationInstructions migrationInstructions = new ValidatingMigrationInstructions();

            generate(sourceProcessDefinition, targetProcessDefinition, sourceProcessDefinition, targetProcessDefinition, migrationInstructions, updateEventTriggers);
            return(migrationInstructions);
        }
Beispiel #3
0
        protected internal virtual IList <IValidatingMigrationInstruction> GenerateInstructionsForActivities(
            ICollection <ActivityImpl> sourceActivities, ICollection <ActivityImpl> targetActivities,
            bool updateEventTriggers, ValidatingMigrationInstructions existingInstructions)
        {
            IList <IValidatingMigrationInstruction> generatedInstructions = new List <IValidatingMigrationInstruction>();

            foreach (var sourceActivity in sourceActivities)
            {
                if (!existingInstructions.ContainsInstructionForSourceScope(sourceActivity))
                {
                    foreach (var targetActivity in targetActivities)
                    {
                        if (IsValidActivity(sourceActivity) && IsValidActivity(targetActivity) &&
                            MigrationActivityMatcher.MatchActivities(sourceActivity, targetActivity))
                        {
                            //for conditional events the update event trigger must be set
                            var updateEventTriggersForInstruction =
                                sourceActivity.ActivityBehavior is IConditionalEventBehavior ||
                                (updateEventTriggers &&
                                 UpdateEventTriggersValidator.DefinesPersistentEventTrigger(sourceActivity));

                            IValidatingMigrationInstruction generatedInstruction =
                                new ValidatingMigrationInstructionImpl(sourceActivity, targetActivity,
                                                                       updateEventTriggersForInstruction);
                            generatedInstructions.Add(generatedInstruction);
                        }
                    }
                }
            }

            return(generatedInstructions);
        }
        protected internal virtual MigrationInstructionValidationReportImpl ValidateInstruction(
            IValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions,
            IList <IMigrationInstructionValidator> migrationInstructionValidators)
        {
            var validationReport = new MigrationInstructionValidationReportImpl(instruction.ToMigrationInstruction());

            foreach (var migrationInstructionValidator in migrationInstructionValidators)
            {
                migrationInstructionValidator.Validate(instruction, instructions, validationReport);
            }
            return(validationReport);
        }
        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);
        }
Beispiel #6
0
        protected internal virtual IList <MigrationInstruction> generateInstructions(CommandContext commandContext, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, bool updateEventTriggers)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.ProcessEngineConfiguration;

            // generate instructions
            MigrationInstructionGenerator   migrationInstructionGenerator = processEngineConfiguration.MigrationInstructionGenerator;
            ValidatingMigrationInstructions generatedInstructions         = migrationInstructionGenerator.generate(sourceProcessDefinition, targetProcessDefinition, updateEventTriggers);

            // filter only valid instructions
            generatedInstructions.filterWith(processEngineConfiguration.MigrationInstructionValidators);

            return(generatedInstructions.asMigrationInstructions());
        }
Beispiel #7
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);
        }
Beispiel #8
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);
            }
        }
Beispiel #9
0
        public virtual void generate(ScopeImpl sourceScope, ScopeImpl targetScope, ProcessDefinitionImpl sourceProcessDefinition, ProcessDefinitionImpl targetProcessDefinition, ValidatingMigrationInstructions existingInstructions, bool updateEventTriggers)
        {
            IList <ValidatingMigrationInstruction> flowScopeInstructions = generateInstructionsForActivities(sourceScope.Activities, targetScope.Activities, updateEventTriggers, existingInstructions);

            existingInstructions.addAll(flowScopeInstructions);

            IList <ValidatingMigrationInstruction> eventScopeInstructions = generateInstructionsForActivities(sourceScope.EventActivities, targetScope.EventActivities, updateEventTriggers, existingInstructions);

            existingInstructions.addAll(eventScopeInstructions);

            existingInstructions.filterWith(migrationInstructionValidators_Renamed);

            foreach (ValidatingMigrationInstruction generatedInstruction in flowScopeInstructions)
            {
                if (existingInstructions.contains(generatedInstruction))
                {
                    generate(generatedInstruction.SourceActivity, generatedInstruction.TargetActivity, sourceProcessDefinition, targetProcessDefinition, existingInstructions, updateEventTriggers);
                }
            }
        }
Beispiel #10
0
        protected internal virtual MigrationInstructionValidationReportImpl validateInstruction(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, IList <MigrationInstructionValidator> migrationInstructionValidators)
        {
            MigrationInstructionValidationReportImpl validationReport = new MigrationInstructionValidationReportImpl(instruction.toMigrationInstruction());

            foreach (MigrationInstructionValidator migrationInstructionValidator in migrationInstructionValidators)
            {
                migrationInstructionValidator.validate(instruction, instructions, validationReport);
            }
            return(validationReport);
        }