Esempio n. 1
0
        public bool ExistsCardinalityChangeRequiringCreation(PSMComponent component)
        {
            bool requiresCreation, dummy2;

            ExistsCardinalityChange(component, out requiresCreation, out dummy2);
            return(requiresCreation);
        }
Esempio n. 2
0
        public bool ExistsCardinalityChangeRequiringDeletion(PSMComponent component)
        {
            bool dummy1, requiresDeletion;

            ExistsCardinalityChange(component, out dummy1, out requiresDeletion);
            return(requiresDeletion);
        }
Esempio n. 3
0
        public string SuggestNameForInstanceGenerator(PSMComponent node, Template callingTemplate, TemplateReference reference)
        {
            string result;

            if (callingTemplate.AttributesTemplate)
            {
                result = SuggestNameForInstanceGenerator(node, attributesTemplate: true);
            }
            else if (callingTemplate.ElementsTemplate)
            {
                if (reference.ReferencesGroupNode)
                {
                    result = SuggestNameForInstanceGenerator(node, elementsTemplate: true);
                }
                else
                {
                    result = SuggestNameForInstanceGenerator(node, wrappingTemplate: true);
                }
            }
            else
            {
                throw new InvalidOperationException();
            }
            return(result);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public string SuggestName(PSMComponent node, bool complexType = false, bool attributeGroup = false, bool contentGroup = false, bool optGroup = false, bool attribute = false)
        {
            string nameBase = NormalizeTypeName(node);

            if (attributeGroup)
            {
                return(nameBase + "-att");
            }

            if (optGroup)
            {
                return(nameBase + "-att-opt");
            }

            if (contentGroup)
            {
                return(nameBase + "-elm");
            }

            if (complexType)
            {
                return(nameBase);
            }

            if (attribute)
            {
                return(nameBase);
            }

            throw new ArgumentException();
        }
Esempio n. 6
0
        public override bool VerifyConsistency(object superordinateObject, object candidate)
        {
            PSMSchema    psmSchema    = (PSMSchema)superordinateObject;
            PSMComponent psmComponent = (PSMComponent)candidate;

            return(psmSchema.SchemaComponents.Contains(psmComponent));
        }
Esempio n. 7
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);
        }
        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));
        }
Esempio n. 9
0
        public XPathExpr GetGroupMembers(PSMComponent component, bool useCurrentInstanceVariable)
        {
            List <PSMComponent> groupMembers = new List <PSMComponent>();

            AddGroupMembersRecursive(component, ref groupMembers);

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

            foreach (PSMComponent psmComponent in groupMembers)
            {
                if (!psmComponent.ExistsInVersion(this.OldVersion))
                {
                    continue;
                }
                result.Add(this.GetRelativeXPath(psmComponent, useCurrentInstanceVariable));
            }

            if (result.Count == 0)
            {
                return(new XPathExpr("()"));
            }
            else
            {
                return(XPathExpr.ConcatWithPipeOperator(result));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Normalizes the name of the type (replaces whitespaces with <see cref="WhitespaceReplacement"/>).
        /// </summary>
        /// <typeparam name="PSMComponent">Type of construct.</typeparam>
        /// <param name="element">The element whose name should be normalized.</param>
        /// <param name="nameGetter">The function (conviniently a lambda expression) that
        /// returns name for <paramref name="element"/>.</param>
        /// <returns></returns>
        public string NormalizeTypeName(PSMComponent element)
        {
            string typeName = element.Name;

            if (normalizationRegex == null)
            {
                normalizationRegex = new Regex("\\s", RegexOptions.CultureInvariant);
            }
            if (normalizationRegex.IsMatch(typeName))
            {
                string replace = normalizationRegex.Replace(typeName, WhitespaceReplacement);
                if (element is PSMAttribute)
                {
                    Log.AddWarning(string.Format("For the purpuses of Relax NG translation name of attribute '{0}' is treated as '{1}'.", element, replace));
                }
                else
                {
                    Log.AddWarning(string.Format("For the purpuses of Relax NG translation name of attribute '{0}' is treated as '{1}'.", element, replace));
                }
                return(replace);
            }
            else
            {
                return(typeName);
            }
        }
Esempio n. 11
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]);
        }
Esempio n. 12
0
        private RegularExpression RewriteDown(PSMComponent component)
        {
            if (component is PSMAssociation)
            {
                return(RewriteDownAssociation((PSMAssociation)component));
            }
            if (component is PSMAttribute)
            {
                return(RewriteDownAttribute((PSMAttribute)component));
            }
            if (component is PSMClass)
            {
                return(RewriteDownClass((PSMClass)component));
            }
            if (component is PSMContentModel)
            {
                switch (((PSMContentModel)component).Type)
                {
                case PSMContentModelType.Sequence:
                    return(RewriteDownSequenceCM((PSMContentModel)component));

                case PSMContentModelType.Choice:
                    return(RewriteDownChoiceCM((PSMContentModel)component));

                case PSMContentModelType.Set:
                    return(RewriteDownSetCM((PSMContentModel)component));

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            throw new NotImplementedException();
        }
Esempio n. 13
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);
        }
Esempio n. 14
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));
        }
 private void DisplayPSMComponent(PSMComponent psmComponent)
 {
     if (psmComponent != null)
     {
         if (psmComponent.Interpretation != null)
         {
             if (!string.IsNullOrEmpty(psmComponent.Interpretation.Name))
             {
                 lInterpreted.ToolTip = psmComponent.ToString();
                 lInterpreted.Text    = psmComponent.Interpretation.Name;
             }
             else
             {
                 lInterpreted.ToolTip = psmComponent.ToString();
                 lInterpreted.Text    = psmComponent.ToString();
             }
         }
         else
         {
             lInterpreted.ToolTip = string.Empty;
             lInterpreted.Text    = "(none)";
         }
         lInterpreted.DataContext  = psmComponent.Interpretation;
         spPSMComponent.Visibility = System.Windows.Visibility.Visible;
     }
     else
     {
         spPSMComponent.DataContext = null;
         spPSMComponent.Visibility  = System.Windows.Visibility.Hidden;
     }
 }
Esempio n. 16
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
     });
 }
Esempio n. 17
0
        private void CurrentParentAsRedNode(List <PSMComponent> redNodes, ChangeInstance changeInstance)
        {
            PSMComponent componentNewVersion = changeInstance is IExistingComponentChange ?
                                               (PSMComponent)((IExistingComponentChange)changeInstance).ComponentNewVersion :
                                               (PSMComponent)((IAdditionChange)changeInstance).ComponentNewVersion;

            CurrentParentAsRedNode(redNodes, componentNewVersion);
        }
Esempio n. 18
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));
        }
Esempio n. 19
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));
        }
Esempio n. 20
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));
        }
Esempio n. 21
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));
        }
Esempio n. 22
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAttribute psmAttribute = ((PSMAttribute)candidate);

            return(new AttributeAddedInstance(candidate, oldVersion, newVersion)
            {
                Parent = psmAttribute.PSMClass, Index = psmAttribute.Index
            });
        }
Esempio n. 23
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMClass psmClass = (PSMClass)candidate;

            return(new SRIntroducedInstance(candidate, oldVersion, newVersion)
            {
                RepresentedPSMClass = psmClass.RepresentedClass
            });
        }
Esempio n. 24
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMAssociation psmAssociation = ((PSMAssociation)candidate);

            return(new AssociationAddedInstance(candidate, oldVersion, newVersion)
            {
                Parent = psmAssociation.Parent, Index = psmAssociation.Index
            });
        }
Esempio n. 25
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMContentModel psmContentModel = ((PSMContentModel)candidate);

            return(new ContentModelAddedInstance(candidate, oldVersion, newVersion)
            {
                ParentAssociation = psmContentModel.ParentAssociation
            });
        }
Esempio n. 26
0
 public bool IsGroupNode(PSMComponent psmComponent)
 {
     return(psmComponent.DownCastSatisfies <PSMClass>(psmClass =>
                                                      psmClass.GetInVersion(OldVersion) != null &&
                                                      psmClass.GetInVersion(OldVersion).ParentAssociation != null &&
                                                      !psmClass.GetInVersion(OldVersion).ParentAssociation.IsNamed) ||
            psmComponent.DownCastSatisfies <PSMClass>(psmClass =>
                                                      IsAddedNode(psmClass) && psmClass.ParentAssociation != null && !psmClass.ParentAssociation.IsNamed));
 }
Esempio n. 27
0
        public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion)
        {
            PSMClass psmClass = ((PSMClass)candidate);

            return(new ClassAddedInstance(candidate, oldVersion, newVersion)
            {
                ParentAssociation = psmClass.ParentAssociation
            });
        }
Esempio n. 28
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
            });
        }
Esempio n. 29
0
        private void CurrentParentAsRedNode(List <PSMComponent> redNodes, PSMComponent componentNewVersion)
        {
            PSMComponent currentParent =
                componentNewVersion is PSMAssociation ? ((PSMAssociation)componentNewVersion).Parent : ModelIterator.GetPSMParent(componentNewVersion, true);

            if (currentParent != null)
            {
                redNodes.AddIfNotContained(currentParent);
            }
        }
Esempio n. 30
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
            });
        }