Esempio n. 1
0
        internal EContentPlacementState GetGroupState(ContentGroup currentContentGroup)
        {
            if (!changesByTarget.ContainsKey(currentContentGroup.ContainingClass))
            {
                return(EContentPlacementState.AsItWas);
            }
            Debug.Assert(!changesByTarget[currentContentGroup.ContainingClass].Any(c => c.EditType == EEditType.Removal));
            EContentPlacementState result = EContentPlacementState.AsItWas;

            EvolutionChange mc = changesByTarget[currentContentGroup.ContainingClass].FirstOrDefault(c => c.EditType == EEditType.Migratory);

            if (mc != null)
            {
                result = EContentPlacementState.Moved;
            }

            if (currentContentGroup.ContainingClass.GetInVersion(OldVersion) == null)
            {
                return(EContentPlacementState.Added);
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Ridi se podle ChagnesByTarget!
        /// </summary>
        /// <param name="contentComponent"></param>
        /// <returns></returns>
        internal EContentPlacementState GetState(PSMElement contentComponent)
        {
            if (!changesByTarget.ContainsKey(contentComponent))
            {
                if (!contentComponent.ExistsInVersion(OldVersion) && contentComponent.ExistsInVersion(NewVersion))
                {
                    return(EContentPlacementState.Added);
                }
                return(EContentPlacementState.AsItWas);
            }
            Debug.Assert(!changesByTarget[contentComponent].Any(c => c.EditType == EEditType.Removal));
            EContentPlacementState result = EContentPlacementState.AsItWas;

            EvolutionChange ac = changesByTarget[contentComponent]
                                 //.Where(c => c.Element == contentComponent || (c is ISubelementChange && ((ISubelementChange)c).ChangedSubelement == contentComponent))
                                 .FirstOrDefault(c => c.EditType == EEditType.Addition);

            if (ac != null)
            {
                result = EContentPlacementState.Added;
            }

            EvolutionChange mc = changesByTarget[contentComponent]
                                 //.Where(c => c.Element == contentComponent || (c is ISubelementChange && ((ISubelementChange)c).ChangedSubelement == contentComponent))
                                 .FirstOrDefault(c => c.EditType == EEditType.Migratory);

            if (mc != null)
            {
                result = EContentPlacementState.Moved;
            }

            EvolutionChange sc = changesByTarget[contentComponent]
                                 //.Where(c => c.Element == contentComponent || (c is ISubelementChange && ((ISubelementChange)c).ChangedSubelement == contentComponent))
                                 .FirstOrDefault(c => c.EditType == EEditType.Sedentary);

            if (result == EContentPlacementState.AsItWas && sc != null)
            {
                if (!(sc is IChangeWithEditTypeOverride) || sc.Element != contentComponent)
                {
                    result = EContentPlacementState.AsItWas;
                }
                else
                {
                    IChangeWithEditTypeOverride changeWithEditTypeOverride = ((IChangeWithEditTypeOverride)sc);
                    switch (changeWithEditTypeOverride.EditTypeOverride)
                    {
                    case EEditType.Addition:
                        result = EContentPlacementState.Added;
                        break;

                    case EEditType.Migratory:
                        result = EContentPlacementState.Moved;
                        break;

                    case EEditType.Sedentary:
                        result = EContentPlacementState.AsItWas;
                        break;

                    case EEditType.Removal:
                        result = EContentPlacementState.AsItWas;
                        break;
                    }
                }
            }
            return(result);
        }