public IDataflowMutableObject buildDataFlow(string id, string agency, string version) { IDataflowMutableObject df = new DataflowMutableCore(); df.Id = id; df.AgencyId = agency; df.Version = version; return df; }
public void TestSaveStructure() { IDataflowMutableObject dataflow = new DataflowMutableCore { Id = "TEST_DF", AgencyId = "TEST_AGENCY", DataStructureRef = new StructureReferenceImpl("TEST_AGENCY", "TEST_DSD", "1.0", SdmxStructureEnumType.Dsd) }; dataflow.AddName("en", "A test DF"); var retrievalManager = new InMemoryRetrievalManager(); Assert.AreEqual(0, retrievalManager.GetMaintainableObjects<IDataflowObject>().Count); retrievalManager.SaveStructure(dataflow.ImmutableInstance); Assert.AreEqual(1, retrievalManager.GetMaintainableObjects<IDataflowObject>().Count); }
/// <summary> /// Create a ImmutableInstance of Dataflow /// </summary> /// <param name="AgencyId">Agency Id</param> /// <param name="Version">Artefact Version</param> /// <returns>IDataflowObject</returns> public IDataflowObject BuildDataflow(string AgencyId, string Version) { try { IDataflowMutableObject df = new DataflowMutableCore(); df.AgencyId = AgencyId; df.Version = Version; df.Id = this.Code; if (this.Names != null) { foreach (SdmxObjectNameDescription nome in this.Names) { df.AddName(nome.Lingua, nome.Name); } } if (!this.ParsingObject.ReturnStub) { if (this.DataStrunctureRef != null) { df.DataStructureRef = this.DataStrunctureRef; } else { df.DataStructureRef = ReferenceBuilder.CreateDSDStructureReference(this.Code);//Creo una struttura di riferimento } } df.FinalStructure = TertiaryBool.ParseBoolean(true); if (this.ParsingObject.isReferenceOf || this.ParsingObject.ReturnStub) { df.ExternalReference = TertiaryBool.ParseBoolean(true); df.StructureURL = RetreivalStructureUrl.Get(this, df.Id, df.AgencyId, df.Version); } return(df.ImmutableInstance); } catch (SdmxException) { throw; } catch (Exception ex) { throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex); } }
public void TestDimensionAtObservation() { IDataStructureMutableObject dsd = new DataStructureMutableCore() { Id = "TEST", AgencyId = "TEST_AGENCY", Version = "1.0" }; dsd.AddName("en", "Test name"); IDimensionMutableObject dimension = new DimensionMutableCore(); dimension.ConceptRef = new StructureReferenceImpl("TEST_AGENCY", "TEST_CONCEPTS", "1.0", SdmxStructureEnumType.Concept, "TEST_DIM"); dimension.Representation = new RepresentationMutableCore { Representation = new StructureReferenceImpl("TEST_AGENCY", "CL_TEST", "2.0", SdmxStructureEnumType.CodeList) }; dsd.AddDimension(dimension); dsd.AddPrimaryMeasure(new StructureReferenceImpl("TEST_AGENCY", "TEST_CONCEPTS", "1.0", SdmxStructureEnumType.Concept, "OBS_VALUE")); var immutableDsd = dsd.ImmutableInstance; var dataflowMutable = new DataflowMutableCore { Id = "TEST_DF", AgencyId = "TEST_AGENCY", Version = "1.2" }; dataflowMutable.AddName("en", "Test"); dataflowMutable.DataStructureRef = immutableDsd.AsReference; var dataflow = dataflowMutable.ImmutableInstance; IDataQuery query = new DataQueryImpl(immutableDsd, null, DataQueryDetail.GetFromEnum(DataQueryDetailEnumType.Full),null,null, null, dataflow, "AllDimensions", new HashSet<IDataQuerySelection>(), null, null); Assert.AreEqual("AllDimensions", query.DimensionAtObservation); }
public void TestStructureReferenceIsMatch(string urn, bool expectedResult) { var df = new DataflowMutableCore { AgencyId = "TFFS.ABC", Id = "EXTERNAL_DEBT", Version = "1.0" }; df.AddName("en", "Test"); df.DataStructureRef = new StructureReferenceImpl("TEST_AG","TST", "1.0", SdmxStructureEnumType.Dsd); var impl = new StructureReferenceImpl(urn); IDataflowObject immutableInstance = df.ImmutableInstance; Assert.AreEqual(expectedResult, impl.IsMatch(immutableInstance)); if (expectedResult) { Assert.IsTrue(immutableInstance.DeepEquals(impl.GetMatch(immutableInstance), true)); } else { Assert.IsNull(impl.GetMatch(immutableInstance)); } var cross = new CrossReferenceImpl(immutableInstance, impl); Assert.IsTrue(cross.ReferencedFrom.DeepEquals(immutableInstance, true)); Assert.AreEqual(cross.CreateMutableInstance().TargetUrn, impl.TargetUrn); }
/// <summary> /// Builds the dataflow. /// </summary> /// <param name="id">The identifier.</param> /// <param name="dsdReference">The Data Structure Definition reference.</param> /// <returns>The <see cref="IDataflowObject" />.</returns> private static IDataflowObject BuildDataflow(string id, IStructureReference dsdReference) { IDataflowMutableObject dataflow = new DataflowMutableCore { Id = id, AgencyId = "TEST", Version = "1.1", DataStructureRef = dsdReference }; dataflow.AddName("en", "Test dataflow"); return dataflow.ImmutableInstance; }
/// <summary> /// Handles the Structure top level elements /// This includes Codelist /// </summary> /// <param name="parent"> /// The parent <see cref="IMutableObjects"/> /// </param> /// <param name="localName"> /// The name of the current xml element /// </param> /// <returns> /// The <see cref="StructureReaderBaseV20.ElementActions"/>. /// </returns> protected override ElementActions HandleTopLevel(IMutableObjects parent, object localName) { ElementActions actions = null; if (NameTableCache.IsElement(localName, ElementNameTable.Dataflow)) { var dataflow = new DataflowMutableCore(); ParseAttributes(dataflow, this.Attributes); parent.AddDataflow(dataflow); this._currentDataflow = dataflow; actions = this.AddNameableAction(dataflow, this.HandleChildElements); } return actions; }
/// <summary> /// Builds a dataflow that references a dsd /// </summary> /// <param name="id"> /// the id of the dataflow /// </param> /// <param name="name"> /// the english name of the dataflow /// </param> /// <param name="dsd"> /// the data structure that is being referenced by the dsd. /// </param> /// <returns> /// the newly created dataflow. /// </returns> public IDataflowObject BuildDataflow(string id, string name, IDataStructureObject dsd) { IDataflowMutableObject dataflow = new DataflowMutableCore(); dataflow.AgencyId = "SDMXSOURCE"; dataflow.Id = id; dataflow.AddName("en", name); dataflow.DataStructureRef = dsd.AsReference; return dataflow.ImmutableInstance; }