public void ReadingStructures(String structureFile, SdmxSchemaEnumType schema, String output){

            // Step 2. Implementing a helper class that parses DSD, Dataflow and writes datasets.
            //1)	Call the method getXmlWriter
            XmlWriter xmlWriter = this.getXmlWriter(output);

            //2)	Obtain IDataWriterEngine
            IDataWriterEngine compactWriter = new CompactDataWriterEngine(xmlWriter,SdmxSchema.GetFromEnum(schema));

            //3)	Read a structure file from a stream
            this.spm = new StructureParsingManager();
            ISdmxObjects structureObjects = new SdmxObjectsImpl();

            using (FileStream stream = File.Open(structureFile, FileMode.Open, FileAccess.Read))
            {
                using (IReadableDataLocation rdl = new ReadableDataLocationTmp(stream))
                {
                    IStructureWorkspace structureWorkspace = this.spm.ParseStructures(rdl);
                    structureObjects = structureWorkspace.GetStructureObjects(false);
                }
            }

            //4)	The IMaintainableRefObject is used to reference structures that extend the IMaintainableObject Interface.  
            IMaintainableRefObject dsdRef = new MaintainableRefObjectImpl("ESTAT", "STS", "2.2");
            IMaintainableRefObject flowRef = new MaintainableRefObjectImpl("ESTAT", "SSTSCONS_PROD_A", "1.0");

            //5)	Get the DataStructure and the Dataflow
            ISet<IDataStructureObject> dsd = structureObjects.GetDataStructures(dsdRef);
            ISet<IDataflowObject> dataflow = structureObjects.GetDataflows(flowRef);

            //6)	After obtaining our IDataWriterEngine, and the IDataStructureObject that we wish to create data for, we can write the dataset
            SampleDataWriter sampleDataWriter = new SampleDataWriter();
            sampleDataWriter.writeSampleData(dsd.FirstOrDefault(), dataflow.FirstOrDefault(), compactWriter);
            xmlWriter.Close();
        }
        /// <summary>
        /// Retrieve Codelist
        /// </summary>
        /// <param name="info">
        /// The current StructureRetrieval state 
        /// </param>
        /// <returns>
        /// A <see cref="CodeListBean"/> 
        /// </returns>
        public ICodelistMutableObject GetCodeList(StructureRetrievalInfo info)
        {
            var dataflowrRef = new MaintainableRefObjectImpl(info.MappingSet.Dataflow.Agency, info.MappingSet.Dataflow.Id, info.MappingSet.Dataflow.Version);
            ISet<ICodelistMutableObject> codeLists = info.MastoreAccess.GetMutableCodelistObjects(info.CodelistRef,dataflowrRef, info.RequestedComponent, this._isTranscoded, info.AllowedDataflows);

            return CodeListHelper.GetFirstCodeList(codeLists);
        }
        /// <summary>
        /// The main method.
        /// </summary>
        /// <param name="args">
        /// The parameter is not used.
        /// </param>
        public static void Main(string[] args)
        {
            // Steps 1 - 4 are performed in the new class DatabaseRetrievalManager, an implementation of the ISdmxObjectRetrievalManager interface.
            // DatabaseRetrievalManager: Step 1. Creating an implementation of  the ISdmxObjectRetrievalManager interface
            // DatabaseRetrievalManager: Step 2. Implementing ISdmxObjectRetrievalManager GetMaintainableObjects<> method.
            // DatabaseRetrievalManager: Step 3. Retrieving codelists from database. 
            // DatabaseRetrievalManager: Step 4. Retrieving Codes from the database.

            // Step 5. Create a ISdmxObjectRetrievalManager instance
            ISdmxObjectRetrievalManager retrievalManager = new DatabaseRetrievalManager();

            // Step 6. Create an IHeader  instance.
            // Create a new HeaderImpl instance with ID “IDREF0001”, Sender ID “ZZ9” 
            IHeader header = new HeaderImpl("IDREF001", "ZZ9"); // can be an instance or even a static field.

            // Step 7. Create the query
            IMaintainableRefObject query = new MaintainableRefObjectImpl("TEST_AGENCY", "TEST", "1.2");

            // Step 8. Get the codelist objects
            var codelistObjects = retrievalManager.GetMaintainableObjects<ICodelistObject>(query);

            // Step 9. Build the immutable object container.
            // Create an immutable container with the header and the codelist objects.
            // Note that immutable container can be modified.
            ISdmxObjects immutableObjects = new SdmxObjectsImpl(header, codelistObjects);

            // Step 10. Create an instance of the IStructureWriterManager.
            IStructureWriterManager structureWriterManager = new StructureWriterManager(); // can be an instance or even static field.

            // Step 11. Create a SdmxStructureFormat instance with StructureOutputFormat SdmxV21StructureDocument
            // SDMX v2.1. Create a SdmxStructureFormat instance with StructureOutputFormat SdmxV21StructureDocument. It can also be an instance or even a static field.
            IStructureFormat formatV21 = new SdmxStructureFormat(StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV21StructureDocument));

            // Step 12. Create a SdmxStructureFormat instance with StructureOutputFormat SdmxV2StructureDocument
            // SDMX v2.0. Create a SdmxStructureFormat instance with StructureOutputFormat SdmxV2StructureDocument. It can also be an instance or even a static field.
            IStructureFormat formatV20 = new SdmxStructureFormat(StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2StructureDocument));


            // Step 13. Write to  the SDMX v2.1 structure file.
            using (Stream fileStream = File.Create(@"..\..\Exercise Output\outputv21.xml"))
            {
                // Write the objects in SDMX v2.1 format. Then flush the output.
                structureWriterManager.WriteStructures(immutableObjects, formatV21, fileStream);
                fileStream.Flush();
            }

            // Step 14. Write to  the SDMX v2.0 structure file. 
            using (Stream fileStream = File.Create(@"..\..\Exercise Output\outputv20.xml"))
            {
                // Write the objects in SDMX v2.0 format. Then flush the output.
                structureWriterManager.WriteStructures(immutableObjects, formatV20, fileStream);
                fileStream.Flush();
            }
        }
        public static ISet<IAgencySchemeMutableObject> GetAgencies()
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl("", "", "");
            ISet<IAgencySchemeMutableObject> ages = manager.GetMutableAgencySchemeObjects(query, true, false);

            return ages;
        }
        public static ICategorisationObject GetCategorisation(SDMXIdentifier sdmxKey, bool stub)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            ICategorisationMutableObject cat = manager.GetMutableCategorisation(query, false, stub);

            return cat.ImmutableInstance;
        }
Exemplo n.º 6
0
       /// <summary>
       /// The evaluate.
       /// </summary>
       /// <param name="queryString">
       /// The query string. 
       /// </param>
       /// <param name="queryParameters">
       /// The query parameters. 
       /// </param>
       private void Evaluate(string[] queryString, IDictionary<string, string> queryParameters)
       {
		    ParseQueryString(queryString);
		    ParseQueryParameters(queryParameters);
		
		    SdmxStructureType referencedStructure = SdmxStructureType.ParseClass(_context);
		
		    if (referencedStructure != SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd) &&
			referencedStructure != SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow) && 
			referencedStructure != SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProvisionAgreement) && 
			referencedStructure != SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataFlow) &&
			referencedStructure != SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Msd))
            {
		    	throw new SdmxSemmanticException("The referenced structure is not a legitimate type!");
		    }
			
	   	    IMaintainableRefObject maintainableRef = new MaintainableRefObjectImpl(_agencyId, _id, _version);
		    _reference = new StructureReferenceImpl(maintainableRef, referencedStructure);
	   }
            /// <summary>
            /// Builds a data query from <paramref name="dataWhereType"/>
            /// </summary>
            /// <param name="dataWhereType">
            /// The data Where Type.
            /// </param>
            /// <param name="structureRetrievalManager">
            /// The structure Retrieval Manager.
            /// </param>
            /// <returns>
            /// The <see cref="IDataQuery"/>.
            /// </returns>
            public IDataQuery BuildDataQuery(
                DataWhereType dataWhereType, ISdmxObjectRetrievalManager structureRetrievalManager)
            {
                if (structureRetrievalManager == null)
                {
                    throw new ArgumentNullException("structureRetrievalManager");
                }

                this.ProcessDataWhere(dataWhereType);
                this.ProcessAnd(dataWhereType.And);

                IMaintainableRefObject flowRef = new MaintainableRefObjectImpl(
                    this._agencyId, this._dataflowId, this._version);
                IDataflowObject dataflow = structureRetrievalManager.GetMaintainableObject<IDataflowObject>(flowRef);
                if (dataflow == null)
                {
                    throw new SdmxNoResultsException("Dataflow not found: " + flowRef);
                }

                IMaintainableRefObject dsdRef = dataflow.DataStructureRef.MaintainableReference;
                IDataStructureObject dataStructureBean = structureRetrievalManager.GetMaintainableObject<IDataStructureObject>(dsdRef);
                if (dataStructureBean == null)
                {
                    throw new SdmxNoResultsException("Data Structure not found: " + dsdRef);
                }

                // TODO check if DSD is v2.0 compatible
                if (!dataStructureBean.IsCompatible(SdmxSchema.GetFromEnum(SdmxSchemaEnumType.VersionTwo)))
                {
                    throw new SdmxSemmanticException("DataStructure used for this dataflow is not SDMX v2.0 compatible.");
                }

                var convertedDataQuerySelectionGroups = ConvertConceptIdToComponentId(this._dataQuerySelectionGroups, dataStructureBean);

                // FUNC Data Provider
                return new DataQueryImpl(
                    dataStructureBean,
                    null,
                    null,
                    this._defaultLimit /* was null TODO */,
                    true,
                    null,
                    dataflow,
                    null,
                    convertedDataQuerySelectionGroups);
            }
        public static IDataflowObject GetDataflow(SDMXIdentifier sdmxKey, bool stub)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            IDataflowMutableObject dataflow = manager.GetMutableDataflow(query, false, stub);

            if (dataflow == null) return null;

            return dataflow.ImmutableInstance;
        }
        public static ISet<IDataStructureMutableObject> GetDSDList()
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            SDMXIdentifier sdmxKey = new SDMXIdentifier();
            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            ISet<IDataStructureMutableObject> dsds = manager.GetMutableDataStructureObjects(query, false, true);

            // Remove not final dsd
            //List<IDataStructureMutableObject> dsdNotFinal = new List<IDataStructureMutableObject>();
            //foreach (IDataStructureMutableObject dsd in dsds)
            //{
            //    if (!dsd.FinalStructure.IsTrue)
            //        dsdNotFinal.Add(dsd);
            //}
            //foreach (IDataStructureMutableObject dsd in dsdNotFinal)
            //{
            //    dsds.Remove(dsd);
            //}

            return dsds;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Builds the categorisation dictionary where dataflow <see cref="IMaintainableRefObject"/> are keys and lists of
        ///     <see cref="ICategorisationMutableObject"/>
        ///     the value.
        /// </summary>
        /// <param name="categorisations">
        /// The categorisations.
        /// </param>
        /// <param name="itemScheme">
        /// The Category Scheme
        /// </param>
        /// <returns>
        /// The categorisation dictionary
        /// </returns>
        private static IDictionaryOfLists<string, ICategorisationMutableObject> BuildCategorisationMap(
            IEnumerable<ICategorisationMutableObject> categorisations, IMaintainableMutableObject itemScheme)
        {
            var categorisationMap = new DictionaryOfLists<string, ICategorisationMutableObject>(StringComparer.Ordinal);
            var categorySchemeRef = new MaintainableRefObjectImpl(
                itemScheme.AgencyId, itemScheme.Id, itemScheme.Version);
            foreach (ICategorisationMutableObject categorisation in categorisations)
            {
                IStructureReference structureReference = categorisation.StructureReference;
                switch (structureReference.MaintainableStructureEnumType.EnumType)
                {
                    case SdmxStructureEnumType.Dataflow:
                        IStructureReference categoryRef = categorisation.CategoryReference;
                        if (categorySchemeRef.Equals(categoryRef.MaintainableReference))
                        {
                            IList<ICategorisationMutableObject> categoryDataflows;
                            string categoryId = categoryRef.ChildReference.GetLastId();
                            if (!categorisationMap.TryGetValue(categoryId, out categoryDataflows))
                            {
                                categoryDataflows = new List<ICategorisationMutableObject>();
                                categorisationMap.Add(categoryId, categoryDataflows);
                            }

                            categoryDataflows.Add(categorisation);
                        }

                        break;
                }
            }

            return categorisationMap;
        }
        public static IConceptObject GetConcept(SDMXIdentifier sdmxKey, string idConcept)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            IConceptSchemeMutableObject concepts = manager.GetMutableConceptScheme(query, false, false);
            foreach (IConceptObject concept in concepts.ImmutableInstance.Items)
            {
                if (concept.Id == idConcept)
                {

                    return concept;
                }
            }
            return null;
        }
        /// <summary>
        /// Processes the dataWhere element to get the Provisionn Agreeement reference and retrieve the respective artefact bean.
        /// If the provision agreement cannot be found it throws an exception.
        /// </summary>
        /// <param name="dataWhere">
        /// The data where.
        /// </param>
        /// <param name="structureRetrievalManager">
        /// The structure retrieval manager.
        /// </param>
        /// <returns>
        /// The provision agreement object.
        /// </returns>
        private IProvisionAgreementObject GetProvisionAgreement(DataParametersAndType dataWhere, ISdmxObjectRetrievalManager structureRetrievalManager)
        {
            IProvisionAgreementObject provisionAgreement = null;

            if (dataWhere.ProvisionAgreement != null && dataWhere.ProvisionAgreement.Count > 0)
            {
                var refBaseType = dataWhere.ProvisionAgreement[0].GetTypedRef<ProvisionAgreementRefType>();
                string praAgency = refBaseType.agencyID;
                string praId = refBaseType.id;
                string praVersion = null;
                if (refBaseType.version != null)
                    praVersion = refBaseType.version;
                IMaintainableRefObject praRef = new MaintainableRefObjectImpl(praAgency, praId, praVersion);
                provisionAgreement = structureRetrievalManager.GetMaintainableObject<IProvisionAgreementObject>(praRef);
                if (provisionAgreement == null)
                {
                    throw new SdmxNoResultsException("Provision Agreement not found: " + praRef);
                }
            }
            return provisionAgreement;
        }
Exemplo n.º 13
0
        public void Test()
        {
            var s = new SdmxObjectsImpl();
            var s2 = new SdmxObjectsImpl(new HeaderImpl("PAOK", "OLE"));
            Assert.IsFalse(s2.HasStructures());
            Assert.NotNull(s2.Header);
            var s3 = new SdmxObjectsImpl(DatasetAction.GetFromEnum(DatasetActionEnumType.Append));

            Assert.AreEqual(s.Action.EnumType, DatasetActionEnumType.Information);
            Assert.AreEqual(s3.Action.EnumType, DatasetActionEnumType.Append);
            Assert.IsNull(s.Header);
            Assert.IsNotNull(s.Agencies);
            CollectionAssert.IsEmpty(s.Agencies);
            Assert.AreNotSame(s.Agencies, s.Agencies);

            Assert.IsNotNull(s.AgenciesSchemes);
            CollectionAssert.IsEmpty(s.AgenciesSchemes);
            Assert.AreNotSame(s.AgenciesSchemes, s.AgenciesSchemes);

            Assert.IsNotNull(s.AllMaintainables);
            CollectionAssert.IsEmpty(s.AllMaintainables);
            Assert.AreNotSame(s.AllMaintainables, s.AllMaintainables);

            Assert.IsNotNull(s.AttachmentConstraints);
            CollectionAssert.IsEmpty(s.AttachmentConstraints);
            Assert.AreNotSame(s.AttachmentConstraints, s.AttachmentConstraints);

            Assert.IsNotNull(s.Categorisations);
            CollectionAssert.IsEmpty(s.Categorisations);
            Assert.AreNotSame(s.Categorisations, s.Categorisations);

            Assert.IsNotNull(s.CategorySchemes);
            CollectionAssert.IsEmpty(s.CategorySchemes);
            Assert.AreNotSame(s.CategorySchemes, s.CategorySchemes);

            Assert.IsNotNull(s.Codelists);
            CollectionAssert.IsEmpty(s.Codelists);
            Assert.AreNotSame(s.Codelists, s.Codelists);

            Assert.IsNotNull(s.ConceptSchemes);
            CollectionAssert.IsEmpty(s.ConceptSchemes);
            Assert.AreNotSame(s.ConceptSchemes, s.ConceptSchemes);

            Assert.IsNotNull(s.ContentConstraintObjects);
            CollectionAssert.IsEmpty(s.ContentConstraintObjects);
            Assert.AreNotSame(s.ContentConstraintObjects, s.ContentConstraintObjects);

            Assert.IsNotNull(s.DataConsumerSchemes);
            CollectionAssert.IsEmpty(s.DataConsumerSchemes);
            Assert.AreNotSame(s.DataConsumerSchemes, s.DataConsumerSchemes);

            Assert.IsNotNull(s.DataProviderSchemes);
            CollectionAssert.IsEmpty(s.DataProviderSchemes);
            Assert.AreNotSame(s.DataProviderSchemes, s.DataProviderSchemes);

            Assert.IsNotNull(s.DataStructures);
            CollectionAssert.IsEmpty(s.DataStructures);
            Assert.AreNotSame(s.DataStructures, s.DataStructures);

            Assert.IsNotNull(s.Dataflows);
            CollectionAssert.IsEmpty(s.Dataflows);
            Assert.AreNotSame(s.Dataflows, s.Dataflows);

            Assert.IsNotNull(s.HierarchicalCodelists);
            CollectionAssert.IsEmpty(s.HierarchicalCodelists);
            Assert.AreNotSame(s.HierarchicalCodelists, s.HierarchicalCodelists);

            Assert.IsNotNull(s.MetadataStructures);
            CollectionAssert.IsEmpty(s.MetadataStructures);
            Assert.AreNotSame(s.MetadataStructures, s.MetadataStructures);

            Assert.IsNotNull(s.Metadataflows);
            CollectionAssert.IsEmpty(s.Metadataflows);
            Assert.AreNotSame(s.Metadataflows, s.Metadataflows);

            Assert.IsNotNull(s.OrganisationUnitSchemes);
            CollectionAssert.IsEmpty(s.OrganisationUnitSchemes);
            Assert.AreNotSame(s.OrganisationUnitSchemes, s.OrganisationUnitSchemes);

            Assert.IsNotNull(s.Processes);
            CollectionAssert.IsEmpty(s.Processes);
            Assert.AreNotSame(s.Processes, s.Processes);

            Assert.IsNotNull(s.ProvisionAgreements);
            CollectionAssert.IsEmpty(s.ProvisionAgreements);
            Assert.AreNotSame(s.ProvisionAgreements, s.ProvisionAgreements);

            Assert.IsNotNull(s.Registrations);
            CollectionAssert.IsEmpty(s.Registrations);
            Assert.AreNotSame(s.Registrations, s.Registrations);

            Assert.IsNotNull(s.ReportingTaxonomys);
            CollectionAssert.IsEmpty(s.ReportingTaxonomys);
            Assert.AreNotSame(s.ReportingTaxonomys, s.ReportingTaxonomys);

            Assert.IsNotNull(s.StructureSets);
            CollectionAssert.IsEmpty(s.StructureSets);
            Assert.AreNotSame(s.StructureSets, s.StructureSets);

            Assert.IsNotNull(s.Subscriptions);
            CollectionAssert.IsEmpty(s.Subscriptions);
            Assert.AreNotSame(s.Subscriptions, s.Subscriptions);

            var agencySchemeMock = new Mock<IAgencyScheme>();
            agencySchemeMock.Setup(o => o.StructureType)
                            .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AgencyScheme));

            agencySchemeMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            agencySchemeMock.Setup(o => o.Id).Returns("ID_AGENCYSCHEME");
            agencySchemeMock.Setup(o => o.Version).Returns("1.2");
            agencySchemeMock.Setup(o => o.StructureType)
                            .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AgencyScheme));
            IAgencyScheme agencyScheme = agencySchemeMock.Object;
            s.AddAgencyScheme(agencyScheme);
            CollectionAssert.IsNotEmpty(s.AgenciesSchemes);
            s.RemoveAgencyScheme(agencyScheme);
            CollectionAssert.IsEmpty(s.AgenciesSchemes);
            s.AddIdentifiable(agencyScheme);
            CollectionAssert.IsNotEmpty(s.AgenciesSchemes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.AgenciesSchemes);

            var attachmentConstraintObjectMock = new Mock<IAttachmentConstraintObject>();
            attachmentConstraintObjectMock.Setup(o => o.StructureType)
                                          .Returns(
                                              SdmxStructureType.GetFromEnum(SdmxStructureEnumType.AttachmentConstraint));

            attachmentConstraintObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            attachmentConstraintObjectMock.Setup(o => o.Id).Returns("ID_ATTACHMENTCONSTRAINTOBJECT");
            attachmentConstraintObjectMock.Setup(o => o.Version).Returns("1.2");
            IAttachmentConstraintObject attachmentConstraintObject = attachmentConstraintObjectMock.Object;
            s.AddAttachmentConstraint(attachmentConstraintObject);
            CollectionAssert.IsNotEmpty(s.AttachmentConstraints);
            s.RemoveAttachmentConstraintObject(attachmentConstraintObject);
            CollectionAssert.IsEmpty(s.AttachmentConstraints);
            s.AddIdentifiable(attachmentConstraintObject);
            CollectionAssert.IsNotEmpty(s.AttachmentConstraints);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.AttachmentConstraints);

            var categorisationObjectMock = new Mock<ICategorisationObject>();
            categorisationObjectMock.Setup(o => o.StructureType)
                                    .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Categorisation));

            categorisationObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            categorisationObjectMock.Setup(o => o.Id).Returns("ID_CATEGORISATIONOBJECT");
            categorisationObjectMock.Setup(o => o.Version).Returns("1.2");
            ICategorisationObject categorisationObject = categorisationObjectMock.Object;
            s.AddCategorisation(categorisationObject);
            CollectionAssert.IsNotEmpty(s.Categorisations);
            s.RemoveCategorisation(categorisationObject);
            CollectionAssert.IsEmpty(s.Categorisations);
            s.AddIdentifiable(categorisationObject);
            CollectionAssert.IsNotEmpty(s.Categorisations);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Categorisations);

            var categorySchemeObjectMock = new Mock<ICategorySchemeObject>();
            categorySchemeObjectMock.Setup(o => o.StructureType)
                                    .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme));

            categorySchemeObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            categorySchemeObjectMock.Setup(o => o.Id).Returns("ID_CATEGORYSCHEMEOBJECT");
            categorySchemeObjectMock.Setup(o => o.Version).Returns("1.2");
            ICategorySchemeObject categorySchemeObject = categorySchemeObjectMock.Object;
            s.AddCategoryScheme(categorySchemeObject);
            CollectionAssert.IsNotEmpty(s.CategorySchemes);
            s.RemoveCategoryScheme(categorySchemeObject);
            CollectionAssert.IsEmpty(s.CategorySchemes);
            s.AddIdentifiable(categorySchemeObject);
            CollectionAssert.IsNotEmpty(s.CategorySchemes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.CategorySchemes);

            var codelistObjectMock = new Mock<ICodelistObject>();
            codelistObjectMock.Setup(o => o.StructureType)
                              .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList));

            codelistObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            codelistObjectMock.Setup(o => o.Id).Returns("ID_CODELISTOBJECT");
            codelistObjectMock.Setup(o => o.Version).Returns("1.2");
            ICodelistObject codelistObject = codelistObjectMock.Object;
            s.AddCodelist(codelistObject);
            CollectionAssert.IsNotEmpty(s.Codelists);
            s.RemoveCodelist(codelistObject);
            CollectionAssert.IsEmpty(s.Codelists);
            s.AddIdentifiable(codelistObject);
            CollectionAssert.IsNotEmpty(s.Codelists);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Codelists);

            var conceptSchemeObjectMock = new Mock<IConceptSchemeObject>();
            conceptSchemeObjectMock.Setup(o => o.StructureType)
                                   .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme));

            conceptSchemeObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            conceptSchemeObjectMock.Setup(o => o.Id).Returns("ID_CONCEPTSCHEMEOBJECT");
            conceptSchemeObjectMock.Setup(o => o.Version).Returns("1.2");
            IConceptSchemeObject conceptSchemeObject = conceptSchemeObjectMock.Object;
            s.AddConceptScheme(conceptSchemeObject);
            CollectionAssert.IsNotEmpty(s.ConceptSchemes);
            s.RemoveConceptScheme(conceptSchemeObject);
            CollectionAssert.IsEmpty(s.ConceptSchemes);
            s.AddIdentifiable(conceptSchemeObject);
            CollectionAssert.IsNotEmpty(s.ConceptSchemes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.ConceptSchemes);

            var contentConstraintObjectMock = new Mock<IContentConstraintObject>();
            contentConstraintObjectMock.Setup(o => o.StructureType)
                                       .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ContentConstraint));

            contentConstraintObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            contentConstraintObjectMock.Setup(o => o.Id).Returns("ID_CONTENTCONSTRAINTOBJECT");
            contentConstraintObjectMock.Setup(o => o.Version).Returns("1.2");
            IContentConstraintObject contentConstraintObject = contentConstraintObjectMock.Object;
            s.AddContentConstraintObject(contentConstraintObject);
            CollectionAssert.IsNotEmpty(s.ContentConstraintObjects);
            s.RemoveContentConstraintObject(contentConstraintObject);
            CollectionAssert.IsEmpty(s.ContentConstraintObjects);
            s.AddIdentifiable(contentConstraintObject);
            CollectionAssert.IsNotEmpty(s.ContentConstraintObjects);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.ContentConstraintObjects);

            var dataConsumerSchemeMock = new Mock<IDataConsumerScheme>();
            dataConsumerSchemeMock.Setup(o => o.StructureType)
                                  .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DataConsumerScheme));

            dataConsumerSchemeMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            dataConsumerSchemeMock.Setup(o => o.Id).Returns("ID_DATACONSUMERSCHEME");
            dataConsumerSchemeMock.Setup(o => o.Version).Returns("1.2");
            IDataConsumerScheme dataConsumerScheme = dataConsumerSchemeMock.Object;
            s.AddDataConsumerScheme(dataConsumerScheme);
            CollectionAssert.IsNotEmpty(s.DataConsumerSchemes);
            s.RemoveDataConsumerScheme(dataConsumerScheme);
            CollectionAssert.IsEmpty(s.DataConsumerSchemes);
            s.AddIdentifiable(dataConsumerScheme);
            CollectionAssert.IsNotEmpty(s.DataConsumerSchemes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.DataConsumerSchemes);

            var dataProviderSchemeMock = new Mock<IDataProviderScheme>();
            dataProviderSchemeMock.Setup(o => o.StructureType)
                                  .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.DataProviderScheme));

            dataProviderSchemeMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            dataProviderSchemeMock.Setup(o => o.Id).Returns("ID_DATAPROVIDERSCHEME");
            dataProviderSchemeMock.Setup(o => o.Version).Returns("1.2");
            IDataProviderScheme dataProviderScheme = dataProviderSchemeMock.Object;
            s.AddDataProviderScheme(dataProviderScheme);
            CollectionAssert.IsNotEmpty(s.DataProviderSchemes);
            s.RemoveDataProviderScheme(dataProviderScheme);
            CollectionAssert.IsEmpty(s.DataProviderSchemes);
            s.AddIdentifiable(dataProviderScheme);
            CollectionAssert.IsNotEmpty(s.DataProviderSchemes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.DataProviderSchemes);

            var dataStructureObjectMock = new Mock<IDataStructureObject>();
            dataStructureObjectMock.Setup(o => o.StructureType)
                                   .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd));

            dataStructureObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            dataStructureObjectMock.Setup(o => o.Id).Returns("ID_DATASTRUCTUREOBJECT");
            dataStructureObjectMock.Setup(o => o.Version).Returns("1.2");
            IDataStructureObject dataStructureObject = dataStructureObjectMock.Object;
            s.AddDataStructure(dataStructureObject);
            CollectionAssert.IsNotEmpty(s.DataStructures);
            s.RemoveDataStructure(dataStructureObject);
            CollectionAssert.IsEmpty(s.DataStructures);
            s.AddIdentifiable(dataStructureObject);
            CollectionAssert.IsNotEmpty(s.DataStructures);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.DataStructures);

            var dataflowObjectMock = new Mock<IDataflowObject>();
            dataflowObjectMock.Setup(o => o.StructureType)
                              .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow));

            dataflowObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            dataflowObjectMock.Setup(o => o.Id).Returns("ID_DATAFLOWOBJECT");
            dataflowObjectMock.Setup(o => o.Version).Returns("1.2");
            IDataflowObject dataflowObject = dataflowObjectMock.Object;
            s.AddDataflow(dataflowObject);
            CollectionAssert.IsNotEmpty(s.Dataflows);
            s.RemoveDataflow(dataflowObject);
            CollectionAssert.IsEmpty(s.Dataflows);
            s.AddIdentifiable(dataflowObject);
            CollectionAssert.IsNotEmpty(s.Dataflows);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Dataflows);

            var hierarchicalCodelistObjectMock = new Mock<IHierarchicalCodelistObject>();
            hierarchicalCodelistObjectMock.Setup(o => o.StructureType)
                                          .Returns(
                                              SdmxStructureType.GetFromEnum(SdmxStructureEnumType.HierarchicalCodelist));

            hierarchicalCodelistObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            hierarchicalCodelistObjectMock.Setup(o => o.Id).Returns("ID_HIERARCHICALCODELISTOBJECT");
            hierarchicalCodelistObjectMock.Setup(o => o.Version).Returns("1.2");
            IHierarchicalCodelistObject hierarchicalCodelistObject = hierarchicalCodelistObjectMock.Object;
            s.AddHierarchicalCodelist(hierarchicalCodelistObject);
            CollectionAssert.IsNotEmpty(s.HierarchicalCodelists);
            s.RemoveHierarchicalCodelist(hierarchicalCodelistObject);
            CollectionAssert.IsEmpty(s.HierarchicalCodelists);
            s.AddIdentifiable(hierarchicalCodelistObject);
            CollectionAssert.IsNotEmpty(s.HierarchicalCodelists);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.HierarchicalCodelists);

            var metadataFlowMock = new Mock<IMetadataFlow>();
            metadataFlowMock.Setup(o => o.StructureType)
                            .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataFlow));

            metadataFlowMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            metadataFlowMock.Setup(o => o.Id).Returns("ID_METADATAFLOW");
            metadataFlowMock.Setup(o => o.Version).Returns("1.2");
            IMetadataFlow metadataFlow = metadataFlowMock.Object;
            s.AddMetadataFlow(metadataFlow);
            CollectionAssert.IsNotEmpty(s.Metadataflows);
            s.RemoveMetadataFlow(metadataFlow);
            CollectionAssert.IsEmpty(s.Metadataflows);
            s.AddIdentifiable(metadataFlow);
            CollectionAssert.IsNotEmpty(s.Metadataflows);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Metadataflows);

            var metadataStructureDefinitionObjectMock = new Mock<IMetadataStructureDefinitionObject>();
            metadataStructureDefinitionObjectMock.Setup(o => o.StructureType)
                                                 .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Msd));

            metadataStructureDefinitionObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            metadataStructureDefinitionObjectMock.Setup(o => o.Id).Returns("ID_METADATASTRUCTUREDEFINITIONOBJECT");
            metadataStructureDefinitionObjectMock.Setup(o => o.Version).Returns("1.2");
            IMetadataStructureDefinitionObject metadataStructureDefinitionObject =
                metadataStructureDefinitionObjectMock.Object;
            s.AddMetadataStructure(metadataStructureDefinitionObject);
            CollectionAssert.IsNotEmpty(s.MetadataStructures);
            s.RemoveMetadataStructure(metadataStructureDefinitionObject);
            CollectionAssert.IsEmpty(s.MetadataStructures);
            s.AddIdentifiable(metadataStructureDefinitionObject);
            CollectionAssert.IsNotEmpty(s.MetadataStructures);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.MetadataStructures);

            var organisationUnitSchemeObjectMock = new Mock<IOrganisationUnitSchemeObject>();
            organisationUnitSchemeObjectMock.Setup(o => o.StructureType)
                                            .Returns(
                                                SdmxStructureType.GetFromEnum(
                                                    SdmxStructureEnumType.OrganisationUnitScheme));

            organisationUnitSchemeObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            organisationUnitSchemeObjectMock.Setup(o => o.Id).Returns("ID_ORGANISATIONUNITSCHEMEOBJECT");
            organisationUnitSchemeObjectMock.Setup(o => o.Version).Returns("1.2");
            IOrganisationUnitSchemeObject organisationUnitSchemeObject = organisationUnitSchemeObjectMock.Object;
            s.AddOrganisationUnitScheme(organisationUnitSchemeObject);
            CollectionAssert.IsNotEmpty(s.OrganisationUnitSchemes);
            s.RemoveOrganisationUnitScheme(organisationUnitSchemeObject);
            CollectionAssert.IsEmpty(s.OrganisationUnitSchemes);
            s.AddIdentifiable(organisationUnitSchemeObject);
            CollectionAssert.IsNotEmpty(s.OrganisationUnitSchemes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.OrganisationUnitSchemes);

            var processObjectMock = new Mock<IProcessObject>();
            processObjectMock.Setup(o => o.StructureType)
                             .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Process));

            processObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            processObjectMock.Setup(o => o.Id).Returns("ID_PROCESSOBJECT");
            processObjectMock.Setup(o => o.Version).Returns("1.2");
            IProcessObject processObject = processObjectMock.Object;
            s.AddProcess(processObject);
            CollectionAssert.IsNotEmpty(s.Processes);
            s.RemoveProcess(processObject);
            CollectionAssert.IsEmpty(s.Processes);
            s.AddIdentifiable(processObject);
            CollectionAssert.IsNotEmpty(s.Processes);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Processes);

            var provisionAgreementObjectMock = new Mock<IProvisionAgreementObject>();
            provisionAgreementObjectMock.Setup(o => o.StructureType)
                                        .Returns(
                                            SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ProvisionAgreement));

            provisionAgreementObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            provisionAgreementObjectMock.Setup(o => o.Id).Returns("ID_PROVISIONAGREEMENTOBJECT");
            provisionAgreementObjectMock.Setup(o => o.Version).Returns("1.2");
            IProvisionAgreementObject provisionAgreementObject = provisionAgreementObjectMock.Object;
            s.AddProvisionAgreement(provisionAgreementObject);
            CollectionAssert.IsNotEmpty(s.ProvisionAgreements);
            s.RemoveProvisionAgreement(provisionAgreementObject);
            CollectionAssert.IsEmpty(s.ProvisionAgreements);
            s.AddIdentifiable(provisionAgreementObject);
            CollectionAssert.IsNotEmpty(s.ProvisionAgreements);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.ProvisionAgreements);

            var registrationObjectMock = new Mock<IRegistrationObject>();
            registrationObjectMock.Setup(o => o.StructureType)
                                  .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Registration));

            registrationObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            registrationObjectMock.Setup(o => o.Id).Returns("ID_REGISTRATIONOBJECT");
            registrationObjectMock.Setup(o => o.Version).Returns("1.2");
            IRegistrationObject registrationObject = registrationObjectMock.Object;
            s.AddRegistration(registrationObject);
            CollectionAssert.IsNotEmpty(s.Registrations);
            s.RemoveRegistration(registrationObject);
            CollectionAssert.IsEmpty(s.Registrations);
            s.AddIdentifiable(registrationObject);
            CollectionAssert.IsNotEmpty(s.Registrations);
            Assert.IsFalse(s2.HasRegistrations());
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Registrations);
            Assert.IsTrue(s2.HasRegistrations());

            var reportingTaxonomyObjectMock = new Mock<IReportingTaxonomyObject>();
            reportingTaxonomyObjectMock.Setup(o => o.StructureType)
                                       .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportingTaxonomy));

            reportingTaxonomyObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            reportingTaxonomyObjectMock.Setup(o => o.Id).Returns("ID_REPORTINGTAXONOMYOBJECT");
            reportingTaxonomyObjectMock.Setup(o => o.Version).Returns("1.2");
            IReportingTaxonomyObject reportingTaxonomyObject = reportingTaxonomyObjectMock.Object;
            s.AddReportingTaxonomy(reportingTaxonomyObject);
            CollectionAssert.IsNotEmpty(s.ReportingTaxonomys);
            s.RemoveReportingTaxonomy(reportingTaxonomyObject);
            CollectionAssert.IsEmpty(s.ReportingTaxonomys);
            s.AddIdentifiable(reportingTaxonomyObject);
            CollectionAssert.IsNotEmpty(s.ReportingTaxonomys);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.ReportingTaxonomys);

            var structureSetObjectMock = new Mock<IStructureSetObject>();
            structureSetObjectMock.Setup(o => o.StructureType)
                                  .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.StructureSet));

            structureSetObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            structureSetObjectMock.Setup(o => o.Id).Returns("ID_STRUCTURESETOBJECT");
            structureSetObjectMock.Setup(o => o.Version).Returns("1.2");
            IStructureSetObject structureSetObject = structureSetObjectMock.Object;
            s.AddStructureSet(structureSetObject);
            CollectionAssert.IsNotEmpty(s.StructureSets);
            s.RemoveStructureSet(structureSetObject);
            CollectionAssert.IsEmpty(s.StructureSets);
            s.AddIdentifiable(structureSetObject);
            CollectionAssert.IsNotEmpty(s.StructureSets);
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.StructureSets);

            var subscriptionObjectMock = new Mock<ISubscriptionObject>();
            subscriptionObjectMock.Setup(o => o.StructureType)
                                  .Returns(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Subscription));

            subscriptionObjectMock.Setup(o => o.AgencyId).Returns("TEST_AGENCY");
            subscriptionObjectMock.Setup(o => o.Id).Returns("ID_SUBSCRIPTIONOBJECT");
            subscriptionObjectMock.Setup(o => o.Version).Returns("1.2");
            ISubscriptionObject subscriptionObject = subscriptionObjectMock.Object;
            s.AddSubscription(subscriptionObject);
            CollectionAssert.IsNotEmpty(s.Subscriptions);
            s.RemoveSubscription(subscriptionObject);
            CollectionAssert.IsEmpty(s.Subscriptions);
            s.AddIdentifiable(subscriptionObject);
            CollectionAssert.IsNotEmpty(s.Subscriptions);
            Assert.IsFalse(s2.HasSubscriptions());
            s2.Merge(s);
            CollectionAssert.IsNotEmpty(s2.Subscriptions);
            Assert.IsTrue(s2.HasSubscriptions());

            var wildCard = new MaintainableRefObjectImpl("TEST_AGENCY", null, "1.2");
            var nothing = new MaintainableRefObjectImpl("NOTHING", null, "1.0");

            CollectionAssert.IsNotEmpty(s2.GetAgenciesSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetAgenciesSchemes(nothing));
            CollectionAssert.IsNotEmpty(
                s2.GetAgenciesSchemes(
                    new MaintainableRefObjectImpl(agencyScheme.AgencyId, agencyScheme.Id, agencyScheme.Version)));
            CollectionAssert.IsNotEmpty(s2.GetAgenciesSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetAgenciesSchemes(nothing));

            CollectionAssert.IsNotEmpty(s2.GetAttachmentConstraints("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetAttachmentConstraints("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetAttachmentConstraints(
                    new MaintainableRefObjectImpl(
                        attachmentConstraintObject.AgencyId, 
                        attachmentConstraintObject.Id, 
                        attachmentConstraintObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetAttachmentConstraints(wildCard));
            CollectionAssert.IsEmpty(s2.GetAttachmentConstraints(nothing));

            CollectionAssert.IsNotEmpty(s2.GetCategorisations("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetCategorisations("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetCategorisations(
                    new MaintainableRefObjectImpl(
                        categorisationObject.AgencyId, categorisationObject.Id, categorisationObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetCategorisations(wildCard));
            CollectionAssert.IsEmpty(s2.GetCategorisations(nothing));

            CollectionAssert.IsNotEmpty(s2.GetCategorySchemes("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetCategorySchemes("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetCategorySchemes(
                    new MaintainableRefObjectImpl(
                        categorySchemeObject.AgencyId, categorySchemeObject.Id, categorySchemeObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetCategorySchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetCategorySchemes(nothing));

            CollectionAssert.IsNotEmpty(s2.GetCodelists("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetCodelists("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetCodelists(
                    new MaintainableRefObjectImpl(codelistObject.AgencyId, codelistObject.Id, codelistObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetCodelists(wildCard));
            CollectionAssert.IsEmpty(s2.GetCodelists(nothing));

            CollectionAssert.IsNotEmpty(s2.GetConceptSchemes("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetConceptSchemes("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetConceptSchemes(
                    new MaintainableRefObjectImpl(
                        conceptSchemeObject.AgencyId, conceptSchemeObject.Id, conceptSchemeObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetConceptSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetConceptSchemes(nothing));

            CollectionAssert.IsNotEmpty(s2.GetContentConstraintObjects("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetContentConstraintObjects("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetContentConstraintObjects(
                    new MaintainableRefObjectImpl(
                        contentConstraintObject.AgencyId, contentConstraintObject.Id, contentConstraintObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetContentConstraintObjects(wildCard));
            CollectionAssert.IsEmpty(s2.GetContentConstraintObjects(nothing));

            CollectionAssert.IsNotEmpty(s2.GetDataConsumerSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetDataConsumerSchemes(nothing));
            CollectionAssert.IsNotEmpty(
                s2.GetDataConsumerSchemes(
                    new MaintainableRefObjectImpl(
                        dataConsumerScheme.AgencyId, dataConsumerScheme.Id, dataConsumerScheme.Version)));
            CollectionAssert.IsNotEmpty(s2.GetDataConsumerSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetDataConsumerSchemes(nothing));

            CollectionAssert.IsNotEmpty(s2.GetDataProviderSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetDataProviderSchemes(nothing));
            CollectionAssert.IsNotEmpty(
                s2.GetDataProviderSchemes(
                    new MaintainableRefObjectImpl(
                        dataProviderScheme.AgencyId, dataProviderScheme.Id, dataProviderScheme.Version)));
            CollectionAssert.IsNotEmpty(s2.GetDataProviderSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetDataProviderSchemes(nothing));

            CollectionAssert.IsNotEmpty(s2.GetDataStructures("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetDataStructures("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetDataStructures(
                    new MaintainableRefObjectImpl(
                        dataStructureObject.AgencyId, dataStructureObject.Id, dataStructureObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetDataStructures(wildCard));
            CollectionAssert.IsEmpty(s2.GetDataStructures(nothing));

            CollectionAssert.IsNotEmpty(s2.GetDataflows("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetDataflows("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetDataflows(
                    new MaintainableRefObjectImpl(dataflowObject.AgencyId, dataflowObject.Id, dataflowObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetDataflows(wildCard));
            CollectionAssert.IsEmpty(s2.GetDataflows(nothing));

            CollectionAssert.IsNotEmpty(s2.GetHierarchicalCodelists("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetHierarchicalCodelists("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetHierarchicalCodelists(
                    new MaintainableRefObjectImpl(
                        hierarchicalCodelistObject.AgencyId, 
                        hierarchicalCodelistObject.Id, 
                        hierarchicalCodelistObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetHierarchicalCodelists(wildCard));
            CollectionAssert.IsEmpty(s2.GetHierarchicalCodelists(nothing));

            CollectionAssert.IsNotEmpty(s2.GetMetadataStructures("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetMetadataStructures("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetMetadataStructures(
                    new MaintainableRefObjectImpl(
                        metadataStructureDefinitionObject.AgencyId, 
                        metadataStructureDefinitionObject.Id, 
                        metadataStructureDefinitionObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetMetadataStructures(wildCard));
            CollectionAssert.IsEmpty(s2.GetMetadataStructures(nothing));

            CollectionAssert.IsNotEmpty(s2.GetMetadataflows("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetMetadataflows("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetMetadataflows(
                    new MaintainableRefObjectImpl(metadataFlow.AgencyId, metadataFlow.Id, metadataFlow.Version)));
            CollectionAssert.IsNotEmpty(s2.GetMetadataflows(wildCard));
            CollectionAssert.IsEmpty(s2.GetMetadataflows(nothing));

            CollectionAssert.IsNotEmpty(s2.GetOrganisationUnitSchemes("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetOrganisationUnitSchemes("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetOrganisationUnitSchemes(
                    new MaintainableRefObjectImpl(
                        organisationUnitSchemeObject.AgencyId, 
                        organisationUnitSchemeObject.Id, 
                        organisationUnitSchemeObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetOrganisationUnitSchemes(wildCard));
            CollectionAssert.IsEmpty(s2.GetOrganisationUnitSchemes(nothing));

            CollectionAssert.IsNotEmpty(s2.GetProcesses("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetProcesses("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetProcesses(
                    new MaintainableRefObjectImpl(processObject.AgencyId, processObject.Id, processObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetProcesses(wildCard));
            CollectionAssert.IsEmpty(s2.GetProcesses(nothing));

            CollectionAssert.IsNotEmpty(s2.GetProvisionAgreements("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetProvisionAgreements("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetProvisionAgreements(
                    new MaintainableRefObjectImpl(
                        provisionAgreementObject.AgencyId, provisionAgreementObject.Id, provisionAgreementObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetProvisionAgreements(wildCard));
            CollectionAssert.IsEmpty(s2.GetProvisionAgreements(nothing));

            CollectionAssert.IsNotEmpty(s2.GetRegistrations("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetRegistrations("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetRegistrations(
                    new MaintainableRefObjectImpl(
                        registrationObject.AgencyId, registrationObject.Id, registrationObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetRegistrations(wildCard));
            CollectionAssert.IsEmpty(s2.GetRegistrations(nothing));

            CollectionAssert.IsNotEmpty(s2.GetReportingTaxonomys("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetReportingTaxonomys("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetReportingTaxonomys(
                    new MaintainableRefObjectImpl(
                        reportingTaxonomyObject.AgencyId, reportingTaxonomyObject.Id, reportingTaxonomyObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetReportingTaxonomys(wildCard));
            CollectionAssert.IsEmpty(s2.GetReportingTaxonomys(nothing));

            CollectionAssert.IsNotEmpty(s2.GetStructureSets("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetStructureSets("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetStructureSets(
                    new MaintainableRefObjectImpl(
                        structureSetObject.AgencyId, structureSetObject.Id, structureSetObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetStructureSets(wildCard));
            CollectionAssert.IsEmpty(s2.GetStructureSets(nothing));

            CollectionAssert.IsNotEmpty(s2.GetSubscriptions("TEST_AGENCY"));
            CollectionAssert.IsEmpty(s2.GetSubscriptions("NOTHING"));
            CollectionAssert.IsNotEmpty(
                s2.GetSubscriptions(
                    new MaintainableRefObjectImpl(
                        subscriptionObject.AgencyId, subscriptionObject.Id, subscriptionObject.Version)));
            CollectionAssert.IsNotEmpty(s2.GetSubscriptions(wildCard));
            CollectionAssert.IsEmpty(s2.GetSubscriptions(nothing));

            Assert.IsTrue(s2.HasStructures());
            foreach (SdmxStructureType structureType in SdmxStructureType.Values)
            {
                if (structureType.IsMaintainable)
                {
                    CollectionAssert.IsNotEmpty(s2.GetMaintainables(structureType.EnumType));
                    CollectionAssert.IsEmpty(s3.GetMaintainables(structureType.EnumType));
                }
            }

            var mutableObjects = s2.MutableObjects;
            Assert.IsNotNull(mutableObjects);
            
            var s5 = new SdmxObjectsImpl(new HeaderImpl("PAOK", "OLE"), s2.Dataflows);
            CollectionAssert.IsNotEmpty(s5.Dataflows);
            CollectionAssert.IsNotEmpty(s5.GetAllMaintainables(SdmxStructureEnumType.HierarchicalCodelist));
            CollectionAssert.IsEmpty(s5.GetAllMaintainables(SdmxStructureEnumType.Dataflow));
        }
        /// <summary>
        /// Processes the dataWhere element to get the DSD reference and retrieve the respective DSD.
        /// It throws an exception if the DSD cannot be retrieved.
        /// </summary>
        /// <param name="dataWhere">
        /// The data where.
        /// </param>
        /// <param name="structureRetrievalManager">
        /// The structure retrieval manager.
        /// </param>
        /// <param name="dataFlow">
        /// The data flow.
        /// </param>
        /// <returns>
        /// The data structure object.
        /// </returns>
        private IDataStructureObject GetDataWhereDataStrucuture(DataParametersAndType dataWhere,
                                            ISdmxObjectRetrievalManager structureRetrievalManager,
                                            IDataflowObject dataFlow)
        {
            IDataStructureObject dataStructure = null;

            if (dataWhere.DataStructure != null && dataWhere.DataStructure.Count > 0)
            {
                var refBaseType = dataWhere.DataStructure[0].GetTypedRef<DataStructureRefType>();
                string dataStructureAgency = refBaseType.agencyID;
                string dataStructureId = refBaseType.id;
                string dataStructureVersion = null;
                if (refBaseType.version != null)
                    dataStructureVersion = refBaseType.version;

                IMaintainableRefObject dsdRef = new MaintainableRefObjectImpl(dataStructureAgency, dataStructureId, dataStructureVersion);
                dataStructure = structureRetrievalManager.GetMaintainableObject<IDataStructureObject>(dsdRef);
                if (dataStructure == null)
                {
                    throw new SdmxNoResultsException("DSD not found: " + dsdRef);
                }
            }
            else
            {
                IMaintainableRefObject dsdRef = dataFlow.DataStructureRef.MaintainableReference;
                dataStructure = structureRetrievalManager.GetMaintainableObject<IDataStructureObject>(dsdRef);
                if (dataStructure == null)
                {
                    throw new SdmxNoResultsException("Data Structure not found: " + dsdRef);
                }
            }
            return dataStructure;
        }
        /// <summary>
        /// Processes the dataWhere element to get the dataflow reference and retrieve the respective dataflow.
        /// It throws an exception if the dataflow retrieved is null
        /// </summary>
        /// <param name="dataWhere">
        /// The data where.
        /// </param>
        /// <param name="structureRetrievalManager">
        /// The structure retrieval manager.
        /// </param>
        /// <returns>
        /// The data flow object.
        /// </returns>
        private IDataflowObject GetDataWhereDataFlow(DataParametersAndType dataWhere, ISdmxObjectRetrievalManager structureRetrievalManager)
        {
            IDataflowObject dataFlow = null;
            if (dataWhere.Dataflow != null && dataWhere.Dataflow.Count > 0)
            {
                var dataflowRefType = dataWhere.Dataflow[0].GetTypedRef<DataflowRefType>();
                string dataFlowAgency = dataflowRefType.agencyID;
                string dataFlowId = dataflowRefType.id;
                string dataFlowVersion = null; // null if not specified so as to get the latest

                if (dataflowRefType.version != null)
                {
                    dataFlowVersion = dataflowRefType.version;
                }

                IMaintainableRefObject flowRef = new MaintainableRefObjectImpl(dataFlowAgency, dataFlowId, dataFlowVersion);
                dataFlow = structureRetrievalManager.GetMaintainableObject<IDataflowObject>(flowRef);
                if (dataFlow == null)
                {
                    throw new SdmxNoResultsException("Dataflow not found: " + flowRef);
                }
            }
            else
            {
                throw new ArgumentException("Can not create DataQuery, Dataflow is required");
            }
            return dataFlow;
        }
        /// <summary>
        /// Builds a data provider bean from DataProviderReferenceType from XML 
        /// </summary>
        /// <param name="dataProviderRef">
        /// The data provider reference.
        /// </param>
        /// <param name="structureRetrievalManager">
        /// The structure retrieval manager.
        /// </param>
        /// <returns>
        /// The data provider.
        /// </returns>
        private IDataProvider ProcessDataProviderType(DataProviderReferenceType dataProviderRef, ISdmxObjectRetrievalManager structureRetrievalManager)
        {
            var dataProviderRefType = dataProviderRef.GetTypedRef<DataProviderRefType>();
            string agencyId = dataProviderRefType.agencyID;
            string id = dataProviderRefType.maintainableParentID;
            string version = dataProviderRefType.maintainableParentVersion;

            IMaintainableRefObject orgSchemeRef = new MaintainableRefObjectImpl(agencyId, id, version);
            IDataProviderScheme dataProviderScheme = structureRetrievalManager.GetMaintainableObject<IDataProviderScheme>(orgSchemeRef);
            foreach (IDataProvider dp in dataProviderScheme.Items)
            {
                if (dp.Id.Equals(dataProviderRefType.id))
                {
                    return dp;
                }
            }
            return null;
        }
        public static List<ICategoryObject> GetCategoryScheme()
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            SDMXIdentifier sdmxKey = new SDMXIdentifier();
            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            ISet<Org.Sdmxsource.Sdmx.Api.Model.Mutable.CategoryScheme.ICategorySchemeMutableObject> categories =
                manager.GetMutableCategorySchemeObjects(query, false, false);

            List<Org.Sdmxsource.Sdmx.Api.Model.Objects.CategoryScheme.ICategoryObject> cats = new List<Org.Sdmxsource.Sdmx.Api.Model.Objects.CategoryScheme.ICategoryObject>();

            foreach (Org.Sdmxsource.Sdmx.Api.Model.Mutable.CategoryScheme.ICategorySchemeMutableObject catSchm in categories)
            {
                cats.AddRange(GetCategories(catSchm.ImmutableInstance.Items));
            }

            return cats;
        }
        /// <summary>
        /// Retrieve the primary key from mapping store for the given period code list.
        /// </summary>
        /// <param name="timeFormat">
        /// The time format.
        /// </param>
        /// <returns>
        /// The  primary key.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Value in <paramref name="timeFormat"/> not supported.
        /// </exception>
        public ICodelistMutableObject RetrievePeriodCodelist(TimeFormat timeFormat)
        {
            PeriodObject periodObject;
            if (PeriodCodelist.PeriodCodelistIdMap.TryGetValue(timeFormat.FrequencyCode, out periodObject))
            {
                var maintainableRef = new MaintainableRefObjectImpl(PeriodCodelist.Agency, periodObject.Id, PeriodCodelist.Version);
                return this._mutableRetrievalManager.GetMutableCodelist(maintainableRef, false, false);
            }

            throw new ArgumentOutOfRangeException("timeFormat", timeFormat, Resources.ErrorNotSupported);
        }
        public static ICodelistObject GetCodelist(SDMXIdentifier sdmxKey)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            ICodelistMutableObject codelist = manager.GetMutableCodelist(query, false, false);

            if (codelist != null) return codelist.ImmutableInstance;

            return GetConceptSchemeItems(sdmxKey);
        }
        public void TestGetLatestAuthResult(SdmxStructureEnumType structureEnumType)
        {
            var structureType = SdmxStructureType.GetFromEnum(structureEnumType);
            var mutableSearchManager = this.GetAuthMutableSearchManager(this._connectionString);
            IStructureReference reference = new StructureReferenceImpl(new MaintainableRefObjectImpl(), structureType);
            switch (structureType.EnumType)
            {
                case SdmxStructureEnumType.Dataflow:
                    var list = this._fullRetrievalManager.GetMutableMaintainables(reference, false, false);
                    foreach (var maintainableMutableObject in list)
                    {
                        IMaintainableRefObject maintainableRefObject = new MaintainableRefObjectImpl(maintainableMutableObject.AgencyId, maintainableMutableObject.Id, null);

                        var mutableObject = mutableSearchManager.GetLatest(maintainableMutableObject, new[] { maintainableRefObject });
                        Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString());
                    }

                    break;
            }
        }
        public static ICodelistObject GetConceptSchemeItems(SDMXIdentifier sdmxKey)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Codelist.CodelistMutableCore codelist =
                new Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Codelist.CodelistMutableCore();

            codelist.Id = sdmxKey.id;
            codelist.AgencyId = sdmxKey.agencyid;
            codelist.Version = sdmxKey.version;
            codelist.StructureType = Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureType.GetFromEnum(Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.CodeList);
            //codelist.StartDate = codelist.EndDate = DateTime.Now;
            codelist.FinalStructure = Org.Sdmxsource.Sdmx.Api.Constants.TertiaryBool.GetFromEnum(Org.Sdmxsource.Sdmx.Api.Constants.TertiaryBoolEnumType.True);

            IConceptSchemeMutableObject concepts = manager.GetMutableConceptScheme(query, false, false);

            foreach (ITextTypeWrapper IText in concepts.ImmutableInstance.Names)
                codelist.Names.Add(new Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Base.TextTypeWrapperMutableCore(IText));
            foreach (ITextTypeWrapper IText in concepts.ImmutableInstance.Descriptions)
                codelist.Descriptions.Add(new Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Base.TextTypeWrapperMutableCore(IText));

            foreach (IConceptObject concept in concepts.ImmutableInstance.Items)
            {

                Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Codelist.CodeMutableCore code =
                    new Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Codelist.CodeMutableCore();

                code.Id = concept.Id;
                code.ParentCode = concept.ParentConcept;

                foreach (ITextTypeWrapper IText in concept.Names)
                    code.Names.Add(new Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Base.TextTypeWrapperMutableCore(IText));
                foreach (ITextTypeWrapper IText in concept.Descriptions)
                    code.Descriptions.Add(new Org.Sdmxsource.Sdmx.SdmxObjects.Model.Mutable.Base.TextTypeWrapperMutableCore(IText));

                codelist.AddItem(code);

            }
            return codelist.ImmutableInstance;
        }
Exemplo n.º 22
0
        private IComplexStructureQuery RetrieveDataflow(string id, string agency, string version)
        {
            IMaintainableRefObject df = new MaintainableRefObjectImpl(agency,id , version);
            var dataflowRefBean = new StructureReferenceImpl(df,SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow));
            IRestStructureQuery structureQueryDataflow = new RESTStructureQueryCore(dataflowRefBean);

            IBuilder<IComplexStructureQuery, IRestStructureQuery> transformerDataFlow = new StructureQuery2ComplexQueryBuilder();

            IComplexStructureQuery complexStructureQueryDataflow = transformerDataFlow.Build(structureQueryDataflow);

            IList<SdmxStructureType> specificObjects = new List<SdmxStructureType>();
            specificObjects.Add(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd));

            IComplexStructureQueryMetadata complexStructureQueryMetadataWithDsd =
                    new ComplexStructureQueryMetadataCore(false,
                    ComplexStructureQueryDetail.GetFromEnum(ComplexStructureQueryDetailEnumType.Full),
                    ComplexMaintainableQueryDetail.GetFromEnum(ComplexMaintainableQueryDetailEnumType.Full),
                    StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific),
                    specificObjects);

            IComplexStructureQuery complexStructureQueryTempDataflow = new ComplexStructureQueryCore(
                    complexStructureQueryDataflow.StructureReference, complexStructureQueryMetadataWithDsd);

            return complexStructureQueryTempDataflow;
        }
        public static IDataStructureObject GetDSD(SDMXIdentifier sdmxKey, bool stub)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxKey.agencyid, sdmxKey.id, sdmxKey.version);

            IDataStructureMutableObject dsd = manager.GetMutableDataStructure(query, false, stub);

            return dsd.ImmutableInstance;
        }
        /// <summary>
        /// Retrieve allowed dataflows for user from the database
        /// </summary>
        /// <param name="user">
        /// The user
        /// </param>
        protected void RetrieveAllowedDataFlows(IUser user)
        {
            this._dataflowSet.Clear();
            this._dataflowIdSet.Clear();
            string userParam = this._database.BuildParameterName(DbConstants.UserParamName);

            string sql =
                this._selectQuery.Replace(DbConstants.UserMacro, userParam).Replace(
                    DbConstants.DataflowIdMacro, DbConstants.DataflowIdField).Replace(
                        DbConstants.DataflowVersionMacro, DbConstants.DataflowVersionField).Replace(
                            DbConstants.DataflowAgencyIdMacro, DbConstants.DataflowAgencyIdField);

            using (DbCommand command = this._database.GetSqlStringCommand(sql))
            {
                this._database.AddInParameter(command, DbConstants.UserParamName, DbType.String, user.UserName);
                using (IDataReader reader = this._database.ExecuteReader(command))
                {
                    int idIdx = reader.GetOrdinal(DbConstants.DataflowIdField);
                    int versionIdx = reader.GetOrdinal(DbConstants.DataflowVersionField);
                    int agencyIdx = reader.GetOrdinal(DbConstants.DataflowAgencyIdField);
                    while (reader.Read())
                    {
                        IMaintainableRefObject dataflowRefBean = new MaintainableRefObjectImpl
                            {
                                MaintainableId = AuthUtils.ConvertDBValue<string>(reader.GetValue(idIdx)), 
                                AgencyId = AuthUtils.ConvertDBValue<string>(reader.GetValue(agencyIdx)), 
                                Version = AuthUtils.ConvertDBValue<string>(reader.GetValue(versionIdx))
                            };
                        if (!this._dataflowSet.ContainsKey(dataflowRefBean))
                        {
                            this._dataflowSet.Add(dataflowRefBean, dataflowRefBean.MaintainableId);
                            List<IMaintainableRefObject> dataflowRefBeans;
                            if (!this._dataflowIdSet.TryGetValue(dataflowRefBean.MaintainableId, out dataflowRefBeans))
                            {
                                dataflowRefBeans = new List<IMaintainableRefObject>();
                                this._dataflowIdSet.Add(dataflowRefBean.MaintainableId, dataflowRefBeans);
                            }

                            dataflowRefBeans.Add(dataflowRefBean);
                        }
                    }
                }
            }
        }
        public static System.IO.MemoryStream GetStreamSDMXObject(SDMXIdentifier sdmxIdentity, Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType structureType)
        {
            ISdmxMutableObjectRetrievalManager manager = GetManager();

            IMaintainableRefObject query = new MaintainableRefObjectImpl(sdmxIdentity.agencyid, sdmxIdentity.id, sdmxIdentity.version);

            Org.Sdmxsource.Sdmx.Api.Model.Objects.ISdmxObjects sdmxObjects =
                new Org.Sdmxsource.Sdmx.Util.Objects.Container.SdmxObjectsImpl();

            switch (structureType)
            {
                case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.AgencyScheme:
                    sdmxObjects.AddAgencyScheme(manager.GetMutableAgencyScheme(query, false, false).ImmutableInstance);
                    break;
                case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.CategoryScheme:
                    sdmxObjects.AddCategoryScheme(manager.GetMutableCategoryScheme(query, false, false).ImmutableInstance);
                    break;
                case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.ConceptScheme:
                    sdmxObjects.AddConceptScheme(manager.GetMutableConceptScheme(query, false, false).ImmutableInstance);
                    break;
                case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.CodeList:
                    sdmxObjects.AddCodelist(manager.GetMutableCodelist(query, false, false).ImmutableInstance);
                    break;
                case Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.Dsd:
                    sdmxObjects.AddDataStructure(manager.GetMutableDataStructure(query, false, false).ImmutableInstance);
                    break;
            }

            System.IO.MemoryStream mem = GetStream(sdmxObjects, Org.Sdmxsource.Sdmx.Api.Constants.StructureOutputFormatEnumType.SdmxV21StructureDocument);

            return mem;
        }
 public void TestEquals(string agencyId, bool hasAgency, string id, bool hasId, string version, bool hasVersion, bool equals)
 {
     var maintRef = new MaintainableRefObjectImpl(agencyId, id, version);
     Assert.AreEqual(hasAgency, maintRef.HasAgencyId());
     Assert.AreEqual(hasVersion, maintRef.HasVersion());
     Assert.AreEqual(hasId, maintRef.HasMaintainableId());
     var moq = new Mock<IMaintainableRefObject>();
     moq.Setup(o => o.MaintainableId).Returns("TEST");
     moq.Setup(o => o.AgencyId).Returns("AGENCY");
     moq.Setup(o => o.Version).Returns("2.0");
     moq.Setup(o => o.HasAgencyId()).Returns(true);
     moq.Setup(o => o.HasVersion()).Returns(true);
     moq.Setup(o => o.HasMaintainableId()).Returns(true);
     Assert.AreEqual(equals, maintRef.Equals(moq.Object));
 }
Exemplo n.º 27
0
        /// <summary>
        /// Get the latest allowed dataflow with version and agency (if are either defined)
        /// </summary>
        /// <param name="dataflowId">
        /// The dataflow id
        /// </param>
        /// <returns>
        /// The allowed dataflow with biggest version
        /// </returns>
        public IMaintainableRefObject GetAllowedDataflow(string dataflowId)
        {
            IMaintainableRefObject actualDataflow = null;

            Match conventionUsed = _dataflowRegex.Match(dataflowId);
            if (conventionUsed.Success)
            {
                actualDataflow = new MaintainableRefObjectImpl
                    {
                        AgencyId = conventionUsed.Groups["agency"].Value, 
                        MaintainableId = conventionUsed.Groups["id"].Value, 
                        Version = conventionUsed.Groups["version"].Value
                    };
                if (!this._authorizationProvider.AccessControl(this._user, actualDataflow))
                {
                    actualDataflow = null;
                }
            }
            else
            {
                IEnumerable<IMaintainableRefObject> dataflowRefBeans = this._authorizationProvider.GetDataflows(
                    this._user, dataflowId);
                foreach (IMaintainableRefObject dataflowRefBean in dataflowRefBeans)
                {
                    if (actualDataflow == null
                        || string.CompareOrdinal(actualDataflow.Version, dataflowRefBean.Version) < 0)
                    {
                        actualDataflow = dataflowRefBean;
                    }
                }
            }

            return actualDataflow;
        }
        /// <summary>
        /// Write dataflows
        /// </summary>
        /// <param name="dataflows">
        /// The dataflows to write
        /// </param>
        /// <param name="categorisations">
        /// The categorisations.
        /// </param>
        private void WriteDataflows(
            IEnumerable<IDataflowMutableObject> dataflows, IEnumerable<ICategorisationMutableObject> categorisations)
        {
            IDictionaryOfLists<IMaintainableRefObject, ICategorisationMutableObject> categorisationMap =
                BuildCategorisationMap(categorisations);

            this.WriteStartElement(this.RootNamespace, ElementNameTable.Dataflows);
            foreach (IDataflowMutableObject dataflow in dataflows)
            {
                this.WriteMaintainableArtefact(ElementNameTable.Dataflow, dataflow);
                if (dataflow.DataStructureRef != null)
                {
                    this.WriteKeyFamilyRef(dataflow.DataStructureRef);
                }

                var dataflowReference = new MaintainableRefObjectImpl(dataflow.AgencyId, dataflow.Id, dataflow.Version);

                foreach (KeyValuePair<IMaintainableRefObject, IList<ICategorisationMutableObject>> catRef in
                    categorisationMap)
                {
                    if (dataflowReference.Equals(catRef.Key))
                    {
                        foreach (ICategorisationMutableObject categorisation in catRef.Value)
                        {
                            this.WriteCategoryRef(categorisation.CategoryReference);
                        }
                    }
                }

                this.WriteAnnotations(ElementNameTable.Annotations, dataflow.Annotations);
                this.WriteEndElement();
            }

            this.WriteEndElement();
        }