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 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 new static ChangeInstance CreateInstance(PSMComponent candidate, Version oldVersion, Version newVersion) { return(new ClassRenamedInstance(candidate, oldVersion, newVersion) { OldName = candidate.GetInVersion(oldVersion).Name, NewName = candidate.Name }); }
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)); }
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 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]); }
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 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) { 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) { PSMAttribute psmAttribute = (PSMAttribute)candidate; PSMAttribute psmAttributeO = (PSMAttribute)candidate.GetInVersion(oldVersion); return(ExistingTest(candidate, oldVersion, newVersion) && !AreLinked(psmAttributeO.PSMClass, psmAttribute.PSMClass)); }
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 }); }
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 }); }
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 }); }
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 }); }
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 }); }
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 }); }
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 }); }
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 }); }
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 }); }
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 }); }
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); } }
protected static bool AreLinked(PSMComponent componentOldVersion, PSMComponent componentNewVersion) { return(componentOldVersion != null && componentNewVersion != null && componentOldVersion.GetInVersion(componentNewVersion.Version) == componentNewVersion); }
public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion) { return(ExistingTest(candidate, oldVersion, newVersion) && candidate.Name != candidate.GetInVersion(oldVersion).Name); }
/* * 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)); } } }