/// <summary> /// Create a CategoryScheme Node /// </summary> /// <param name="categoryScheme"> /// The SDMX Model category scheme object /// </param> /// <returns> /// The CategoryScheme Node /// </returns> private JsTreeNode CreateCategorySchemeNode(ICategorySchemeObject categoryScheme, string TwoLetterISO) { var categorySchemeNode = new JsTreeNode(); // categorySchemeNode.data.attributes["rel"] = MakeKey(categoryScheme); categorySchemeNode.SetId(Utils.MakeKey(categoryScheme).Replace('.', '_')); // categorySchemeNode.data.icon = "folder"; categorySchemeNode.SetRel("category-scheme"); categorySchemeNode.type = "category-scheme"; categorySchemeNode.AddClass("category-scheme"); SetupNode(categorySchemeNode, categoryScheme, TwoLetterISO); return(categorySchemeNode); }
private List <JsTreeNode> BuildJSTree(ISdmxObjects SdmxOBJ, string TwoLetterISO) { var categorisedDataflowIndex = new Dictionary <string, IDataflowObject>(); var uncategorisedDataflow = new List <IDataflowObject>(); var nodeList = new List <JsTreeNode>(); // for each dataflows control if has a categorization // if true put it in dataflow list or in uncategorizate list foreach (IDataflowObject d in SdmxOBJ.Dataflows) { if (!d.IsExternalReference.IsTrue && SdmxOBJ.Categorisations.Count(cat => !cat.IsExternalReference.IsTrue && cat.StructureReference.TargetReference.EnumType == d.StructureType.EnumType && MaintainableUtil <IMaintainableObject> .Match(d, cat.StructureReference)) == 0) { uncategorisedDataflow.Add(d); } else { categorisedDataflowIndex.Add(Utils.MakeKey(d), d); } } nodeList.AddRange(CreateCategorisedNodes(SdmxOBJ, categorisedDataflowIndex, TwoLetterISO)); if (TreeObj.Configuration.UseUncategorysed) { var uncategorisedNode = new JsTreeNode(); uncategorisedNode.SetRel("category-scheme"); uncategorisedNode.type = "category-scheme"; uncategorisedNode.SetId("uncategorised"); uncategorisedNode.text = Messages.text_dataflows_uncategorized; foreach (IDataflowObject dataflow in uncategorisedDataflow) { JsTreeNode node = CreateDataflowNode(dataflow, SdmxOBJ, TwoLetterISO); if (node != null) { uncategorisedNode.children.Add(node); } } if (uncategorisedNode.children.Count > 0) { nodeList.Add(uncategorisedNode); } } return(nodeList); }
private JsTreeNode CreateDataflowNode( string dataflow_id, string dataflow_version, string dataflow_agency, string dataflow_title, string dataflow_url_v20, string dataflow_url_v21, string dataflow_type, string dataflow_source, string dataflow_decimalCulture, List <string> dataflow_desc, List <DataflowMetaUrl> dataflow_url) { var dataflowNode = new JsTreeNode(); dataflowNode.SetId(dataflow_id); dataflowNode.text = dataflow_title; dataflowNode.SetRel("virtual-dataflow"); dataflowNode.type = "virtual-dataflow"; dataflowNode.li_attr.Add("title", dataflow_title); dataflowNode.a_attr = new JSTreeMetadata { DataflowID = dataflow_id, DataflowVersion = dataflow_version, DataflowAgency = dataflow_agency, DataflowUrl = dataflow_url_v21, DataflowUrlV20 = dataflow_url_v20, DataflowUrlType = dataflow_type, DataflowSource = dataflow_source, DataflowDecimalCulture = dataflow_decimalCulture, DataflowName = dataflow_title, DataflowDesc = new JavaScriptSerializer().Serialize(dataflow_desc), DataflowUrls = new JavaScriptSerializer().Serialize(dataflow_url) }; return(dataflowNode); }
/// <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; }
/// <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, ISdmxObjects SdmxOBJ, string TwoLetterISO) { var dataflowNode = new JsTreeNode(); if (dataflow.HasAnnotationType(VirtualDataflowTypeEpAnn)) { // VIrtual DF var vrtDf = dataflow.GetAnnotationsByType(VirtualDataflowTypeEpAnn); var value = TextTypeHelper.GetText(vrtDf.FirstOrDefault().Text, TwoLetterISO); string end_key = "@"; string search_key = string.Empty; search_key = "@EP1="; string endpoint_1 = value.Substring(value.IndexOf(search_key) + search_key.Length); endpoint_1 = endpoint_1.Substring(0, endpoint_1.IndexOf(end_key)); search_key = "@EP2="; string endpoint_2 = value.Substring(value.IndexOf(search_key) + search_key.Length); endpoint_2 = endpoint_2.Substring(0, endpoint_2.IndexOf(end_key)); search_key = "@EPT="; string endpoint_type = value.Substring(value.IndexOf(search_key) + search_key.Length); endpoint_type = endpoint_type.Substring(0, endpoint_type.IndexOf(end_key)); search_key = "@SOURCE="; string dataflow_source = value.Substring(value.IndexOf(search_key) + search_key.Length); dataflow_source = dataflow_source.Substring(0, dataflow_source.IndexOf(end_key)); search_key = "@SEP="; string decimal_separator = ""; if (value.IndexOf(search_key) != -1) { decimal_separator = value.Substring(value.IndexOf(search_key) + search_key.Length); decimal_separator = decimal_separator.Substring(0, decimal_separator.IndexOf(end_key)); } else { decimal_separator = TreeObj.Configuration.DecimalSeparator; } //fabio forzo il sep prova debug del separatore decimale //if (dataflow.Id == "PARAS") { decimal_separator = ","; } List <string> valueDesc = new List <string>(); if (dataflow.HasAnnotationType(VirtualDataflowTypeDescAnn)) { var vrtDfDesc = dataflow.GetAnnotationsByType(VirtualDataflowTypeDescAnn); foreach (var ann in vrtDfDesc) { valueDesc.Add(TextTypeHelper.GetText(ann.Text, TwoLetterISO)); } } List <DataflowMetaUrl> valueUrls = new List <DataflowMetaUrl>(); if (dataflow.HasAnnotationType(VirtualDataflowTypeUrlAnn)) { var vrtDfUrls = dataflow.GetAnnotationsByType(VirtualDataflowTypeUrlAnn); foreach (var ann in vrtDfUrls) { valueUrls.Add(new DataflowMetaUrl() { Title = TextTypeHelper.GetText(ann.Text, TwoLetterISO), URL = ann.Title }); } } dataflowNode = CreateDataflowNode( dataflow.Id, dataflow.Version, dataflow.AgencyId, TextTypeHelper.GetText(dataflow.Names, TwoLetterISO), endpoint_1, endpoint_2, endpoint_type, dataflow_source, decimal_separator, valueDesc, valueUrls); } else { // Normal DF dataflowNode.SetId(Utils.MakeKey(dataflow).Replace('.', '_').Replace('+', '-')); SetupNode(dataflowNode, dataflow, TwoLetterISO); IDataStructureObject dsd = SdmxOBJ.DataStructures.FirstOrDefault( dataStructure => dataflow.DataStructureRef.Equals(dataStructure.AsReference)); if (dsd != null && dsd is ICrossSectionalDataStructureObject) { dataflowNode.SetRel("xs-dataflow"); dataflowNode.type = "xs-dataflow"; } else { dataflowNode.SetRel("dataflow"); dataflowNode.type = "dataflow"; } dataflowNode.li_attr.Add("title", TreeObj.Configuration.Title); dataflowNode.a_attr = new JSTreeMetadata { DataflowID = dataflow.Id, DataflowVersion = dataflow.Version, DataflowAgency = dataflow.AgencyId, DataflowUrl = TreeObj.Configuration.EndPoint, DataflowUrlV20 = TreeObj.Configuration.EndPointV20, DataflowUrlType = TreeObj.Configuration.EndPointType, DataflowSource = TreeObj.Configuration.EndPointSource, DataflowDecimalCulture = TreeObj.Configuration.DecimalSeparator, }; } return(dataflowNode); }
private JsTreeNode CreateCategoryNode( ICategoryObject category, ref int categoryCount, string TwoLetterISO) { var categoryNode = new JsTreeNode(); categoryNode.SetId( string.Format( CultureInfo.InvariantCulture, CategoryIdFormat, categoryCount.ToString("x", CultureInfo.InvariantCulture))); categoryCount++; SetupNode(categoryNode, category, TwoLetterISO); categoryNode.SetRel("category"); categoryNode.type = "category"; //if (TreeObj.Configuration.UseVirtualDf // && category.HasAnnotationType(VirtualDataflowTypeAnn)) //{ // var vrtDf = category.GetAnnotationsByType(VirtualDataflowTypeAnn); // var value = TextTypeHelper.GetText(vrtDf.FirstOrDefault().Text,TwoLetterISO); // string end_key = "@"; // string search_key = string.Empty; // search_key = "@TITOLO="; // string title = value.Substring(value.IndexOf(search_key) + search_key.Length); // title = title.Substring(0,title.IndexOf(end_key)); // search_key = "@EP1="; // string endpoint_1 = value.Substring(value.IndexOf(search_key) + search_key.Length); // endpoint_1 = endpoint_1.Substring(0, endpoint_1.IndexOf(end_key)); // search_key = "@EP2="; // string endpoint_2 = value.Substring(value.IndexOf(search_key) + search_key.Length); // endpoint_2 = endpoint_2.Substring(0, endpoint_2.IndexOf(end_key)); // search_key = "@EPT="; // string endpoint_type = value.Substring(value.IndexOf(search_key) + search_key.Length); // endpoint_type = endpoint_type.Substring(0, endpoint_type.IndexOf(end_key)); // search_key = "@Id="; // string Id = value.Substring(value.IndexOf(search_key) + search_key.Length); // Id = Id.Substring(0, Id.IndexOf(end_key)); // search_key = "@Agency="; // string Agency = value.Substring(value.IndexOf(search_key) + search_key.Length); // Agency = Agency.Substring(0, Agency.IndexOf(end_key)); // search_key = "@Version="; // string Version = value.Substring(value.IndexOf(search_key) + search_key.Length); // Version = Version.Substring(0, Version.IndexOf(end_key)); // search_key = "@Source="; // string Source = value.Substring(value.IndexOf(search_key) + search_key.Length); // Source = Source.Substring(0, Source.IndexOf(end_key)); // categoryNode.children.Add( // CreateDataflowNode(Id, // Version, // Agency, // title, // endpoint_2, // endpoint_1, // endpoint_type, // Source, // TreeObj.Configuration.Locale)); //} return(categoryNode); }