in src/MIMConfigDocumenter/ConnectorDocumenter.cs [1574:1639]
protected void FillConnectorProjectionRulesDataSet(bool pilotConfig)
{
Logger.Instance.WriteMethodEntry("Pilot Config: '{0}'.", pilotConfig);
try
{
var config = pilotConfig ? this.PilotXml : this.ProductionXml;
var dataSet = pilotConfig ? this.PilotDataSet : this.ProductionDataSet;
var table = dataSet.Tables[0];
var connector = config.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(pilotConfig) + "/ma-data[name ='" + this.ConnectorName + "']");
if (connector != null)
{
var projectionRules = from projectionRule in connector.XPathSelectElements("projection/class-mapping")
let sourceObjectType = (string)projectionRule.Attribute("cd-object-type")
orderby sourceObjectType
select projectionRule;
if (projectionRules.Count() == 0)
{
return;
}
var projectionRuleIndex = 0; // This will be the relative rule number if there are more than one sync rule based projection rules.
var previoussourceObjectType = string.Empty;
foreach (var projectionRule in projectionRules)
{
var sourceObjectType = (string)projectionRule.Attribute("cd-object-type");
projectionRuleIndex = sourceObjectType == previoussourceObjectType ? projectionRuleIndex + 1 : 0;
previoussourceObjectType = sourceObjectType;
var projectionType = (string)projectionRule.Attribute("type") ?? string.Empty;
var scopeExpression = string.Empty;
if (projectionType.Equals("sync-rule", StringComparison.OrdinalIgnoreCase))
{
foreach (var scope in projectionRule.XPathSelectElements("scoping/scope"))
{
scopeExpression += string.Format(CultureInfo.InvariantCulture, "{0} {1} {2} AND ", (string)scope.Element("csAttribute"), (string)scope.Element("csOperator"), (string)scope.Element("csValue"));
}
if (scopeExpression.Length > 5)
{
scopeExpression = scopeExpression.Substring(0, scopeExpression.Length - " AND ".Length);
}
}
projectionType = projectionType.Equals("scripted", StringComparison.OrdinalIgnoreCase) ?
"Rules Extension" : projectionType.Equals("declared", StringComparison.OrdinalIgnoreCase) ?
"Declared" : projectionType.Equals("sync-rule", StringComparison.OrdinalIgnoreCase) ? string.IsNullOrEmpty(scopeExpression) ? "Sync Rule - Direct" : "Sync Rule - Scoped - " + scopeExpression : projectionType;
var metaverseObjectType = (string)projectionRule.Element("mv-object-type") ?? string.Empty;
Documenter.AddRow(table, new object[] { sourceObjectType + projectionRuleIndex, sourceObjectType, projectionType, metaverseObjectType });
}
table.AcceptChanges();
}
}
finally
{
Logger.Instance.WriteMethodExit("Pilot Config: '{0}'.", pilotConfig);
}
}