/// <summary> /// Fills the metaverse object type data set. /// </summary> /// <param name="pilotConfig">if set to <c>true</c>, the pilot configuration is loaded. Otherwise, the production configuration is loaded.</param> 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 table3 = dataSet.Tables[2]; var attributes = config.XPathSelectElements("//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("//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 Sync Rules var syncRules = config.XPathSelectElements("//synchronizationRule[targetObjectType = '" + this.currentObjectType + "' and direction = 'Inbound' " + Documenter.SyncRuleDisabledCondition + " and attribute-mappings/mapping/dest = '" + attributeName + "']"); syncRules = from syncRule in syncRules let precedence = (int)syncRule.Element("precedence") orderby precedence select syncRule; for (var syncRuleIndex = 0; syncRuleIndex < syncRules.Count(); ++syncRuleIndex) { var syncRule = syncRules.ElementAt(syncRuleIndex); var row2 = table2.NewRow(); row2[0] = attributeName; row2[1] = syncRuleIndex + 1; // Care only about the precedence relative rank here than actual value var connector = ((string)syncRule.Element("connector") ?? string.Empty).ToUpperInvariant(); var connectorName = (string)config.XPathSelectElement("//Connectors/ma-data[translate(id, '" + Documenter.LowercaseLetters + "', '" + Documenter.UppercaseLetters + "') = '" + connector + "']/name"); var syncRuleName = (string)syncRule.Element("name"); row2[2] = connectorName; row2[3] = syncRuleName; Logger.Instance.WriteVerbose("Processing Sync Rule Info for Connector: '{0}'. Sync Rule: '{1}'.", connectorName, syncRuleName); var mappingExpression = syncRule.XPathSelectElement("attribute-mappings/mapping[dest = '" + attributeName + "']/expression"); var mappingSourceAttribute = syncRule.XPathSelectElement("attribute-mappings/mapping[dest = '" + attributeName + "']/src/attr"); var mappingSource = syncRule.XPathSelectElement("attribute-mappings/mapping[dest = '" + attributeName + "']/src"); row2[4] = (string)mappingExpression ?? (string)mappingSourceAttribute ?? (string)mappingSource ?? "??"; row2[5] = connector; row2[6] = (string)syncRule.Element("id"); Documenter.AddRow(table2, row2); Logger.Instance.WriteVerbose("Processed Sync Rule Info for Connector: '{0}'. Sync Rule: '{1}'.", connectorName, syncRuleName); // Fetch Sync Rule Scoping Conditions var conditions = syncRule.XPathSelectElements("synchronizationCriteria/conditions"); for (var conditionIndex = 0; conditionIndex < conditions.Count(); ++conditionIndex) { Logger.Instance.WriteVerbose("Processing Sync Rule Scope for Connector: '{0}'. Sync Rule: '{1}'.", connectorName, syncRuleName); var condition = conditions.ElementAt(conditionIndex); var scopes = condition.Elements("scope"); for (var scopeIndex = 0; scopeIndex < scopes.Count(); ++scopeIndex) { var scope = scopes.ElementAt(scopeIndex); var row3 = table3.NewRow(); row3[0] = attributeName; row3[1] = connectorName; row3[2] = syncRuleName; row3[3] = conditionIndex; row3[4] = scopeIndex; row3[5] = (string)scope.Element("csAttribute"); row3[6] = (string)scope.Element("csOperator"); row3[7] = (string)scope.Element("csValue"); row3[8] = connector; row3[9] = (string)syncRule.Element("id"); Documenter.AddRow(table3, row3); } Logger.Instance.WriteVerbose("Processed Sync Rule Scope for Connector: '{0}'. Sync Rule: '{1}'.", connectorName, syncRuleName); } } } table.AcceptChanges(); table2.AcceptChanges(); table3.AcceptChanges(); } finally { Logger.Instance.WriteMethodExit("Pilot Config: '{0}'.", pilotConfig); // Clear Logger call context items Logger.ClearContextItem(MetaverseDocumenter.LoggerContextItemMetaverseAttribute); } }