public IUndoableEdit ChangeRiskLevel(int newRiskLevel)
        {
            CompoundEdit ce = new CompoundEdit();

            //check if is posible to assign the new risk level
            if (riskLevelObject.GetParentRiskLevels() != null)
            {
                foreach (IRiskLevelObject parentRiskLevel in riskLevelObject.GetParentRiskLevels())
                {
                    if (newRiskLevel < parentRiskLevel.RiskLevel)
                    {
                        throw new Exception("The risk level cannot change, contains a greater risk level as a parent");
                    }
                }
            }
            //change the risk level of each children
            if (riskLevelObject.GetChildrenRiskLevels() != null)
            {
                foreach (IRiskLevelObject o in riskLevelObject.GetChildrenRiskLevels())
                {
                    RiskLevelManager rlm = new RiskLevelManager(o);
                    ce.AddEdit(rlm.ChangeRiskLevel(newRiskLevel));
                }
            }
            ce.AddEdit(EditFactory.instance.CreateChangeRiskLevelEdit(riskLevelObject, newRiskLevel));
            riskLevelObject.RiskLevel = newRiskLevel;
            return(ce);
        }
Пример #2
0
        private IUndoableEdit MergeEffects(IList <Combination> combinationsToMerge)
        {
            CompoundEdit ce = new CompoundEdit();

            foreach (Combination combi in combinationsToMerge)
            {
                foreach (Effect effect in combi.Effects)
                {
                    if (!combination.Effects.Contains(effect))
                    {
                        ce.AddEdit(EditFactory.instance.CreateAddEffectEdit(combination, effect));
                        combination.AddEffect(effect);
                    }
                }
            }
            foreach (Combination combi in combinationsToMerge)
            {
                foreach (Effect effect in combi.Effects)
                {
                    if (!combi.Effects.Contains(effect))
                    {
                        ce.AddEdit(EditFactory.instance.CreateAddEffectEdit(combi, effect));
                        combi.AddEffect(effect);
                    }
                    //update risk level
                    RiskLevelManager rlm = new RiskLevelManager(effect);
                    ce.AddEdit(rlm.ApplyRiskLevelToChildren());
                    //update state
                    StateObjectManager som = new StateObjectManager(effect);
                    ce.AddEdit(som.ApplyStateToChildren());
                }
            }
            return(ce);
        }
Пример #3
0
        public IUndoableEdit AddEquivalenceClass(EquivalenceClass equivalenceClass)
        {
            if (testCase == null)
            {
                throw new Exception("The test case cannot be null");
            }
            CompoundEdit ce = new CompoundEdit();

            ce.AddEdit(EditFactory.instance.CreateAddEquivalenceClassEdit(testCase, equivalenceClass));
            testCase.AddEquivalenceClass(equivalenceClass);
            RiskLevelManager rlc = new RiskLevelManager(equivalenceClass);

            ce.AddEdit(rlc.ApplyRiskLevelToChildren());
            StateObjectManager som = new StateObjectManager(equivalenceClass);

            ce.AddEdit(som.ApplyStateToChildren());


            return(ce);
        }
        public IUndoableEdit ApplyRiskLevelToChildren()
        {
            if (riskLevelObject == null)
            {
                return(null);
            }
            CompoundEdit ce = new CompoundEdit();

            if (riskLevelObject.GetChildrenRiskLevels() == null)
            {
                return(ce);
            }
            foreach (IRiskLevelObject o in riskLevelObject.GetChildrenRiskLevels())
            {
                if (o.RiskLevel < riskLevelObject.RiskLevel)
                {
                    RiskLevelManager rlc = new RiskLevelManager(o);
                    ce.AddEdit(rlc.ChangeRiskLevel(riskLevelObject.RiskLevel));
                }
            }
            return(ce);
        }
        public IUndoableEdit ApplyRiskLevel(IRiskLevelObject riskObject, int newRiskLevel)
        {
            RiskLevelManager rlm = new RiskLevelManager(riskObject);

            return(rlm.ChangeRiskLevel(newRiskLevel));
        }