in src/MIMConfigDocumenter/MetaverseDocumenter.cs [326:487]
private void FillMetaverseObjectTypeDataSet(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 table2 = dataSet.Tables[1];
var attributes = config.XPathSelectElements(Documenter.GetMetaverseXmlRootXPath(pilotConfig) + "/mv-data//dsml:class[dsml:name = '" + this.currentObjectType + "' ]/dsml:attribute", Documenter.NamespaceManager);
// Sort by name
attributes = from attribute in attributes
let name = (string)attribute.Attribute("ref")
orderby name
select attribute;
for (var attributeIndex = 0; attributeIndex < attributes.Count(); ++attributeIndex)
{
var attribute = attributes.ElementAt(attributeIndex);
var attributeName = ((string)attribute.Attribute("ref") ?? string.Empty).Trim('#');
// Set Logger call context items
Logger.SetContextItem(MetaverseDocumenter.LoggerContextItemMetaverseAttribute, attributeName);
Logger.Instance.WriteInfo("Processing Attribute Information.");
var attributeInfo = config.XPathSelectElement(Documenter.GetMetaverseXmlRootXPath(pilotConfig) + "/mv-data//dsml:attribute-type[dsml:name = '" + attributeName + "']", Documenter.NamespaceManager);
var attributeSyntax = (string)attributeInfo.Element(Documenter.DsmlNamespace + "syntax");
var row = table.NewRow();
row[0] = attributeName;
row[1] = Documenter.GetAttributeType(attributeSyntax, (string)attributeInfo.Attribute(Documenter.MmsDsmlNamespace + "indexable"));
row[2] = ((string)attributeInfo.Attribute("single-value") ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase) ? "No" : "Yes";
row[3] = ((string)attributeInfo.Attribute(Documenter.MmsDsmlNamespace + "indexed") ?? string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase) ? "Yes" : "No";
Documenter.AddRow(table, row);
Logger.Instance.WriteVerbose("Processed Attribute Information.");
// Fetch Import Flows
var importFlowsXPath = Documenter.GetMetaverseXmlRootXPath(pilotConfig) + "/mv-data/import-attribute-flow/import-flow-set[@mv-object-type = '" + this.currentObjectType + "']/import-flows[@mv-attribute = '" + attributeName + "']";
var precedenceType = config.XPathSelectElement(importFlowsXPath) != null ? (string)config.XPathSelectElement(importFlowsXPath).Attribute("type") : string.Empty;
var importFlows = config.XPathSelectElements(importFlowsXPath + "/import-flow");
for (var importFlowIndex = 0; importFlowIndex < importFlows.Count(); ++importFlowIndex)
{
var importFlow = importFlows.ElementAt(importFlowIndex);
var row2 = table2.NewRow();
row2[0] = attributeName;
if (precedenceType.Equals("ranked", StringComparison.OrdinalIgnoreCase))
{
row2[1] = importFlowIndex + 1;
row2[2] = importFlowIndex + 1;
}
else
{
row2[1] = 1;
row2[2] = precedenceType;
}
var connectorId = ((string)importFlow.Attribute("src-ma") ?? string.Empty).ToUpperInvariant();
var connectorName = (string)config.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(pilotConfig) + "/ma-data[translate(id, '" + Documenter.LowercaseLetters + "', '" + Documenter.UppercaseLetters + "') = '" + connectorId + "']/name");
row2[3] = connectorName ?? connectorId;
var connectorObjectType = (string)importFlow.Attribute("cd-object-type");
row2[4] = connectorObjectType;
Logger.Instance.WriteVerbose("Processing Sync Rule Info for Connector: '{0}'.", connectorName);
var scopeExpression = string.Empty;
if (importFlow.XPathSelectElement("direct-mapping") != null)
{
row2[5] = (string)importFlow.XPathSelectElement("direct-mapping/src-attribute");
row2[6] = "Direct";
}
else if (importFlow.XPathSelectElement("scripted-mapping") != null)
{
var dataSourceAttribute = string.Empty;
foreach (var sourceAttribute in importFlow.XPathSelectElements("scripted-mapping/src-attribute"))
{
dataSourceAttribute += sourceAttribute + ",";
}
row2[5] = dataSourceAttribute.TrimEnd(',');
row2[6] = "Rules Extension - " + (string)importFlow.XPathSelectElement("scripted-mapping/script-context");
}
else if (importFlow.XPathSelectElement("constant-mapping") != null)
{
row2[5] = string.Empty;
row2[6] = "Constant - " + (string)importFlow.XPathSelectElement("constant-mapping/constant-value");
}
else if (importFlow.XPathSelectElement("dn-part--mapping") != null)
{
row2[5] = string.Empty;
row2[6] = "DN Component - ( " + (string)importFlow.XPathSelectElement("dn-part-mapping/dn-part") + " )";
}
else if (importFlow.XPathSelectElement("sync-rule-mapping") != null)
{
var mappingType = (string)importFlow.XPathSelectElement("sync-rule-mapping").Attribute("mapping-type") ?? string.Empty;
if (mappingType.Equals("direct", StringComparison.OrdinalIgnoreCase))
{
row2[5] = (string)importFlow.XPathSelectElement("sync-rule-mapping/src-attribute");
row2[6] = "Sync Rule - Direct";
}
else if (mappingType.Equals("constant", StringComparison.OrdinalIgnoreCase))
{
row2[5] = (string)importFlow.XPathSelectElement("sync-rule-mapping/sync-rule-value");
row2[6] = "Sync Rule - Constant";
}
else
{
var dataSourceAttribute = string.Empty;
foreach (var sourceAttribute in importFlow.XPathSelectElements("sync-rule-mapping/src-attribute"))
{
dataSourceAttribute += sourceAttribute + ",";
}
row2[5] = dataSourceAttribute.TrimEnd(',');
row2[6] = "Sync Rule - Expression"; // TODO: Print the Sync Rule Expression
}
var syncRuleId = (string)importFlow.XPathSelectElement("sync-rule-mapping").Attribute("sync-rule-id") ?? string.Empty;
var connector = config.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(pilotConfig) + "/ma-data[id ='" + connectorId + "']");
foreach (var scope in connector.XPathSelectElements("join/join-profile/join-criterion[@sync-rule-id='" + syncRuleId + "']/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);
}
}
row2[7] = scopeExpression;
row2[8] = connectorId;
Documenter.AddRow(table2, row2);
Logger.Instance.WriteVerbose("Processed Sync Rule Info for Connector: '{0}'.", connectorName);
}
}
table.AcceptChanges();
table2.AcceptChanges();
}
finally
{
Logger.Instance.WriteMethodExit("Pilot Config: '{0}'.", pilotConfig);
// Clear Logger call context items
Logger.ClearContextItem(MetaverseDocumenter.LoggerContextItemMetaverseAttribute);
}
}