/// <summary> /// Add references to <paramref name="structureReferences"/> /// </summary> /// <param name="dataflow"> /// The dataflow. /// </param> /// <param name="structureReferences"> /// The structure references. /// </param> private static void AddReferences(IDataflowMutableObject dataflow, ISet <IStructureReference> structureReferences) { if (dataflow != null && !dataflow.Stub) { structureReferences.Add(dataflow.DataStructureRef); } }
private void CreateEmptyDataFlow() { IDataflowMutableObject dfMutable; dfMutable = _sdmxUtils.buildDataFlow(_ntdString + "DSD_ID", _ntdString + "AGENCY", _ntdDSDVersion); dfMutable.AddName("en", _ntdString + "DSD_NAME"); IStructureReference dsdRef = new StructureReferenceImpl(_ntdString, _ntdString, "1.0", SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), new string[] { _ntdString }); dfMutable.DataStructureRef = dsdRef; _dfMutable = dfMutable; SetDfToSession(); }
/// <summary> /// /// </summary> private void GetDfFromSession() { if (Session[_snInsDf] != null) _dfMutable = (IDataflowMutableObject)Session[_snInsDf]; }
protected void Page_Load(object sender, EventArgs e) { Org.Sdmxsource.Sdmx.Api.Exception.SdmxException.SetMessageResolver(new Org.Sdmxsource.Util.ResourceBundle.MessageDecoder()); _dfMutable = null; _sdmxUtils = new SDMXUtils(); _localizedUtils = new LocalizedUtils(Utils.LocalizedCulture); _entityMapper = new EntityMapper(Utils.LocalizedLanguage); _artIdentity = Utils.GetIdentityFromRequest(Request); SetAction(); if (!IsPostBack) { CommonInit(); } switch (_action) { case Action.INSERT: SetInsertForm(); break; case Action.UPDATE: SetEditForm(); break; case Action.VIEW: SetViewForm(); Utils.ResetBeforeUnload(); break; } DuplicateArtefact1.ucStructureType = SdmxStructureEnumType.Dataflow; DuplicateArtefact1.ucMaintanableArtefact = _dfMutable; lblDFID.DataBind(); lblAgency.DataBind(); lblVersion.DataBind(); lblIsFinal.DataBind(); lblURI.DataBind(); lblURN.DataBind(); lblValidFrom.DataBind(); lblValidTo.DataBind(); lblDSD.DataBind(); lblDFNames.DataBind(); lblDFDescriptions.DataBind(); lbl_annotation.DataBind(); btnSaveDF.DataBind(); }
//TODO: Riscrivere con le corrette inizializzazioni /// <summary> /// Imposta il title della pagina con il DF selezionato /// </summary> //private void SetLabelDetail() //{ // lblDetail.Text = String.Format("DataFlow: {0}, {1}, {2}", _artIdentity.ID, _artIdentity.Agency, _artIdentity.Version); //} private void BindData() { IDataflowObject df = _sdmxObjects.Dataflows.FirstOrDefault(); if (df == null) return; if (_action == Action.VIEW) { _dfMutable = df.MutableInstance; SetDfToSession(); } SetGeneralTab(df); }
/// <summary> /// Handles the Structure top level elements /// This includes Codelist /// </summary> /// <param name="parent"> /// The parent <see cref="IMutableObjects"/> /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> protected override ElementActions HandleTopLevel(IMutableObjects parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.Dataflow)) { var dataflow = new DataflowMutableCore(); ParseAttributes(dataflow, this.Attributes); parent.AddDataflow(dataflow); this._currentDataflow = dataflow; actions = this.AddNameableAction(dataflow, this.HandleChildElements); } return actions; }
/// <summary> /// Handles the Dataflow element child elements /// </summary> /// <param name="parent"> /// The parent IDataflowMutableObject object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> private ElementActions HandleChildElements(IDataflowMutableObject parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.KeyFamilyRef)) { IReferenceInfo reference = new ReferenceInfo(SdmxStructureEnumType.Dsd); this._currentReferenceInfo = reference; actions = this.AddReferenceAction(reference, DoNothingComplex, this.HandleTextChildElementKeyFamily); } else if (NameTableCache.IsElement(localName, ElementNameTable.CategoryRef)) { IReferenceInfo reference = new ReferenceInfo(SdmxStructureEnumType.Category); this._currentReferenceInfo = reference; this._currentCategoryIds.Clear(); actions = this.AddReferenceAction(reference, this.HandleChildElementsCategory, this.HandleTextChildElementCategoryRef); } return actions; }
/// <summary> /// Requests the DSD. /// </summary> /// <param name="dataflow">The dataflow.</param> /// <param name="mutableSearchManager">The mutable search manager.</param> /// <returns>The <see cref="IDataStructureMutableObject"/></returns> private static IDataStructureMutableObject RequestDsd(IDataflowMutableObject dataflow, Func<IStructureReference, IMutableObjects> mutableSearchManager) { IStructureReference dsdReference = dataflow.DataStructureRef; IMutableObjects dsdMutableObjects = mutableSearchManager(dsdReference); Assert.IsNotNull(dsdMutableObjects); Assert.IsNotEmpty(dsdMutableObjects.DataStructures); var firstDsd = dsdMutableObjects.DataStructures.First(); Assert.IsTrue(firstDsd.ExternalReference == null || !firstDsd.ExternalReference.IsTrue, "Failed for dataflow: '{0}', DSD : '{1}'", _fromMutableBuilder.Build(dataflow), dsdReference); return firstDsd; }
/// <summary> /// Requests the partial codelist. /// </summary> /// <param name="dataflow">The dataflow.</param> /// <param name="firstDsd">The first DSD.</param> /// <param name="mutableSearchManager">The mutable search manager.</param> /// <returns>The criteria used.</returns> private static IEnumerable<IKeyValuesMutable> RequestPartialCodelist(IDataflowMutableObject dataflow, IDataStructureMutableObject firstDsd, IMutableStructureSearchManager mutableSearchManager) { var currentDataflowReference = _fromMutableBuilder.Build(dataflow); var previousMembers = new List<IKeyValuesMutable>(); foreach (var dimension in firstDsd.Dimensions) { var representation = dimension.GetEnumeratedRepresentation(firstDsd); if (representation != null) { IStructureReference codelistRef = new StructureReferenceImpl(representation.MaintainableReference, SdmxStructureEnumType.CodeList); var id = dimension.Id; var agencyId = firstDsd.AgencyId; var version = firstDsd.Version; var name = dimension.ConceptRef.ChildReference.Id; var specialRequest = BuildConstrainableStructureReference(id, agencyId, version, name, previousMembers, currentDataflowReference); var queries = new[] { specialRequest, codelistRef }; var objects = mutableSearchManager.RetrieveStructures(queries, false, false); var message = string.Format("DataflowRef : {0}, CodelistRef : {1}", specialRequest, codelistRef); Assert.IsNotNull(objects, message); Assert.IsNotEmpty(objects.Codelists, message); Assert.AreEqual(1, objects.Codelists.Count, message); var codeIds = objects.Codelists.First().Items.TakeWhile(o => _random.Next() % 2 == 0).Select(o => o.Id).ToArray(); if (codeIds.Length > 0) { var criteria = new KeyValuesMutableImpl { Id = id }; criteria.KeyValues.AddAll(codeIds); previousMembers.Add(criteria); } } else if (dimension.TimeDimension) { var id = dimension.Id; var agencyId = firstDsd.AgencyId; var version = firstDsd.Version; var name = dimension.ConceptRef.ChildReference.Id; IStructureReference specialRequest = BuildConstrainableStructureReference(id, agencyId, version, name, previousMembers, currentDataflowReference); IStructureReference timeCodelistReference = new StructureReferenceImpl( CustomCodelistConstants.Agency, CustomCodelistConstants.TimePeriodCodeList, CustomCodelistConstants.Version, SdmxStructureEnumType.CodeList); var queries = new[] { specialRequest, timeCodelistReference }; var objects = mutableSearchManager.RetrieveStructures(queries, false, false); var message = string.Format("DataflowRef : {0}, CodelistRef : {1}", specialRequest, timeCodelistReference); Assert.IsNotNull(objects); Assert.IsNotEmpty(objects.Codelists, message); Assert.AreEqual(1, objects.Codelists.Count, message); var timeCodelist = objects.Codelists.First(); Assert.GreaterOrEqual(timeCodelist.Items.Count, 1, message); Assert.LessOrEqual(timeCodelist.Items.Count, 2, message); foreach (var item in timeCodelist.Items) { DateTime date; Assert.IsTrue(DateTime.TryParseExact(item.Id, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out date), "Invalid date : '{0}' for {1}", item.Id, specialRequest); } if (timeCodelist.Items.Count > 0) { var criteria = new KeyValuesMutableImpl { Id = id }; criteria.KeyValues.AddAll(timeCodelist.Items.Select(o => o.Id)); previousMembers.Add(criteria); } } } return previousMembers; }
/// <summary> /// Requests the count. /// </summary> /// <param name="dataflow">The dataflow.</param> /// <param name="structureSearch">The structure search.</param> /// <param name="previousMembers">The previous members.</param> private static void RequestCount(IDataflowMutableObject dataflow, IMutableStructureSearchManager structureSearch, IEnumerable<IKeyValuesMutable> previousMembers = null) { var currentDataflowReference = _fromMutableBuilder.Build(dataflow); var specialRequest = BuildConstrainableStructureReference("PAOK", "SR", "1.1.1", "PAOK OLE", previousMembers, currentDataflowReference); RequestCount(specialRequest, structureSearch); }
private List<string[]> GetDFNameList(IDataflowMutableObject dataflow) { List<string[]> nameList = new List<string[]>(); foreach (ITextTypeWrapperMutableObject name in dataflow.Names) { nameList.Add(new string[] { name.Locale, name.Value }); } return nameList; }
private List<string[]> GetDFDescriptionList(IDataflowMutableObject dataflow) { List<string[]> descriptionList = new List<string[]>(); foreach (ITextTypeWrapperMutableObject descr in dataflow.Descriptions) { descriptionList.Add(new string[] { descr.Locale, descr.Value }); } return descriptionList; }
protected void Page_Load(object sender, EventArgs e) { if (Request["IDSET"] != null) _idSet = Int32.Parse(Request["IDSET"]); //Org.Sdmxsource.Sdmx.Api.Exception.SdmxException.SetMessageResolver(new Org.Sdmxsource.Util.ResourceBundle.MessageDecoder()); _sdmxUtils = new SDMXUtils(); _localizedUtils = new LocalizedUtils(base.CurrentLocale); AnnotationGeneral.ucLocalCulture = base.CurrentLocale; //_entityMapper = new EntityMapper(Utils.LocalizedLanguage); //_artIdentity = Utils.GetIdentityFromRequest(Request); //_artIdentity = SDMXIdentifier.CreateFromString(Request["AI"]); SetAction(); if (!IsPostBack) { _dfMutable = null; CommonInit(); SetQueryForm(); GetCSTrees(); } switch (_action) { case DLEnums.Action.INSERT: SetInsertForm(); break; case DLEnums.Action.UPDATE: SetEditForm(); break; //case DLEnums.Action.VIEW: // SetViewForm(); // Utils.ResetBeforeUnload(); break; } RefreshConditionSummary(); }
private void SetEditForm() { InitUserControl(); if (!IsPostBack) { SDMXIdentifier identifier = DataAccess.GetIdentifierFromIDSet(_idSet); IDataflowObject df = DataSDMX.GetDataflow(identifier, false); _dfMutable = df.MutableInstance; SetDfToSession(); SetEditingControl(); //BindData(); SetGeneralTab(df); } else { GetDfFromSession(); } }