コード例 #1
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAssociation psmAssociation  = (PSMAssociation)candidate;
            PSMAssociation psmAssociationO = (PSMAssociation)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) && (psmAssociation.Lower != psmAssociationO.Lower || psmAssociation.Upper != psmAssociationO.Upper));
        }
コード例 #2
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) && psmContentModel.Type != psmContentModelO.Type);
        }
コード例 #3
0
 public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
 {
     return(new ClassRenamedInstance(candidate, oldVersion, newVersion)
     {
         OldName = candidate.GetInVersion(oldVersion).Name, NewName = candidate.Name
     });
 }
コード例 #4
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) && psmAttribute.AttributeType != psmAttributeO.AttributeType);
        }
コード例 #5
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) && (psmAttribute.Lower != psmAttributeO.Lower || psmAttribute.Upper != psmAttributeO.Upper));
        }
コード例 #6
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMClass psmClass  = (PSMClass)candidate;
            PSMClass psmClassO = (PSMClass)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) && psmClassO.IsStructuralRepresentative && !psmClass.IsStructuralRepresentative);
        }
コード例 #7
0
        public XPathExpr GetGroupDistinguisher(PSMComponent component)
        {
            List <PSMComponent> groupMembers = new List <PSMComponent>();

            AddGroupMembersRecursive(component, ref groupMembers);
            List <PSMComponent> oldMembers = new List <PSMComponent>();

            AddGroupMembersRecursive(component.GetInVersion(this.OldVersion), ref oldMembers);

            List <XPathExpr> result = new List <XPathExpr>();

            foreach (PSMComponent psmComponent in oldMembers)
            {
                if (!psmComponent.ExistsInVersion(this.NewVersion))
                {
                    continue;
                }

                PSMComponent comp        = psmComponent.GetFirstAncestorOrSelfExistingInVersion(this.OldVersion).GetInVersion(this.OldVersion);
                int          lastIndexOf = comp.XPath.LastIndexOf("/");
                string       expression  = lastIndexOf > -1 ? comp.XPath.Substring(lastIndexOf + 1) : comp.XPath;
                result.Add(new XPathExpr(expression));
            }

            return(result[0]);
        }
コード例 #8
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAssociation psmAssociation  = (PSMAssociation)candidate;
            PSMAssociation psmAssociationO = (PSMAssociation)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) &&
                   !AreLinked(psmAssociationO.Parent, psmAssociation.Parent));
        }
コード例 #9
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) &&
                   !AreLinked(psmContentModelO.ParentAssociation, psmContentModel.ParentAssociation));
        }
コード例 #10
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMClass psmClass  = (PSMClass)candidate;
            PSMClass psmClassO = (PSMClass)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) &&
                   !AreLinked(psmClassO.ParentAssociation, psmClass.ParentAssociation));
        }
コード例 #11
0
        public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(ExistingTest(candidate, oldVersion, newVersion) &&
                   !AreLinked(psmAttributeO.PSMClass, psmAttribute.PSMClass));
        }
コード例 #12
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMClass psmClassO = (PSMClass)candidate.GetInVersion(oldVersion);

            return(new SRRemovedInstance(candidate, oldVersion, newVersion)
            {
                OldRepresentedPSMClass = psmClassO.RepresentedClass
            });
        }
コード例 #13
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAssociation psmAssociation  = (PSMAssociation)candidate;
            PSMAssociation psmAssociationO = (PSMAssociation)candidate.GetInVersion(oldVersion);

            return(new AssociationIndexChangedInstance(candidate, oldVersion, newVersion)
            {
                OldIndex = psmAssociationO.Index,
                NewIndex = psmAssociation.Index
            });
        }
コード例 #14
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(new ContentModelMovedInstance(candidate, oldVersion, newVersion)
            {
                NewParentAssociation = psmContentModel.ParentAssociation,
                OldParentAssociation = psmContentModelO.ParentAssociation
            });
        }
コード例 #15
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(new AttributeTypeChangedInstance(candidate, oldVersion, newVersion)
            {
                OldType = psmAttributeO.AttributeType,
                NewType = psmAttribute.AttributeType
            });
        }
コード例 #16
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(new AttributeXFormChangedInstance(candidate, oldVersion, newVersion)
            {
                OldXFormElement = psmAttributeO.Element,
                NewXFormElement = psmAttribute.Element
            });
        }
コード例 #17
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel  = (PSMContentModel)candidate;
            PSMContentModel psmContentModelO = (PSMContentModel)candidate.GetInVersion(oldVersion);

            return(new ContentModelTypeChangedInstance(candidate, oldVersion, newVersion)
            {
                OldType = psmContentModelO.Type,
                NewType = psmContentModel.Type
            });
        }
コード例 #18
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMClass psmClass  = (PSMClass)candidate;
            PSMClass psmClassO = (PSMClass)candidate.GetInVersion(oldVersion);

            return(new ClassMovedInstance(candidate, oldVersion, newVersion)
            {
                NewParentAssociation = psmClass.ParentAssociation,
                OldParentAssociation = psmClassO.ParentAssociation
            });
        }
コード例 #19
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(new AttributeMovedInstance(candidate, oldVersion, newVersion)
            {
                NewParent = psmAttribute.PSMClass,
                OldParent = psmAttributeO.PSMClass,
                NewIndex = psmAttribute.Index,
                OldIndex = psmAttributeO.Index
            });
        }
コード例 #20
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute  = (PSMAttribute)candidate;
            PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion);

            return(new AttributeCardinalityChangedInstance(candidate, oldVersion, newVersion)
            {
                OldLower = psmAttributeO.Lower,
                OldUpper = psmAttributeO.Upper,
                NewLower = psmAttribute.Lower,
                NewUpper = psmAttribute.Upper
            });
        }
コード例 #21
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAssociation psmAssociation  = (PSMAssociation)candidate;
            PSMAssociation psmAssociationO = (PSMAssociation)candidate.GetInVersion(oldVersion);

            return(new AssociationCardinalityChangedInstance(candidate, oldVersion, newVersion)
            {
                OldLower = psmAssociationO.Lower,
                OldUpper = psmAssociationO.Upper,
                NewLower = psmAssociation.Lower,
                NewUpper = psmAssociation.Upper
            });
        }
コード例 #22
0
        private void FormerParentAsRedNode(List <PSMComponent> redNodes, ChangeInstance changeInstance)
        {
            PSMComponent componentOldVersion = changeInstance is IExistingComponentChange ?
                                               (PSMComponent)((IExistingComponentChange)changeInstance).ComponentOldVersion :
                                               (PSMComponent)((IRemovalChange)changeInstance).ComponentOldVersion;

            PSMComponent formerParent =
                componentOldVersion is PSMAssociation ? ((PSMAssociation)componentOldVersion).Parent : ModelIterator.GetPSMParent(componentOldVersion, true);

            PSMComponent formerParentNewVersion = formerParent.GetInVersion(changeInstance.NewVersion);

            if (formerParentNewVersion != null)
            {
                redNodes.AddIfNotContained(formerParentNewVersion);
            }
        }
コード例 #23
0
ファイル: ChangeInstance.cs プロジェクト: mff-uk/exolutio
 protected static bool AreLinked(PSMComponent componentOldVersion, PSMComponent componentNewVersion)
 {
     return(componentOldVersion != null && componentNewVersion != null &&
            componentOldVersion.GetInVersion(componentNewVersion.Version) == componentNewVersion);
 }
コード例 #24
0
 public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion)
 {
     return(ExistingTest(candidate, oldVersion, newVersion) && candidate.Name != candidate.GetInVersion(oldVersion).Name);
 }
コード例 #25
0
        /*
         * useCurrentInstanceVariable is probably always false in the current version of the algorithm.
         */

        public XPathExpr GetRelativeXPath(PSMComponent node, bool useCurrentInstanceVariable, string currentInstanceVariableName = XDocumentXsltExtensions.ParamCurrentInstance)
        {
            PSMComponent closestExistingCurrentNode = CurrentNode.GetFirstAncestorOrSelfExistingInVersion(OldVersion).GetInVersion(OldVersion);
            PSMComponent closestExistingTargetNode  = node.GetFirstAncestorOrSelfExistingInVersion(OldVersion).GetInVersion(OldVersion);

            if (closestExistingTargetNode == null)
            {
                throw new InvalidOperationException();
            }

            if (closestExistingCurrentNode == null)
            {
                return(new XPathExpr(closestExistingTargetNode.XPath));
            }

            XPathExpr currentNodeAbsoluteXPath = new XPathExpr(closestExistingCurrentNode.GetInVersion(OldVersion).XPath);
            // /A/R
            XPathExpr targetNodeAbsoluteXPath = new XPathExpr(closestExistingTargetNode.GetInVersion(OldVersion).XPath);

            // /A/R/B/z

            if (targetNodeAbsoluteXPath.HasPrefix(currentNodeAbsoluteXPath) && targetNodeAbsoluteXPath != currentNodeAbsoluteXPath)
            {
                string withoutPrefix = targetNodeAbsoluteXPath.ToString().Substring(currentNodeAbsoluteXPath.ToString().Length);
                while (withoutPrefix[0].IsAmong('/', '@'))
                {
                    withoutPrefix = withoutPrefix.Substring(1);
                }

                string nextStep;
                if (withoutPrefix.IndexOf('/') == -1)
                {
                    nextStep = withoutPrefix.Substring(0, withoutPrefix.Length);
                }
                else
                {
                    nextStep = withoutPrefix.Substring(0, withoutPrefix.IndexOf('/'));
                }

                string afterNextStep = withoutPrefix.Substring(nextStep.Length);

                XPathExpr result;

                if (useCurrentInstanceVariable)
                {
                    result = new XPathExpr(string.Format("${3}[name() = '{0}']{1}{2}", nextStep, string.IsNullOrEmpty(afterNextStep) ? string.Empty : "/", afterNextStep, currentInstanceVariableName));
                }
                else
                {
                    result = new XPathExpr(string.Format("{0}{1}{2}", nextStep, string.IsNullOrEmpty(afterNextStep) ? string.Empty : "/", afterNextStep));
                }

                return(result);
            }
            else if (targetNodeAbsoluteXPath == currentNodeAbsoluteXPath)
            {
                return(new XPathExpr("."));
            }
            else
            {
                // find the uppermost common node
                PSMAssociationMember nearestCommonAncestor = closestExistingCurrentNode.GetNearestCommonAncestor(closestExistingTargetNode);
                if (nearestCommonAncestor != null)
                {
                    string commonPath = nearestCommonAncestor.XPath;
                    Debug.Assert(targetNodeAbsoluteXPath.HasPrefix(new XPathExpr(commonPath)));
                    Debug.Assert(currentNodeAbsoluteXPath.HasPrefix(new XPathExpr(commonPath)));
                    string fromCommonToTarget  = targetNodeAbsoluteXPath.ToString().Replace(commonPath, string.Empty);
                    string fromCommonToCurrent = currentNodeAbsoluteXPath.ToString().Replace(commonPath, string.Empty);
                    string stepsUp             = string.Empty;

                    foreach (char c in fromCommonToCurrent)
                    {
                        if (c == '/')
                        {
                            stepsUp += "../";
                        }
                    }

                    if (fromCommonToTarget.StartsWith("/"))
                    {
                        fromCommonToTarget = fromCommonToTarget.Substring(1);
                    }


                    string joined = string.Format("{0}{1}", stepsUp, fromCommonToTarget);
                    if (joined.EndsWith("/"))
                    {
                        joined = joined.Substring(0, joined.Length - 1);
                    }
                    return(new XPathExpr(joined));
                }
                else
                {
                    return(new XPathExpr(closestExistingTargetNode.XPath));
                }
            }
        }