From: <mcu...@us...> - 2010-04-14 06:53:50
|
Revision: 1438 http://orm.svn.sourceforge.net/orm/?rev=1438&view=rev Author: mcurland Date: 2010-04-14 06:53:40 +0000 (Wed, 14 Apr 2010) Log Message: ----------- * Fixed some verbalization cases with subtype navigation. refs #395 * Fixed crash changing a remote correlation target Modified Paths: -------------- trunk/ORMModel/ObjectModel/RolePath.cs trunk/ORMModel/ObjectModel/Verbalization.cs Modified: trunk/ORMModel/ObjectModel/RolePath.cs =================================================================== --- trunk/ORMModel/ObjectModel/RolePath.cs 2010-04-02 22:27:07 UTC (rev 1437) +++ trunk/ORMModel/ObjectModel/RolePath.cs 2010-04-14 06:53:40 UTC (rev 1438) @@ -1252,7 +1252,7 @@ private static void RemoteCorrelationRolePlayerChangedRule(RolePlayerChangedEventArgs e) { // This will always change within the same lead path. Just use the new role player. - AddDelayedPathValidation((RolePath)e.NewRolePlayer); + AddDelayedPathValidation(((PathedRole)e.NewRolePlayer).RolePath); } /// <summary> /// AddRule: typeof(RolePathOwner) Modified: trunk/ORMModel/ObjectModel/Verbalization.cs =================================================================== --- trunk/ORMModel/ObjectModel/Verbalization.cs 2010-04-02 22:27:07 UTC (rev 1437) +++ trunk/ORMModel/ObjectModel/Verbalization.cs 2010-04-14 06:53:40 UTC (rev 1438) @@ -4054,7 +4054,7 @@ /// the same set.</remarks> public bool AddCorrelatedVariable(RolePlayerVariable variable) { - if (myPrimaryVariable == variable) + if (myPrimaryVariable == variable || variable == null) { return false; } @@ -4298,6 +4298,18 @@ explicitParent = retVal.CorrelatingParent; } } + if (retVal.Role is SubtypeMetaRole && retVal.PathedRolePurpose == PathedRolePurpose.SameFactType) + { + foreach (PathedRole precedingPathedRole in GetPrecedingPathedRoles(retVal, false)) + { + // UNDONE: Consider supporting this pattern for negation as well. + if (precedingPathedRole.Role is SupertypeMetaRole && !retVal.IsNegated) + { + retVal = GetCorrelationRootPathedRole(precedingPathedRole); + } + break; + } + } return retVal; } /// <summary> @@ -6759,11 +6771,7 @@ useMap.TryGetValue(subtypePathedRole, out subtypeVariableUse)) { currentNode.Detach(ref headChildNode); - // Note that both variables are already registered, this just modifies the settings - // and adjust or adds the the join for the subtype variable. There is no need to remove - // other parts of the registered variable information. If there is a chained subtype, then - // the middle correlations steps will just be ignored. - RegisterRolePlayerUse(subtypePathedRole.Role.RolePlayer, supertypeVariableUse.PrimaryRolePlayerVariable, subtypePathedRole, null); + // Note that the variables are already correlated, all we need to do is pull the path. } } } @@ -7025,10 +7033,22 @@ RolePlayerVariableUse existingVariableUse; if (useMap.TryGetValue(usedFor, out existingVariableUse)) { - if (existingVariableUse.JoinedToVariable != joinToVariable) + if (joinToVariable != null && existingVariableUse.JoinedToVariable != joinToVariable) { existingVariableUse.JoinedToVariable = joinToVariable; - UpdateRolePlayerVariableUse(usedFor, existingVariableUse); + if (correlateWith == usedFor) + { + // Anything in the join should be in the head list as well + existingVariableUse.AddCorrelatedVariable(joinToVariable); + } + else if (correlateWith != null && correlationRootVariableUse.AddCorrelatedVariable(joinToVariable)) + { + if (correlationRootVariableUse.AddCorrelatedVariable(joinToVariable)) + { + useMap[correlateWith] = correlationRootVariableUse; + } + } + useMap[usedFor] = existingVariableUse; } } else @@ -7038,7 +7058,7 @@ if (addNewVariableToCorrelationRoot && correlationRootVariableUse.AddCorrelatedVariable(existingVariable)) { // An external variable was found that is not in the local correlation list - UpdateRolePlayerVariableUse(correlateWith, correlationRootVariableUse); + useMap[correlateWith] = correlationRootVariableUse; } } // Track use phase during registration to see if the root variable is @@ -7096,9 +7116,21 @@ { joinToVariable = null; } - if (existingVariableUse.JoinedToVariable != joinToVariable) + if (joinToVariable != null && existingVariableUse.JoinedToVariable != joinToVariable) { existingVariableUse.JoinedToVariable = joinToVariable; + if (correlateWith == usedFor) + { + // Anything in the join should be in the head list as well + existingVariableUse.AddCorrelatedVariable(joinToVariable); + } + else if (correlateWith != null && correlationRootVariableUse.AddCorrelatedVariable(joinToVariable)) + { + if (correlationRootVariableUse.AddCorrelatedVariable(joinToVariable)) + { + useMap[correlateWith] = correlationRootVariableUse; + } + } useMap[usedFor] = existingVariableUse; } } @@ -7138,7 +7170,7 @@ } if (addNewVariableToCorrelationRoot && existingVariable != null && correlationRootVariableUse.AddCorrelatedVariable(existingVariable)) { - UpdateRolePlayerVariableUse(correlateWith, correlationRootVariableUse); + useMap[correlateWith] = correlationRootVariableUse; } if (joinToVariable != null && joinedToExternalVariable && !existingVariable.IsExternalVariable) { @@ -7163,13 +7195,6 @@ return null; } /// <summary> - /// Update the <see cref="RolePlayerVariableUse"/> registered for a given key - /// </summary> - protected void UpdateRolePlayerVariableUse(object usedFor, RolePlayerVariableUse variableUse) - { - myUseToVariableMap[usedFor] = variableUse; - } - /// <summary> /// A chance for a subtype to add path projections using the /// <see cref="AddExternalVariable"/> method. /// </summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |