Beispiel #1
0
        /// <summary>
        /// Gets path to a content grop
        /// </summary>
        /// <param name="containingClass">The containing class of the group.</param>
        /// <param name="oldVersion">The old version.</param>
        /// <returns>path to a content group</returns>
        private static XPathExpr GetXPathForContentGroup(PSMElement containingClass, Version oldVersion)
        {
            PSMElement groupElementOldVersion = (PSMElement)containingClass.GetInVersion(oldVersion);

            if (groupElementOldVersion != null)
            {
                return(groupElementOldVersion.XPathE());
            }
            else
            {
                return(GetXPathForAddedNode(containingClass, oldVersion).Append("/$cg"));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the X path for a node. If the node existed in the previous version, the old
        /// path is returned. For new nodes it returns the path to the closest ancestor
        /// that existed in the previous version.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="oldVersion">The old version.</param>
        /// <returns>xpath expression</returns>
        public static XPathExpr GetXPathForNode(PSMElement node, Version oldVersion)
        {
            PSMElement nodeOldVersion = (PSMElement)node.GetInVersion(oldVersion);

            if (nodeOldVersion != null)
            {
                return(nodeOldVersion.XPathE());
            }
            else
            {
                return(GetXPathForAddedNode(node, oldVersion));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Converts path to <paramref name="psmElementNewVersion"/>
        /// into a path relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ProcessedPath"/>.
        /// (and also relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ContentGroupPath"/> if it is used).
        /// If context is in group (<see cref="XsltGeneratorContext"/>.<see cref="XsltGeneratorContext.InGroup"/>) which
        /// has group attributes and <paramref name="psmElementNewVersion"/> is one of these attributes, the returned path
        /// is modified to use the '$attributes' variable.
        /// </summary>
        /// <param name="context">current generator context</param>
        /// <param name="psmElementNewVersion">element for which the path is projected</param>
        /// <param name="oldVersion">old version, used to determine the path to <paramref name="psmElementNewVersion"/> in the
        /// old version of the diagram</param>
        /// <returns>relative xpath expression</returns>
        public static XPathExpr GroupAwareProjectXPath(XsltGeneratorContext context, PSMElement psmElementNewVersion, Version oldVersion)
        {
            XPathExpr oldPath = ((PSMElement)psmElementNewVersion.GetInVersion(oldVersion)).XPathE();

            if (context.InGroup && oldPath.HasPrefix(context.ContentGroupPath))
            {
                oldPath = oldPath.InsertAfterPrefix(context.ContentGroupPath, "/$cg");
            }
            XPathExpr tmp = ProjectXPath(context.ProcessedPath, oldPath, context.InGroup);

            if (context.InGroup && context.ContentGroupAttributes != null && psmElementNewVersion is PSMAttribute &&
                context.ContentGroupAttributes.Contains((PSMAttribute)psmElementNewVersion))
            {
                if (tmp.ToString().StartsWith(XPathExpr.CurrentGroupVariableExpr))
                {
                    tmp = new XPathExpr(tmp.ToString().Replace(XPathExpr.CurrentGroupVariableExpr, "$attributes"));
                }
            }

            return(tmp);
        }
Beispiel #4
0
        private Dictionary <PSMElement, List <EvolutionChange> > GroupByTarget()
        {
            Dictionary <PSMElement, List <EvolutionChange> > groupChanges = GroupChanges(groupingFuncByTarget);

            foreach (IDoubleTargetChange doubleTargetChange in this.OfType <IDoubleTargetChange>())
            {
                PSMElement secondaryTarget = doubleTargetChange.SecondaryTarget;
                if (secondaryTarget != null)
                {
                    secondaryTarget = (PSMElement)secondaryTarget.GetInVersion(((EvolutionChange)doubleTargetChange).NewVersion);

                    if (secondaryTarget != null)
                    {
                        if (!groupChanges.ContainsKey(secondaryTarget))
                        {
                            groupChanges[secondaryTarget] = new List <EvolutionChange>();
                        }
                        groupChanges[secondaryTarget].Add((EvolutionChange)doubleTargetChange);
                    }
                }
            }
            return(groupChanges);
        }
Beispiel #5
0
        public bool ContinueInGroup(PSMElement node)
        {
            PSMElement elementOldVersion = (PSMElement)node.GetInVersion(OldVersion);

            return(elementOldVersion != null && IsUnderContentGroup(elementOldVersion));
        }