Exemplo n.º 1
0
        /// <summary>
        /// Create a Dataflow Node
        /// </summary>
        /// <param name="dataflow">
        /// The SDMX Model Dataflow object
        /// </param>
        /// <returns>
        /// The Dataflow Node
        /// </returns>
        private JsTreeNode CreateDataflowNode(IDataflowObject dataflow)
        {
            var dataflowNode = new JsTreeNode();

            // dataflowNode.data.attributes.rel = MakeKey(dataflow);
            dataflowNode.SetId(Utils.MakeKey(dataflow).Replace('.', '_').Replace('+', '-'));
            SetupNode(dataflowNode, dataflow);
            IDataStructureObject dsd = NsiClientHelper.GetDsdFromDataflow(dataflow, _dataStructure);

            if (dsd != null && NsiClientHelper.DataflowDsdIsCrossSectional(dsd))
            {
                dataflowNode.SetRel("xs-dataflow");
            }
            else
            {
                dataflowNode.SetRel("dataflow");
            }
            dataflowNode.AddClass("dataflow-item");
            dataflowNode.SetLeaf(true);

            // dataflowNode.state = "closed";
            dataflowNode.metadata = new JSTreeMetadata
            {
                DataflowID      = dataflow.Id,
                DataflowVersion = dataflow.Version,
                DataflowAgency  = dataflow.AgencyId
            };

            // dataflowNode.metadata.dataflow_name = dataflow.PrimaryName;
            return(dataflowNode);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a CategoryScheme Node
        /// </summary>
        /// <param name="categoryScheme">
        /// The SDMX Model category scheme object
        /// </param>
        /// <returns>
        /// The CategoryScheme Node
        /// </returns>
        private static JsTreeNode CreateCategorySchemeNode(ICategorySchemeObject categoryScheme)
        {
            var categorySchemeNode = new JsTreeNode();

            // categorySchemeNode.data.attributes["rel"] = MakeKey(categoryScheme);
            categorySchemeNode.SetId(Utils.MakeKey(categoryScheme).Replace('.', '_'));

            // categorySchemeNode.data.icon = "folder";
            categorySchemeNode.SetRel("category-scheme");
            SetupNode(categorySchemeNode, categoryScheme);
            return(categorySchemeNode);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a Category Node
        /// </summary>
        /// <param name="category">
        /// The SDMX Model category  object
        /// </param>
        /// <param name="categoryCount">
        /// The caregory counter. This methods updates it
        /// </param>
        /// <returns>
        /// The Category Node
        /// </returns>
        private static JsTreeNode CreateCategoryNode(ICategoryObject category, ref int categoryCount)
        {
            var categoryNode = new JsTreeNode();

            // categoryNode.data.attributes["rel"] = category.Id;
            // categoryNode.SetId(category.Id);
            categoryNode.SetId(
                string.Format(
                    CultureInfo.InvariantCulture,
                    CategoryIdFormat,
                    categoryCount.ToString("x", CultureInfo.InvariantCulture)));
            categoryCount++;
            SetupNode(categoryNode, category);
            categoryNode.SetRel("category");
            return(categoryNode);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Build a JQuery plugin JSTree JSON_DATA json string. It uses the <see cref="_dataflows"/> and <see cref="_categories"/>
        /// </summary>
        /// <returns>
        /// A list of nodes
        /// </returns>
        private List <JsTreeNode> BuildJSTree()
        {
            this._prevCulture = Thread.CurrentThread.CurrentUICulture;
            var categorisedDataflowIndex = new Dictionary <string, IDataflowObject>();
            var uncategorisedDataflow    = new List <IDataflowObject>();
            var nodeList = new List <JsTreeNode>();

            foreach (IDataflowObject d in this._dataflows)
            {
                if (GetCategorisations(d, _categorisations).Count == 0)
                {
                    uncategorisedDataflow.Add(d);
                }
                else
                {
                    string key = Utils.MakeKey(d);
                    categorisedDataflowIndex.Add(key, d);
                }
            }


            nodeList.AddRange(CreateCategorisedNodes(this._categories, categorisedDataflowIndex));
            var uncategorisedNode = new JsTreeNode();

            //////var data = new Data();
            uncategorisedNode.SetRel("category-scheme");
            uncategorisedNode.SetId("uncategorised");

            ////data.title = Messages.text_dataflows_uncategorized;
            ////uncategorisedNode.data.Add(data);
            uncategorisedNode.data = Messages.text_dataflows_uncategorized;
            foreach (IDataflowObject dataflow in uncategorisedDataflow)
            {
                uncategorisedNode.children.Add(CreateDataflowNode(dataflow));
            }

            if (uncategorisedNode.children.Count > 0)
            {
                nodeList.Add(uncategorisedNode);
            }

            return(nodeList);
        }
        /// <summary>
        /// Build the  <see cref="_idNodeMap"/>
        /// </summary>
        private void BuildIdNodeMap()
        {
            this._idNodeMap.Clear();
            this._rootNodes.Clear();
            this._prevCulture = Thread.CurrentThread.CurrentUICulture;
            var needParent = new Queue <ICode>();

            foreach (ICode code in this._codeList.Items)
            {
                var node = new JsTreeNode();
                node.SetId(string.Format(CultureInfo.InvariantCulture, "{0}{1}", IDPrefix, code.Id));
                SetupNode(node, code);
                this._idNodeMap.Add(code, node);
                node.SetLeaf(true);
                if (!string.IsNullOrEmpty(code.ParentCode))
                {
                    needParent.Enqueue(code);
                }
                else
                {
                    this._rootNodes.Add(node);
                }
            }

            while (needParent.Count > 0)
            {
                ICode      code = needParent.Dequeue();
                JsTreeNode child;
                if (this._idNodeMap.TryGetValue(code, out child))
                {
                    var        parentCode = (ICode)this._codeList.GetCodeById(code.ParentCode);
                    JsTreeNode parent;
                    if (this._idNodeMap.TryGetValue(parentCode, out parent))
                    {
                        parent.state = JSTreeConstants.OpenState;
                        parent.SetLeaf(false);
                        parent.children.Add(child);
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Build the  <see cref="_idNodeMap"/>
        /// </summary>
        private void BuildIdNodeMap()
        {
            this._idNodeMap.Clear();
            this._rootNodes.Clear();
            this._prevCulture = Thread.CurrentThread.CurrentUICulture;
            var needParent = new Queue<ICode>();
            foreach (ICode code in this._codeList.Items)
            {
                var node = new JsTreeNode();
                node.SetId(string.Format(CultureInfo.InvariantCulture, "{0}{1}", IDPrefix, code.Id));
                SetupNode(node, code);
                this._idNodeMap.Add(code, node);
                node.SetLeaf(true);
                if (!string.IsNullOrEmpty(code.ParentCode))
                {
                    needParent.Enqueue(code);
                }
                else
                {
                    this._rootNodes.Add(node);
                }
            }

            while (needParent.Count > 0)
            {
                ICode code = needParent.Dequeue();
                JsTreeNode child;
                if (this._idNodeMap.TryGetValue(code, out child))
                {
                    var parentCode = (ICode)this._codeList.GetCodeById(code.ParentCode);
                    JsTreeNode parent;
                    if (this._idNodeMap.TryGetValue(parentCode, out parent))
                    {
                        parent.state = JSTreeConstants.OpenState;
                        parent.SetLeaf(false);
                        parent.children.Add(child);
                    }
                }
            }
        }
        /// <summary>
        /// Create a Dataflow Node
        /// </summary>
        /// <param name="dataflow">
        /// The SDMX Model Dataflow object
        /// </param>
        /// <returns>
        /// The Dataflow Node
        /// </returns>
        private JsTreeNode CreateDataflowNode(IDataflowObject dataflow)
        {
            var dataflowNode = new JsTreeNode();

            // dataflowNode.data.attributes.rel = MakeKey(dataflow);
            dataflowNode.SetId(Utils.MakeKey(dataflow).Replace('.', '_').Replace('+', '-'));
            SetupNode(dataflowNode, dataflow);
            IDataStructureObject dsd = NsiClientHelper.GetDsdFromDataflow(dataflow, _dataStructure);
            if (dsd != null && NsiClientHelper.DataflowDsdIsCrossSectional(dsd))
            {
                dataflowNode.SetRel("xs-dataflow");
            }
            else
            {
                dataflowNode.SetRel("dataflow");
            }
            dataflowNode.AddClass("dataflow-item");
            dataflowNode.SetLeaf(true);

            // dataflowNode.state = "closed";
            dataflowNode.metadata = new JSTreeMetadata
            {
                DataflowID = dataflow.Id,
                DataflowVersion = dataflow.Version,
                DataflowAgency = dataflow.AgencyId
            };

            // dataflowNode.metadata.dataflow_name = dataflow.PrimaryName;
            return dataflowNode;
        }
        /// <summary>
        /// Build a JQuery plugin JSTree JSON_DATA json string. It uses the <see cref="_dataflows"/> and <see cref="_categories"/>
        /// </summary>
        /// <returns>
        /// A list of nodes
        /// </returns>
        private List<JsTreeNode> BuildJSTree()
        {
            this._prevCulture = Thread.CurrentThread.CurrentUICulture;
            var categorisedDataflowIndex = new Dictionary<string, IDataflowObject>();
            var uncategorisedDataflow = new List<IDataflowObject>();
            var nodeList = new List<JsTreeNode>();

            foreach (IDataflowObject d in this._dataflows)
            {

                if (GetCategorisations(d, _categorisations).Count == 0)
                {
                    uncategorisedDataflow.Add(d);
                }
                else
                {
                    string key = Utils.MakeKey(d);
                    categorisedDataflowIndex.Add(key, d);
                }
            }

            nodeList.AddRange(CreateCategorisedNodes(this._categories, categorisedDataflowIndex));
            var uncategorisedNode = new JsTreeNode();

            //////var data = new Data();
            uncategorisedNode.SetRel("category-scheme");
            uncategorisedNode.SetId("uncategorised");

            ////data.title = Messages.text_dataflows_uncategorized;
            ////uncategorisedNode.data.Add(data);
            uncategorisedNode.data = Messages.text_dataflows_uncategorized;
            foreach (IDataflowObject dataflow in uncategorisedDataflow)
            {
                uncategorisedNode.children.Add(CreateDataflowNode(dataflow));
            }

            if (uncategorisedNode.children.Count > 0)
            {
                nodeList.Add(uncategorisedNode);
            }

            return nodeList;
        }
        /// <summary>
        /// Create a CategoryScheme Node
        /// </summary>
        /// <param name="categoryScheme">
        /// The SDMX Model category scheme object
        /// </param>
        /// <returns>
        /// The CategoryScheme Node
        /// </returns>
        private static JsTreeNode CreateCategorySchemeNode(ICategorySchemeObject categoryScheme)
        {
            var categorySchemeNode = new JsTreeNode();

            // categorySchemeNode.data.attributes["rel"] = MakeKey(categoryScheme);
            categorySchemeNode.SetId(Utils.MakeKey(categoryScheme).Replace('.', '_'));

            // categorySchemeNode.data.icon = "folder";
            categorySchemeNode.SetRel("category-scheme");
            SetupNode(categorySchemeNode, categoryScheme);
            return categorySchemeNode;
        }
        /// <summary>
        /// Create a Category Node
        /// </summary>
        /// <param name="category">
        /// The SDMX Model category  object
        /// </param>
        /// <param name="categoryCount">
        /// The caregory counter. This methods updates it
        /// </param>
        /// <returns>
        /// The Category Node
        /// </returns>
        private static JsTreeNode CreateCategoryNode(ICategoryObject category, ref int categoryCount)
        {
            var categoryNode = new JsTreeNode();

            // categoryNode.data.attributes["rel"] = category.Id;
            // categoryNode.SetId(category.Id);
            categoryNode.SetId(
                string.Format(
                    CultureInfo.InvariantCulture,
                    CategoryIdFormat,
                    categoryCount.ToString("x", CultureInfo.InvariantCulture)));
            categoryCount++;
            SetupNode(categoryNode, category);
            categoryNode.SetRel("category");
            return categoryNode;
        }