예제 #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);
        }
        /// <summary>
        /// Setup a <see cref="JsTreeNode"/> from a <c>DataflowBean</c>
        /// </summary>
        /// <param name="node">
        /// The <see cref="JsTreeNode"/>
        /// </param>
        /// <param name="artefact">
        /// The <c>DataflowBean</c>
        /// </param>
        protected static void SetupNode(JsTreeNode node, IDataflowObject artefact)
        {
            string entitle = artefact.Id;
            string format  = string.Format(CultureInfo.InvariantCulture, ArtefactFormat, entitle);

            SetupNode(node, artefact, entitle, format);
        }
        /// <summary>
        /// Setup a <see cref="JsTreeNode"/> from a <c>CodeBean</c>
        /// </summary>
        /// <param name="node">
        /// The <see cref="JsTreeNode"/>
        /// </param>
        /// <param name="artefact">
        /// The <c>CodeBean</c>
        /// </param>
        protected static void SetupNode(JsTreeNode node, ICode artefact)
        {
            string entitle = "[" + artefact.Id + "]";
            string format  = string.Format(CultureInfo.InvariantCulture, ArtefactFormat, entitle);

            SetupNode(node, artefact, entitle, format);
        }
예제 #4
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);
        }
예제 #5
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);
        }
예제 #6
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>
        /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c>
        /// </summary>
        /// <param name="node">
        /// The <see cref="JsTreeNode"/>
        /// </param>
        /// <param name="artefact">
        /// The <c>IdentifiableArtefactBean</c>
        /// </param>
        /// <param name="defaultString">
        /// The text to use in case there is no name or description
        /// </param>
        /// <param name="format">
        /// The format that will be used with <see cref="System.String.Format(string,object)"/> and artefact name or description
        /// </param>
        protected static void SetupNode(
            JsTreeNode node, INameableObject artefact, string defaultString, string format)
        {
            string lang = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;

            /*string result = TextTypeHelper.GetText(artefact.Names, lang);
             * string title = string.Format(CultureInfo.CurrentCulture, format, result.Length == 0 ? TextTypeHelper.GetText(artefact.Descriptions, lang) : result);
             * */
            string result;
            string title = "";

            if (string.IsNullOrEmpty(title))
            {
                title = defaultString;
            }

            ////Data data = new Data { title = title };
            ////node.data.Add(data);
            node.data = title;
        }
        /// <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);
                    }
                }
            }
        }
예제 #9
0
 /// <summary>
 /// Setup a <see cref="JsTreeNode"/> from a <c>DataflowBean</c>
 /// </summary>
 /// <param name="node">
 /// The <see cref="JsTreeNode"/>
 /// </param>
 /// <param name="artefact">
 /// The <c>DataflowBean</c>
 /// </param>
 protected static void SetupNode(JsTreeNode node, IDataflowObject artefact)
 {
     string entitle = artefact.Id;
     string format = string.Format(CultureInfo.InvariantCulture, ArtefactFormat, entitle);
     SetupNode(node, artefact, entitle, format);
 }
예제 #10
0
        /// <summary>
        /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c>
        /// </summary>
        /// <param name="node">
        /// The <see cref="JsTreeNode"/>
        /// </param>
        /// <param name="artefact">
        /// The <c>IdentifiableArtefactBean</c>
        /// </param>
        /// <param name="defaultString">
        /// The text to use in case there is no name or description
        /// </param>
        /// <param name="format">
        /// The format that will be used with <see cref="System.String.Format(string,object)"/> and artefact name or description
        /// </param>
        protected static void SetupNode(
            JsTreeNode node, INameableObject artefact, string defaultString, string format)
        {
            string lang = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
            /*string result = TextTypeHelper.GetText(artefact.Names, lang);
            string title = string.Format(CultureInfo.CurrentCulture, format, result.Length == 0 ? TextTypeHelper.GetText(artefact.Descriptions, lang) : result);
             * */
            string result;
            string title="";

            if (string.IsNullOrEmpty(title))
            {
                title = defaultString;
            }

            ////Data data = new Data { title = title };
            ////node.data.Add(data);
            node.data = title;
        }
        /// <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;
        }
예제 #12
0
 /// <summary>
 /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c>
 /// </summary>
 /// <param name="node">
 /// The <see cref="JsTreeNode"/>
 /// </param>
 /// <param name="artefact">
 /// The <c>IdentifiableArtefactBean</c>
 /// </param>
 protected static void SetupNode(JsTreeNode node, INameableObject artefact)
 {
     string entitle = artefact.Id;
     SetupNode(node, artefact, entitle, DefaultFormat1);
 }
예제 #13
0
        /// <summary>
        /// Create the categorised nodes, including the Categories and Dataflows
        /// </summary>
        /// <param name="categories">
        /// The list of CategorySchemes
        /// </param>
        /// <param name="categorisedDataflowIndex">
        /// A dictionary with a string with the format "Agency+Id+Version", <see cref="Utils.MakeKey(RefBean)"/> to DataflowBean map
        /// </param>
        /// <returns>
        /// The create categorised nodes.
        /// The tree with the categorized nodes
        /// </returns>
        private IEnumerable <JsTreeNode> CreateCategorisedNodes(
            IEnumerable <ICategorySchemeObject> categories, IDictionary <string, IDataflowObject> categorisedDataflowIndex)
        {
            int categoryCount       = 0;
            var categorySchemeNodes = new List <JsTreeNode>();
            var childToParent       = new Dictionary <JsTreeNode, JsTreeNode>();
            var leafCategories      = new Queue <JsTreeNode>();

            foreach (ICategorySchemeObject categoryScheme in categories)
            {
                JsTreeNode categorySchemeNode = CreateCategorySchemeNode(categoryScheme);
                categorySchemeNodes.Add(categorySchemeNode);
                var remainingCategoryNodes = new Stack <JsTreeNode>();
                var remainingCategories    = new Stack <ICategoryObject>();

                IList <ICategoryObject> categoriesWithAnnotation    = new List <ICategoryObject>();
                IList <ICategoryObject> categoriesWithoutAnnotation = new List <ICategoryObject>();

                /*foreach (var category in categoryScheme.Items)
                 * {
                 *  if (category.Annotations.Count > 0 && category.Annotations[0].FromAnnotation() == CustomAnnotationType.CategorySchemeNodeOrder)
                 *  {
                 *      categoriesWithAnnotation.Add(category);
                 *  }
                 *  else
                 *  {
                 *      categoriesWithoutAnnotation.Add(category);
                 *  }
                 * }*/

                IEnumerable <ICategoryObject> categoriesWithAnnotationOrderedBy = categoriesWithAnnotation.OrderBy(category => Convert.ToInt64(category.Annotations[0].ValueFromAnnotation()));

                IEnumerable <ICategoryObject> categoriesWithAndWithoutAnnotations = categoriesWithoutAnnotation.Concat(categoriesWithAnnotationOrderedBy);

                foreach (ICategoryObject c in categoriesWithAndWithoutAnnotations)
                {
                    JsTreeNode parent = CreateCategoryNode(c, ref categoryCount);

                    categorySchemeNode.children.Add(parent);
                    remainingCategoryNodes.Push(parent);
                    remainingCategories.Push(c);
                    childToParent.Add(parent, categorySchemeNode);
                }

                while (remainingCategoryNodes.Count > 0)
                {
                    JsTreeNode      currentNode     = remainingCategoryNodes.Pop();
                    ICategoryObject currentCategory = remainingCategories.Pop();

                    IList <ICategoryObject> categoriesParentWithAnnotation    = new List <ICategoryObject>();
                    IList <ICategoryObject> categoriesParentWithoutAnnotation = new List <ICategoryObject>();

                    foreach (var category in currentCategory.Items)
                    {
                        if (category.Annotations.Count > 0 && category.Annotations[0].FromAnnotation() == CustomAnnotationType.CategorySchemeNodeOrder)
                        {
                            categoriesParentWithAnnotation.Add(category);
                        }
                        else
                        {
                            categoriesParentWithoutAnnotation.Add(category);
                        }
                    }

                    IEnumerable <ICategoryObject> categoriesParentWithAnnotationOrderedBy = categoriesParentWithAnnotation.OrderBy(category => Convert.ToInt64(category.Annotations[0].ValueFromAnnotation()));

                    IEnumerable <ICategoryObject> categoriesParentWithAndWithoutAnnotations = categoriesParentWithoutAnnotation.Concat(categoriesParentWithAnnotationOrderedBy);

                    foreach (ICategoryObject cc in categoriesParentWithAndWithoutAnnotations)
                    {
                        JsTreeNode childNode = CreateCategoryNode(cc, ref categoryCount);
                        remainingCategoryNodes.Push(childNode);
                        remainingCategories.Push(cc);

                        currentNode.children.Add(childNode);
                        childToParent.Add(childNode, currentNode);
                    }

                    foreach (IMaintainableRefObject dataflowRef in GetDataFlows(currentCategory, _categorisations))
                    {
                        string          key = "";// Utils.MakeKey(dataflowRef);
                        IDataflowObject dataflow;
                        if (categorisedDataflowIndex.TryGetValue(key, out dataflow))
                        {
                            JsTreeNode dataflowNode = CreateDataflowNode(dataflow);
                            currentNode.children.Add(dataflowNode);
                        }
                    }

                    if (currentNode.children.Count == 0)
                    {
                        leafCategories.Enqueue(currentNode);
                    }
                }
            }

            while (leafCategories.Count > 0)
            {
                JsTreeNode current = leafCategories.Dequeue();
                JsTreeNode parent;
                if (childToParent.TryGetValue(current, out parent))
                {
                    parent.children.Remove(current);
                    if (parent.children.Count == 0)
                    {
                        leafCategories.Enqueue(parent);
                    }
                }
                else
                {
                    categorySchemeNodes.Remove(current);
                }
            }

            return(categorySchemeNodes);
        }
        /// <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;
        }
예제 #15
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>
        /// Setup a <see cref="JsTreeNode"/> from a <c>IdentifiableArtefactBean</c>
        /// </summary>
        /// <param name="node">
        /// The <see cref="JsTreeNode"/>
        /// </param>
        /// <param name="artefact">
        /// The <c>IdentifiableArtefactBean</c>
        /// </param>
        protected static void SetupNode(JsTreeNode node, INameableObject artefact)
        {
            string entitle = artefact.Id;

            SetupNode(node, artefact, entitle, DefaultFormat1);
        }
        /// <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;
        }
예제 #18
0
 /// <summary>
 /// Setup a <see cref="JsTreeNode"/> from a <c>CodeBean</c>
 /// </summary>
 /// <param name="node">
 /// The <see cref="JsTreeNode"/>
 /// </param>
 /// <param name="artefact">
 /// The <c>CodeBean</c>
 /// </param>
 protected static void SetupNode(JsTreeNode node, ICode artefact)
 {
     string entitle = "[" + artefact.Id + "]";
     string format = string.Format(CultureInfo.InvariantCulture, ArtefactFormat, entitle);
     SetupNode(node, artefact, entitle, format);
 }
        /// <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;
        }