public bool ExistsCardinalityChangeRequiringCreation(PSMComponent component) { bool requiresCreation, dummy2; ExistsCardinalityChange(component, out requiresCreation, out dummy2); return(requiresCreation); }
public bool ExistsCardinalityChangeRequiringDeletion(PSMComponent component) { bool dummy1, requiresDeletion; ExistsCardinalityChange(component, out dummy1, out requiresDeletion); return(requiresDeletion); }
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); }
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); }
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(); }
public override bool VerifyConsistency(object superordinateObject, object candidate) { PSMSchema psmSchema = (PSMSchema)superordinateObject; PSMComponent psmComponent = (PSMComponent)candidate; return(psmSchema.SchemaComponents.Contains(psmComponent)); }
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)); }
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)); } }
/// <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); } }
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]); }
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(); }
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); }
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; } }
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 }); }
private void CurrentParentAsRedNode(List <PSMComponent> redNodes, ChangeInstance changeInstance) { PSMComponent componentNewVersion = changeInstance is IExistingComponentChange ? (PSMComponent)((IExistingComponentChange)changeInstance).ComponentNewVersion : (PSMComponent)((IAdditionChange)changeInstance).ComponentNewVersion; CurrentParentAsRedNode(redNodes, componentNewVersion); }
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)); }
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)); }
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)); }
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)); }
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 }); }
public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion) { PSMClass psmClass = (PSMClass)candidate; return(new SRIntroducedInstance(candidate, oldVersion, newVersion) { RepresentedPSMClass = psmClass.RepresentedClass }); }
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 }); }
public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion) { PSMContentModel psmContentModel = ((PSMContentModel)candidate); return(new ContentModelAddedInstance(candidate, oldVersion, newVersion) { ParentAssociation = psmContentModel.ParentAssociation }); }
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)); }
public new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion) { PSMClass psmClass = ((PSMClass)candidate); return(new ClassAddedInstance(candidate, oldVersion, newVersion) { ParentAssociation = psmClass.ParentAssociation }); }
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 }); }
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); } }
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 }); }