/// <summary> /// Get the maximum number of observations that can be retrieved given the specified criteria /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. Each member should have member values else they shouldn't be included. It can be null /// </param> /// <returns> /// The maximum number of observations or -1 if it can't be parsed or it is not available /// </returns> /// <exception cref="NsiClientException"> /// NSI WS communication error or parsing error /// </exception> public int GetDataflowDataCount(IDataflowObject dataflow, IContentConstraintMutableObject criteria) { int count; List <IContentConstraintMutableObject> criterias = new List <IContentConstraintMutableObject>(); if (criteria == null) { criteria = new ContentConstraintMutableCore(); } criteria.Id = CustomCodelistConstants.CountCodeList; criteria.AddName("en", "name"); criteria.AgencyId = "agency"; criterias.Add(criteria); var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList)) { MaintainableId = CustomCodelistConstants.CountCodeList, AgencyId = CustomCodelistConstants.Agency, Version = CustomCodelistConstants.Version }; string info = string.Format(CultureInfo.InvariantCulture, Resources.InfoCountFormat2, Utils.MakeKey(dataflow), Utils.MakeKey(codelistRef)); try { ICodelistObject countCodelist = this.GetCodelist(dataflow, codelistRef, criterias, info, true); if (!CustomCodelistConstants.IsCountCodeList(countCodelist) || !int.TryParse(countCodelist.Items[0].Id, out count)) { Logger.WarnFormat(CultureInfo.InvariantCulture, Resources.ExceptionParsingCountCodelistFormat0, info); throw new NsiClientException("Error parsing the count codelist for " + info); } } catch (NsiClientException ex) { Logger.Warn(ex.Message, ex); count = -1; } return(count); }
/// <summary> /// Get the maximum number of observations that can be retrieved given the specified criteria /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. Each member should have member values else they shouldn't be included. It can be null /// </param> /// <returns> /// The maximum number of observations or -1 if it can't be parsed or it is not available /// </returns> /// <exception cref="NsiClientException"> /// NSI WS communication error or parsing error /// </exception> public int GetDataflowDataCount(IDataflowObject dataflow, IContentConstraintMutableObject criteria) { return(_nsiClientWs.GetDataflowDataCount(dataflow, criteria)); }
/// <summary> /// Gets a bean with data about the codelist for specified dataflow and component. /// The dataflow can be retrieved from <see cref="RetrieveCategorisations"/> and the component from <see cref="GetStructure"/> /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="dsd"> /// The dsd /// </param> /// <param name="component"> /// The component /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. The Member has componentRef the dimension conceptRef and the MemberValue(s) specify the selected codes for this dimension. /// </param> /// <returns> /// A <c>CodeListBean</c> with the requested data /// </returns> public ICodelistObject GetCodelist(IDataflowObject dataflow, IDataStructureObject dsd, IComponent component, IContentConstraintMutableObject criteria) { return(_nsiClientWs.GetCodelist(dataflow, dsd, component, criteria)); }
/// <summary> /// Get the maximum number of observations that can be retrieved given the specified criteria /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. Each member should have member values else they shouldn't be included. It can be null /// </param> /// <returns> /// The maximum number of observations or -1 if it can't be parsed or it is not available /// </returns> /// <exception cref="NsiClientException"> /// NSI WS communication error or parsing error /// </exception> public int GetDataflowDataCount(IDataflowObject dataflow, IContentConstraintMutableObject criteria) { return this._nsiClientWs.GetDataflowDataCount(dataflow, criteria); }
/// <summary> /// Gets a bean with data about the codelist for specified dataflow and component. /// The dataflow can be retrieved from <see cref="RetrieveCategorisations"/> and the component from <see cref="GetStructure"/> /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="dsd"> /// The dsd /// </param> /// <param name="component"> /// The component /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. The Member has componentRef the dimension conceptRef and the MemberValue(s) specify the selected codes for this dimension. /// </param> /// <returns> /// A <c>CodeListBean</c> with the requested data /// </returns> public ICodelistObject GetCodelist(IDataflowObject dataflow, IDataStructureObject dsd, IComponent component, IContentConstraintMutableObject criteria) { return this._nsiClientWs.GetCodelist(dataflow, dsd, component, criteria); }
/// <summary> /// Gets a bean with data about the codelist for specified dataflow and codelist ref. /// The dataflow can be retrieved from <see cref="RetrieveDataflow"/> /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="codelistRef"> /// The codelist reference /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. /// </param> /// <param name="info"> /// Some helper information used for logging /// </param> /// <returns> /// The partial codelist. /// </returns> private ICodelistObject GetCodelist( IDataflowObject dataflow, IStructureReference codelistRef, IContentConstraintMutableObject criteria, string info) { ICodelistObject codelist; var refs = new List<IStructureReference>(); var dataflowRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)) { MaintainableId = dataflow.Id, AgencyId = dataflow.AgencyId, Version = dataflow.Version, }; var dataflowRefBean = new ConstrainableStructureReference(dataflowRef, criteria.ImmutableInstance); Logger.InfoFormat(CultureInfo.InvariantCulture, Resources.InfoGettingCodelistFormat1, info); refs.Add(codelistRef); refs.Add(dataflowRefBean); try { ISdmxObjects response; response = this.SendQueryStructureRequest(refs, false); if (response.Codelists.Count != 1) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionInvalidNumberOfCodeListsFormat1, info); Logger.Error(message); throw new NsiClientException(message); } codelist = response.Codelists.First(); if (codelist.Items.Count == 0) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionZeroCodesFormat1, info); Logger.Error(message); throw new NsiClientException(message); } } catch (NsiClientException e) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionGetCodelistFormat2, info, e.Message); Logger.Error(message); Logger.Error(e.Message, e); throw; } catch (DataflowException e) { throw; } catch (Exception e) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionGetCodelistFormat2, info, e.Message); Logger.Error(message); Logger.Error(e.Message, e); throw new NsiClientException(message, e); } return codelist; }
/// <summary> /// Get the maximum number of observations that can be retrieved given the specified criteria /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. Each member should have member values else they shouldn't be included. It can be null /// </param> /// <returns> /// The maximum number of observations or -1 if it can't be parsed or it is not available /// </returns> /// <exception cref="NsiClientException"> /// NSI WS communication error or parsing error /// </exception> public int GetDataflowDataCount(IDataflowObject dataflow, IContentConstraintMutableObject criteria) { int count; if (criteria == null) { criteria = new ContentConstraintMutableCore(); criteria.Id = CustomCodelistConstants.CountCodeList; criteria.AddName("en", "name"); criteria.AgencyId = "agency"; } var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList)) { MaintainableId = CustomCodelistConstants.CountCodeList, AgencyId = CustomCodelistConstants.Agency, Version = CustomCodelistConstants.Version }; string info = string.Format( CultureInfo.InvariantCulture, Resources.InfoCountFormat2, Utils.MakeKey(dataflow), Utils.MakeKey(codelistRef)); try { ICodelistObject countCodelist = this.GetCodelist(dataflow, codelistRef, criteria, info); if (!CustomCodelistConstants.IsCountCodeList(countCodelist) || !int.TryParse(countCodelist.Items[0].Id, out count)) { Logger.WarnFormat(CultureInfo.InvariantCulture, Resources.ExceptionParsingCountCodelistFormat0, info); // throw new NsiClientException("Error parsing the count codelist for " + info); count = -1; } } catch (NsiClientException ex) { Logger.Warn(ex.Message, ex); count = -1; } return count; }
/// <summary> /// Gets a bean with data about the codelist for specified dataflow and codelist ref. /// The dataflow can be retrieved from <see cref="RetrieveDataflow"/> /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="codelistRef"> /// The codelist reference /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. /// </param> /// <param name="info"> /// Some helper information used for logging /// </param> /// <returns> /// The partial codelist. /// </returns> private ICodelistObject GetCodelist( IDataflowObject dataflow, IStructureReference codelistRef, IContentConstraintMutableObject criteria, string info) { ICodelistObject codelist; var refs = new List <IStructureReference>(); var dataflowRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)) { MaintainableId = dataflow.Id, AgencyId = dataflow.AgencyId, Version = dataflow.Version, }; var dataflowRefBean = new ConstrainableStructureReference(dataflowRef, criteria.ImmutableInstance); Logger.InfoFormat(CultureInfo.InvariantCulture, Resources.InfoGettingCodelistFormat1, info); refs.Add(codelistRef); refs.Add(dataflowRefBean); try { ISdmxObjects response; response = this.SendQueryStructureRequest(refs, false); if (response.Codelists.Count != 1) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionInvalidNumberOfCodeListsFormat1, info); Logger.Error(message); throw new NsiClientException(message); } codelist = response.Codelists.First(); if (codelist.Items.Count == 0) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionZeroCodesFormat1, info); Logger.Error(message); throw new NsiClientException(message); } } catch (NsiClientException e) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionGetCodelistFormat2, info, e.Message); Logger.Error(message); Logger.Error(e.Message, e); throw; } catch (DataflowException e) { throw; } catch (Exception e) { string message = string.Format( CultureInfo.InvariantCulture, Resources.ExceptionGetCodelistFormat2, info, e.Message); Logger.Error(message); Logger.Error(e.Message, e); throw new NsiClientException(message, e); } return(codelist); }
/// <summary> /// The handle text child element. /// </summary> /// <param name="c"> /// The c. /// </param> /// <param name="localName"> /// The local name. /// </param> protected void HandleTextChildElement(IContentConstraintMutableObject c, object localName) { if (NameTableCache.IsElement(localName, ElementNameTable.ConstraintID)) { c.Id = this.Text; } }
/// <summary> /// Handle Constraint Child elements /// </summary> /// <param name="parent"> /// The parent IConstraintMutableObject object /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> protected ElementActions HandleChildElements(IContentConstraintMutableObject parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.CubeRegion)) { var cb = new CubeRegionMutableCore(); bool isIncluded = Helper.TrySetFromAttribute(this.Attributes, AttributeNameTable.isIncluded, true); if (isIncluded) { parent.IncludedCubeRegion = cb; } else { parent.ExcludedCubeRegion = cb; } actions = this.BuildElementActions(cb, this.HandleChildElements, DoNothing); } else if (NameTableCache.IsElement(localName, ElementNameTable.ReleaseCalendar)) { parent.ReleaseCalendar = new ReleaseCalendarMutableCore(); actions = this.BuildElementActions(parent.ReleaseCalendar, DoNothingComplex, this.HandleTextChildElement); } else if (NameTableCache.IsElement(localName, ElementNameTable.ReferencePeriod)) { parent.ReferencePeriod = new ReferencePeriodMutableCore(); parent.ReferencePeriod.StartTime = Helper.TrySetFromAttribute(this.Attributes, AttributeNameTable.startTime, parent.ReferencePeriod.StartTime); parent.ReferencePeriod.EndTime = Helper.TrySetFromAttribute(this.Attributes, AttributeNameTable.endTime, parent.ReferencePeriod.EndTime); actions = this.BuildElementActions(parent.ReferencePeriod, DoNothingComplex, DoNothing); } return actions; }
/// <summary> /// /// </summary> private void GetCCFromSession() { if (Session[_snInsCC] != null) _ccMutable = (IContentConstraintMutableObject)Session[_snInsCC]; }
private void CreateEmptyContentConstraint() { IContentConstraintMutableObject ccMutable; ccMutable = _sdmxUtils.buildContentConstraint(_ntdString + "CCS_ID", _ntdString + "AGENCY", _ntdCCVersion); ccMutable.AddName("en", _ntdString + "CC_NAME"); _ccMutable = ccMutable; SetCCToSession(); }
//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() { IContentConstraintObject cc = _sdmxObjects.ContentConstraintObjects.FirstOrDefault(); if (cc == null) return; if (_action == Action.VIEW) { _ccMutable = cc.MutableInstance; SetCCToSession(); } SetGeneralTab(cc); SetConstraintElementsTab(); SetReleaseCalendarTab(); }
protected void Page_Load(object sender, EventArgs e) { Org.Sdmxsource.Sdmx.Api.Exception.SdmxException.SetMessageResolver(new Org.Sdmxsource.Util.ResourceBundle.MessageDecoder()); GetDSD1.ucDSDSelectedEH += new EventHandler<UserControls.GetDSDEventArgs>(GetDSD1_ucDSDSelectedEH); GetDataFlow1.ucDFSelectedEH += new EventHandler<UserControls.GetDFEventArgs>(GetDataFlow1_ucDFSelectedEH); _ccMutable = null; _sdmxUtils = new SDMXUtils(); _localizedUtils = new LocalizedUtils(Utils.LocalizedCulture); _entityMapper = new EntityMapper(Utils.LocalizedLanguage); _artIdentity = Utils.GetIdentityFromRequest(Request); GetDSD1.ucAddIconType = AddIconType.cross; GetDataFlow1.ucAddIconType = AddIconType.cross; SetAction(); if (!IsPostBack) { CommonInit(); } switch (_action) { case Action.INSERT: SetInsertForm(); if ( !Page.IsPostBack ) { cmbAgencies.Items.Insert(0, new ListItem(String.Empty, String.Empty)); cmbAgencies.SelectedIndex = 0; FileDownload31.Visible = false; } break; case Action.UPDATE: SetEditForm(); break; case Action.VIEW: SetViewForm(); Utils.ResetBeforeUnload(); break; } DuplicateArtefact1.ucStructureType = SdmxStructureEnumType.ContentConstraint; DuplicateArtefact1.ucMaintanableArtefact = _ccMutable; }
/// <summary> /// Gets a bean with data about the codelist for specified dataflow and component. /// The dataflow can be retrieved from <see cref="RetrieveCategorisations"/> and the component from <see cref="GetStructure"/> /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="component"> /// The component /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. The Member has componentRef the dimension conceptRef and the MemberValue(s) specify the selected codes for this dimension. /// </param> /// <returns> /// A <c>CodeListBean</c> with the requested data /// </returns> public ICodelistObject GetCodelist(IDataflowObject dataflow, IDataStructureObject dsd, IComponent component, IContentConstraintMutableObject criteria) { var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList)); var dimension = component as IDimension; if (dimension != null && dimension.TimeDimension) { codelistRef.MaintainableId = CustomCodelistConstants.TimePeriodCodeList; codelistRef.AgencyId = CustomCodelistConstants.Agency; codelistRef.Version = CustomCodelistConstants.Version; } else if (dimension != null && dimension.MeasureDimension && dsd is ICrossSectionalDataStructureObject) { var crossDsd = dsd as ICrossSectionalDataStructureObject; codelistRef.MaintainableId = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.MaintainableId; codelistRef.AgencyId = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.AgencyId; codelistRef.Version = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.Version; } else { if (component.HasCodedRepresentation()) { codelistRef.MaintainableId = component.Representation.Representation.MaintainableReference.MaintainableId; codelistRef.AgencyId = component.Representation.Representation.MaintainableReference.AgencyId; codelistRef.Version = component.Representation.Representation.MaintainableReference.Version; } } string info = string.Format( CultureInfo.InvariantCulture, Resources.InfoPartialCodelistFormat3, Utils.MakeKey(dataflow), component.ConceptRef, Utils.MakeKey(codelistRef)); return this.GetCodelist(dataflow, codelistRef, criteria, info); }
/// <summary> /// Write Constraint /// </summary> /// <param name="constrain"> /// The IConstraintMutableObject to write /// </param> protected void WriteConstrain(IContentConstraintMutableObject constrain) { if (constrain != null) { this.WriteStartElement(this.DefaultNS, ElementNameTable.Constraint); this.TryWriteAttribute(AttributeNameTable.ConstraintType, "Content"); this.TryToWriteElement(this._commonPrefix, ElementNameTable.ConstraintID, constrain.Id); this.WriteCubeRegion(constrain.IncludedCubeRegion, true); this.WriteCubeRegion(constrain.ExcludedCubeRegion, false); //////this.WriteMetadataConceptSet(constrain.); this.WriteKeySet(constrain.IncludedSeriesKeys, true); this.WriteKeySet(constrain.ExcludedSeriesKeys, false); this.WriteReleaseCalendar(constrain.ReleaseCalendar); this.WriteReferencePeriod(constrain.ReferencePeriod); this.WriteEndElement(); } }
/// <summary> /// Gets a bean with data about the codelist for specified dataflow and component. /// The dataflow can be retrieved from <see cref="RetrieveCategorisations"/> and the component from <see cref="GetStructure"/> /// </summary> /// <param name="dataflow"> /// The dataflow /// </param> /// <param name="component"> /// The component /// </param> /// <param name="criteria"> /// The criteria includes a set of Member and MemberValue(s) for each dimension. The Member has componentRef the dimension conceptRef and the MemberValue(s) specify the selected codes for this dimension. /// </param> /// <returns> /// A <c>CodeListBean</c> with the requested data /// </returns> public ICodelistObject GetCodelist(IDataflowObject dataflow, IDataStructureObject dsd, IComponent component, IContentConstraintMutableObject criteria) { var codelistRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList)); var dimension = component as IDimension; if (dimension != null && dimension.TimeDimension) { codelistRef.MaintainableId = CustomCodelistConstants.TimePeriodCodeList; codelistRef.AgencyId = CustomCodelistConstants.Agency; codelistRef.Version = CustomCodelistConstants.Version; } else if (dimension != null && dimension.MeasureDimension && dsd is ICrossSectionalDataStructureObject) { var crossDsd = dsd as ICrossSectionalDataStructureObject; codelistRef.MaintainableId = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.MaintainableId; codelistRef.AgencyId = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.AgencyId; codelistRef.Version = crossDsd.GetCodelistForMeasureDimension(dimension.Id).MaintainableReference.Version; } else { if (component.HasCodedRepresentation()) { codelistRef.MaintainableId = component.Representation.Representation.MaintainableReference.MaintainableId; codelistRef.AgencyId = component.Representation.Representation.MaintainableReference.AgencyId; codelistRef.Version = component.Representation.Representation.MaintainableReference.Version; } } string info = string.Format( CultureInfo.InvariantCulture, Resources.InfoPartialCodelistFormat3, Utils.MakeKey(dataflow), component.ConceptRef, Utils.MakeKey(codelistRef)); return(this.GetCodelist(dataflow, codelistRef, criteria, info)); }