/// <summary>
 /// The modify data structure reference.
 /// </summary>
 /// <param name="datasetStructureRef">
 /// The dataset structure reference agencySchemeMutable 0. 
 /// </param>
 /// <returns>
 /// The <see cref="IDatasetHeader"/> . 
 /// </returns>
 public virtual IDatasetHeader ModifyDataStructureReference(
     IDatasetStructureReference datasetStructureRef)
 {
     return new DatasetHeaderCore(
         this.DatasetId,
         this.Action,
         datasetStructureRef,
         this.DataProviderReference,
         this.ReportingBeginDate,
         this.ReportingEndDate,
         this.ValidFrom,
         this.ValidTo,
         this.PublicationYear,
         this.PublicationPeriod,
         null); // TODO reportingYearStartDate
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetHeaderCore"/> class. 
        ///   Create an instance from a parser reading the dataset XML Node and the header
        /// </summary>
        /// <param name="parser">XML reader instance.
        /// </param>
        /// <param name="datasetHeader">Header object.
        /// </param>
        public DatasetHeaderCore(XmlReader parser, IHeader datasetHeader)
        {
            this._action = DatasetAction.GetFromEnum(DatasetActionEnumType.Information);
            this._publicationYear = -1;
            if (parser.GetAttribute("structureRef") != null)
            {
                string structureRef = parser.GetAttribute("structureRef");
                this._datasetStructureReference = GetStructureFromHeader(datasetHeader, structureRef);
                if (this._datasetStructureReference == null)
                {
                    throw new SdmxSemmanticException(
                        "Dataset references CategorisationStructure that is not defined in the Header of the message.  CategorisationStructure reference defined by Dataset is:"
                        + structureRef);
                }
            }
            else
            {
                this._datasetStructureReference = GenerateOrUseDefaultStructure(parser, datasetHeader);
            }

            if (parser.GetAttribute("action") != null)
            {
                this._action = DatasetAction.GetAction(parser.GetAttribute("action"));
            }
            else if (datasetHeader.Action != null)
            {
                this._action = datasetHeader.Action;
            }

            // if(parser.getAttributeValue(null, "dataProviderID") != null) {
            // datasetAttributes.setDataProviderId(parser.getAttributeValue(null, "dataProviderID"));
            // }
            // if(parser.getAttributeValue(null, "dataProviderSchemeAgencyId") != null) {
            // datasetAttributes.setDataProviderSchemeAgencyId(parser.getAttributeValue(null, "dataProviderSchemeAgencyId"));
            // }
            // if(parser.getAttributeValue(null, "dataProviderSchemeId") != null) {
            // datasetAttributes.setDataProviderSchemeId(parser.getAttributeValue(null, "dataProviderSchemeId"));
            // }
            // TODO use switch & parser.MoveToNextAttribute()
            if (parser.GetAttribute("datasetID") != null)
            {
                this._datasetId = parser.GetAttribute("datasetID");
            }

            if (parser.GetAttribute("publicationPeriod") != null)
            {
                this._publicationPeriod = parser.GetAttribute("publicationPeriod");
            }

            if (parser.GetAttribute("publicationYear") != null)
            {
                this._publicationYear = int.Parse(parser.GetAttribute("publicationYear"));
            }

            if (parser.GetAttribute("reportingBeginDate") != null)
            {
                this._reportingBeginDate = DateUtil.FormatDate(parser.GetAttribute("reportingBeginDate"), true);
            }

            if (parser.GetAttribute("reportingEndDate") != null)
            {
                this._reportingEndDate = DateUtil.FormatDate(parser.GetAttribute("reportingEndDate"), true);
            }

            if (parser.GetAttribute("validFromDate") != null)
            {
                this._validFrom = DateUtil.FormatDate(parser.GetAttribute("validFromDate"), true);
            }

            if (parser.GetAttribute("validToDate") != null)
            {
                this._validTo = DateUtil.FormatDate(parser.GetAttribute("validToDate"), true);
            }
        }
        private string reportingYearStartDate; // TODO WE NEED A MONTH DAY TYPE

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetHeaderCore"/> class. 
        ///   Minimal Constructor
        /// </summary>
        /// <param name="datasetId">Dataset id
        /// </param>
        /// <param name="action">Dataset action
        /// </param>
        /// <param name="datasetStructureReference">DatasetStructureReference object
        /// </param>
        public DatasetHeaderCore(
            string datasetId, DatasetAction action, IDatasetStructureReference datasetStructureReference)
        {
            this._action = DatasetAction.GetFromEnum(DatasetActionEnumType.Information);
            this._publicationYear = -1;
            this._datasetId = datasetId;
            if (action != null)
            {
                this._action = action;
            }

            this._datasetStructureReference = datasetStructureReference;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DatasetHeaderCore"/> class.
 /// </summary>
 /// <param name="datasetId">
 /// The dataset id. 
 /// </param>
 /// <param name="action">
 /// The action. 
 /// </param>
 /// <param name="datasetStructureReference">
 /// The dataset structure reference agencySchemeMutable. 
 /// </param>
 /// <param name="dataProviderRef">
 /// The data provider ref. 
 /// </param>
 /// <param name="reportingBeginDate">
 /// The reporting begin date. 
 /// </param>
 /// <param name="reportingEndDate">
 /// The reporting end date. 
 /// </param>
 /// <param name="validFrom">
 /// The valid from. 
 /// </param>
 /// <param name="validTo">
 /// The valid to. 
 /// </param>
 /// <param name="publicationYear">
 /// The publication year. 
 /// </param>
 /// <param name="publicationPeriod">
 /// The publication period. 
 /// </param>
 /// <param name="reportingYearStartDate">
 /// The reporting year start date. 
 /// </param>
 public DatasetHeaderCore(
     string datasetId,
     DatasetAction action,
     IDatasetStructureReference datasetStructureReference,
     IMaintainableRefObject dataProviderRef,
     DateTime reportingBeginDate,
     DateTime reportingEndDate,
     DateTime validFrom,
     DateTime validTo,
     int publicationYear,
     string publicationPeriod,
     string reportingYearStartDate)
 {
     this._action = DatasetAction.GetFromEnum(DatasetActionEnumType.Information);
     this._publicationYear = -1;
     this._dataProviderRef = dataProviderRef;
     this._datasetStructureReference = datasetStructureReference;
     this._datasetId = datasetId;
     this._reportingBeginDate = reportingBeginDate;
     this._reportingEndDate = reportingEndDate;
     this._validFrom = validFrom;
     this._validTo = validTo;
     this._action = action;
     this._publicationYear = publicationYear;
     this._publicationPeriod = publicationPeriod;
     this.reportingYearStartDate = reportingYearStartDate;
 }
Beispiel #5
0
 public void AddStructure(IDatasetStructureReference datasetStructureReference)
 {
     this._structureReferences.Add(datasetStructureReference);
 }