protected void ProcessConnectorAttributeFlows()

in src/MIMConfigDocumenter/ConnectorDocumenter.cs [1681:1788]


        protected void ProcessConnectorAttributeFlows()
        {
            Logger.Instance.WriteMethodEntry();

            try
            {
                var sectionTitle = "Attribute Flows";

                Logger.Instance.WriteInfo("Processing " + sectionTitle + ".");

                this.WriteSectionHeader(sectionTitle, 3);

                var pilotConnectorId = ((string)this.PilotXml.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(true) + "/ma-data[name ='" + this.ConnectorName + "']/id") ?? string.Empty).ToUpperInvariant();
                var productionConnectorId = ((string)this.ProductionXml.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(false) + "/ma-data[name ='" + this.ConnectorName + "']/id") ?? string.Empty).ToUpperInvariant();

                var pilotImportFlowSetXPath = Documenter.GetMetaverseXmlRootXPath(true) + "/mv-data/import-attribute-flow/import-flow-set";
                var productionImportFlowSetXPath = Documenter.GetMetaverseXmlRootXPath(false) + "/mv-data/import-attribute-flow/import-flow-set";
                var pilotConnectorIdXPath = "translate(@src-ma, '" + Documenter.LowercaseLetters + "', '" + Documenter.UppercaseLetters + "') = '" + pilotConnectorId + "'";
                var productionConnectorIdXPath = "translate(@src-ma, '" + Documenter.LowercaseLetters + "', '" + Documenter.UppercaseLetters + "') = '" + productionConnectorId + "'";

                var pilotSourceObjectTypesXPath = pilotImportFlowSetXPath + "/import-flows/import-flow[" + pilotConnectorIdXPath + "]";
                var productionSourceObjectTypesXPath = productionImportFlowSetXPath + "/import-flows/import-flow[" + productionConnectorIdXPath + "]";
                var pilotMetaverseObjectTypesXPath = pilotImportFlowSetXPath + "[count(import-flows/import-flow[ " + pilotConnectorIdXPath + "]) != 0]";
                var productionMetaverseObjectTypesXPath = productionImportFlowSetXPath + "[count(import-flows/import-flow[ " + productionConnectorIdXPath + "]) != 0]";

                var pilotSourceObjectTypes = from importFlow in this.PilotXml.XPathSelectElements(pilotSourceObjectTypesXPath, Documenter.NamespaceManager)
                                             let sourceObjectType = (string)importFlow.Attribute("cd-object-type")
                                             select sourceObjectType;

                var pilotSourceObjectTypes2 = from exportFlowSet in this.PilotXml.XPathSelectElements(Documenter.GetConnectorXmlRootXPath(true) + "/ma-data[name ='" + this.ConnectorName + "']/export-attribute-flow/export-flow-set")
                                              let sourceObjectType = (string)exportFlowSet.Attribute("cd-object-type")
                                              select sourceObjectType;

                var productionSourceObjectTypes = from importFlow in this.ProductionXml.XPathSelectElements(productionSourceObjectTypesXPath, Documenter.NamespaceManager)
                                                  let sourceObjectType = (string)importFlow.Attribute("cd-object-type")
                                                  select sourceObjectType;

                var productionSourceObjectTypes2 = from exportFlowSet in this.ProductionXml.XPathSelectElements(Documenter.GetConnectorXmlRootXPath(false) + "/ma-data[name ='" + this.ConnectorName + "']/export-attribute-flow/export-flow-set")
                                                   let sourceObjectType = (string)exportFlowSet.Attribute("cd-object-type")
                                                   select sourceObjectType;

                var sourceObjectTypes = pilotSourceObjectTypes.Union(pilotSourceObjectTypes2).Union(productionSourceObjectTypes).Union(productionSourceObjectTypes2).Distinct().OrderBy(pilotSourceObjectType => pilotSourceObjectType);

                var pilotMetaverseObjectTypes = from importFlowSet in this.PilotXml.XPathSelectElements(pilotMetaverseObjectTypesXPath, Documenter.NamespaceManager)
                                                let metaverseObjectType = (string)importFlowSet.Attribute("mv-object-type")
                                                select metaverseObjectType;

                var pilotMetaverseObjectTypes2 = from exportFlowSet in this.PilotXml.XPathSelectElements(Documenter.GetConnectorXmlRootXPath(true) + "/ma-data[name ='" + this.ConnectorName + "']/export-attribute-flow/export-flow-set")
                                                 let metaverseObjectType = (string)exportFlowSet.Attribute("mv-object-type")
                                                 select metaverseObjectType;

                var productionMetaverseObjectTypes = from importFlowSet in this.ProductionXml.XPathSelectElements(productionMetaverseObjectTypesXPath, Documenter.NamespaceManager)
                                                     let name = (string)importFlowSet.Attribute("mv-object-type")
                                                     select name;

                var productionMetaverseObjectTypes2 = from exportFlowSet in this.ProductionXml.XPathSelectElements(Documenter.GetConnectorXmlRootXPath(false) + "/ma-data[name ='" + this.ConnectorName + "']/export-attribute-flow/export-flow-set")
                                                      let metaverseObjectType = (string)exportFlowSet.Attribute("mv-object-type")
                                                      select metaverseObjectType;

                var metaverseObjectTypes = pilotMetaverseObjectTypes.Union(pilotMetaverseObjectTypes2).Union(productionMetaverseObjectTypes).Union(productionMetaverseObjectTypes2).Distinct().OrderBy(metaverseObjectType => metaverseObjectType);

                var connectorHasFlowsConfigured = false;

                foreach (var sourceObjectType in sourceObjectTypes)
                {
                    this.currentDataSourceObjectType = sourceObjectType;

                    foreach (var metaverseObjectType in metaverseObjectTypes)
                    {
                        this.currentMetaverseObjectType = metaverseObjectType;

                        var pilotHasImportFlowsXPath = pilotImportFlowSetXPath + "[@mv-object-type = '" + this.currentMetaverseObjectType + "' and count(import-flows/import-flow[@cd-object-type = '" + this.currentDataSourceObjectType + "' and " + pilotConnectorIdXPath + "])]";
                        var productionHasImportFlowsXPath = productionImportFlowSetXPath + "[@mv-object-type = '" + this.currentMetaverseObjectType + "' and count(import-flows/import-flow[@cd-object-type = '" + this.currentDataSourceObjectType + "' and " + productionConnectorIdXPath + "])]";
                        var exportFlowsXPath = "/ma-data[name ='" + this.ConnectorName + "']/export-attribute-flow/export-flow-set[@mv-object-type = '" + this.currentMetaverseObjectType + "' and @cd-object-type = '" + this.currentDataSourceObjectType + "']/export-flow";

                        // Ignore the source object type and metaverse object type pair if there are no flows configured
                        var pilotHasImportFlows = this.PilotXml.XPathSelectElement(pilotHasImportFlowsXPath) != null;
                        var productionHasImportFlows = this.ProductionXml.XPathSelectElement(productionHasImportFlowsXPath) != null;
                        var pilotHasExportFlows = this.PilotXml.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(true) + exportFlowsXPath) != null;
                        var productionHasExportFlows = this.ProductionXml.XPathSelectElement(Documenter.GetConnectorXmlRootXPath(false) + exportFlowsXPath) != null;

                        if (!pilotHasImportFlows && !productionHasImportFlows && !pilotHasExportFlows && !productionHasExportFlows)
                        {
                            continue;
                        }

                        connectorHasFlowsConfigured = true;

                        var arrows = (pilotHasImportFlows || productionHasImportFlows ? "→" : string.Empty) + (pilotHasExportFlows || productionHasExportFlows ? "←" : string.Empty);
                        var sectionTitle2 = this.currentDataSourceObjectType + arrows + this.currentMetaverseObjectType;

                        this.WriteSectionHeader(sectionTitle2, 4);

                        this.ProcessConnectorObjectTypeImportAttributeFlows();
                        this.ProcessConnectorObjectTypeExportAttributeFlows();
                    }
                }

                if (!connectorHasFlowsConfigured)
                {
                    this.WriteContentParagraph("There are no attribute flows configured.");
                }
            }
            finally
            {
                Logger.Instance.WriteMethodExit();
            }
        }