public void TestWriteCodedTimeDimensionV20() { IDimensionMutableObject dimension = new DimensionMutableCore(); dimension.TimeDimension = true; dimension.Id = DimensionObject.TimeDimensionFixedId; dimension.ConceptRef = new StructureReferenceImpl("TEST_AGENCY", "TEST_CONCEPTS", "1.0", SdmxStructureEnumType.Concept, "TIME_PERIOD"); var structureReference = new StructureReferenceImpl("TEST_AGENCY", "CL_TIME_PERIOD", "1.0", SdmxStructureEnumType.CodeList); dimension.Representation = new RepresentationMutableCore() { Representation = structureReference }; var immutable = BuildDataStructureObject(dimension); using (var stream = new MemoryStream()) { this._writerManager.WriteStructure(immutable, new HeaderImpl("TEST", "TEST"), new SdmxStructureFormat(StructureOutputFormat.GetFromEnum(StructureOutputFormatEnumType.SdmxV2StructureDocument)), stream); stream.Position = 0; using (var location = new MemoryReadableLocation(stream.ToArray())) { var workspace = _parsingManager.ParseStructures(location); var dsd = workspace.GetStructureObjects(false).DataStructures.First(); var timeDimension = dsd.TimeDimension; Assert.IsTrue(timeDimension.HasCodedRepresentation()); Assert.AreEqual(timeDimension.Representation.Representation.AgencyId, structureReference.AgencyId); Assert.AreEqual(timeDimension.Representation.Representation.MaintainableId, structureReference.MaintainableId); Assert.AreEqual(timeDimension.Representation.Representation.Version, structureReference.Version); } } }
public IStructureReference CreateCategorySchemeReference() { IStructureReference reference = new StructureReferenceImpl( "SDMX", "SDMXStatMatDomainsWD1", "1.0", SdmxStructureEnumType.CategoryScheme); return reference; }
protected void btnSaveCategorisation_Click(object sender, EventArgs e) { // Controllo su selezione categoria if (String.IsNullOrEmpty(tvCategory.SelectedValue)) return; // Creo la Categorisation e la salvo // Creazione delle info di base della categorisation // Recupero della category selezionata string catsID = cmbCategorySchemes.SelectedValue.Replace(',', '_').Replace(".", "") + "_" + tvCategory.SelectedValue + "-" + ucArtIdentity.ID + "_" + ucArtIdentity.Agency + "_" + ucArtIdentity.Version.Replace(".", ""); ICategorisationMutableObject categorisation = new CategorisationMutableCore(); categorisation.Id = catsID; categorisation.AgencyId = ucArtIdentity.Agency; categorisation.Version = ucArtIdentity.Version; categorisation.AddName("en", "Categorisation " + ucArtIdentity.ToString()); IStructureReference structureRef = new StructureReferenceImpl(ucArtIdentity.Agency, ucArtIdentity.ID, ucArtIdentity.Version, GetStructureType()); categorisation.StructureReference = structureRef; ArtefactIdentity artIDCS = Utils.GetArtefactIdentityFromString(cmbCategorySchemes.SelectedValue); IStructureReference categoryRef = new StructureReferenceImpl(artIDCS.Agency, artIDCS.ID, artIDCS.Version, SdmxStructureEnumType.Category, tvCategory.SelectedValue); categorisation.CategoryReference = categoryRef; ISdmxObjects sdmxCategorisationInsert = new SdmxObjectsImpl(); sdmxCategorisationInsert.AddCategorisation(categorisation.ImmutableInstance); _wsModel.SubmitStructure(sdmxCategorisationInsert); // Controllo su errore // Messaggio di inserimento avvenuto con successo // Refresh della Gridview PopolateGVCategorisations(); ResetCatPanel(); }
public void TestGetAllCategorisations(string name) { var mutableStructureSearchManager = GetStructureSearchManager(name); var catRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Categorisation)); var detailLevel = StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.ReferencedStubs); var referenceLevel = StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.All); var structureQuery = new RESTStructureQueryCore(detailLevel, referenceLevel, null, catRef, false); var mutableObjects = mutableStructureSearchManager.GetMaintainables(structureQuery); Assert.IsTrue(mutableObjects.Dataflows.Count > 0); Assert.IsTrue(mutableObjects.DataStructures.Count > 0); Assert.IsTrue(mutableObjects.CategorySchemes.Count > 0); Assert.IsTrue(mutableObjects.Categorisations.Count > 0); Assert.IsTrue(mutableObjects.Codelists.Count > 0); Assert.IsTrue(mutableObjects.ConceptSchemes.Count > 0); Assert.IsTrue(mutableObjects.HierarchicalCodelists.Count == 0); }
/// <summary> /// Convert measure representation from SDMX v2.0 to SDMX v2.1 and <see cref="ICrossSectionalDataStructureObject"/>. /// </summary> /// <param name="crossSectionalDataStructure"> /// The cross sectional data structure. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="crossSectionalDataStructure"/> is null /// </exception> /// <remarks> /// HACK HORIBLE HACK /// in 2.0 measure dimensions have a codelist based representation. On 2.1 have concept scheme based representation. /// </remarks> public static void ConvertMeasureRepresentation(ICrossSectionalDataStructureMutableObject crossSectionalDataStructure) { if (crossSectionalDataStructure == null) { throw new ArgumentNullException("crossSectionalDataStructure"); } IDimensionMutableObject measureDim = crossSectionalDataStructure.Dimensions.FirstOrDefault(o => o.MeasureDimension); if (measureDim != null && crossSectionalDataStructure.CrossSectionalMeasures.Count > 0) { IStructureReference crossSectionalMeasureConceptRef = crossSectionalDataStructure.CrossSectionalMeasures[0].ConceptRef; IDictionary<string, IStructureReference> measureDimensionCodelistMapping = crossSectionalDataStructure.MeasureDimensionCodelistMapping; IStructureReference cocneptSchemeRef = new StructureReferenceImpl( crossSectionalMeasureConceptRef.MaintainableReference, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme)); measureDimensionCodelistMapping.Add(measureDim.Id ?? measureDim.ConceptRef.ChildReference.Id, measureDim.Representation.Representation); measureDim.Representation.Representation = cocneptSchemeRef; } }
/// <summary> /// Gets the maintainables. /// </summary> /// <param name="structureQuery">The structure query.</param> /// <returns>The <see cref="IMutableObjects"/>.</returns> public IMutableObjects GetMaintainables(IComplexStructureQuery structureQuery) { // In this sample we convert the SDMX v2.1 SOAP request to REST. var maintainableRefObject = structureQuery.StructureReference.GetMaintainableRefObject(); var structureReference = new StructureReferenceImpl(maintainableRefObject, structureQuery.StructureReference.ReferencedStructureType); StructureQueryDetail structureQueryDetail = Convert(structureQuery.StructureQueryMetadata.StructureQueryDetail, structureQuery.StructureQueryMetadata.ReferencesQueryDetail); StructureReferenceDetail reference = structureQuery.StructureQueryMetadata.StructureReferenceDetail; SdmxStructureType specificStructureReference = null; if (structureQuery.StructureQueryMetadata.ReferenceSpecificStructures != null) { specificStructureReference = structureQuery.StructureQueryMetadata.ReferenceSpecificStructures.FirstOrDefault(); } bool returnLatest = structureQuery.StructureReference.VersionReference.IsReturnLatest.IsTrue; IRestStructureQuery restStructureQuery = new RESTStructureQueryCore(structureQueryDetail, reference, specificStructureReference, structureReference, returnLatest); return this._mutableStructureSearchManager.GetMaintainables(restStructureQuery); }
public void TestGetOneCategorisations(string name) { var mutableStructureSearchManager = GetStructureSearchManager(name); var detailLevel = StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full); var referenceLevel = StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.All); IStructureReference catRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Categorisation)); var categorisation = mutableStructureSearchManager.RetrieveStructures(new[] { catRef }, false, false).Categorisations.First(); var referenceForOne = new StructureReferenceImpl(categorisation.AgencyId, categorisation.Id,categorisation.Version, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Categorisation)); var structureQuery = new RESTStructureQueryCore(detailLevel, referenceLevel, null, referenceForOne , false); var mutableObjects = mutableStructureSearchManager.GetMaintainables(structureQuery); Assert.IsTrue(mutableObjects.Dataflows.Count > 0); Assert.IsTrue(mutableObjects.DataStructures.Count > 0); Assert.IsTrue(mutableObjects.CategorySchemes.Count > 0); Assert.IsTrue(mutableObjects.Categorisations.Count > 0); Assert.IsTrue(mutableObjects.Codelists.Count > 0); Assert.IsTrue(mutableObjects.ConceptSchemes.Count > 0); Assert.IsTrue(mutableObjects.HierarchicalCodelists.Count == 0); }
/// <summary> /// Processes the structure reference urn. /// </summary> /// <param name="sdmxStructureEnumType"> /// Type of the SDMX structure. /// </param> /// <param name="text"> /// The text. /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> /// <exception cref="SdmxSemmanticException"> /// Dataset Structure reference invalid, reference does not match /// <paramref name="sdmxStructureEnumType"/> /// </exception> private static IStructureReference ProcessStructureReferenceUrn(SdmxStructureEnumType sdmxStructureEnumType, string text) { IStructureReference structureReference = null; string urn = text; if (!string.IsNullOrWhiteSpace(urn)) { structureReference = new StructureReferenceImpl(urn); if (structureReference.TargetReference != sdmxStructureEnumType) { throw new SdmxSemmanticException( string.Format( CultureInfo.InvariantCulture, "Dataset Structure reference invalid '{0}' , expecting a reference to '{1}' but got '{2}'", urn, SdmxStructureType.GetFromEnum(sdmxStructureEnumType), structureReference.TargetReference.StructureType)); } } return structureReference; }
/// <summary> /// Returns the latest version of the maintainable for the given maintainable input /// </summary> /// <param name="maintainableObject"> /// The maintainable Object. /// </param> /// <param name="allowedDataflows"> /// The allowed Dataflows. /// </param> /// <returns> /// The <see cref="IMaintainableMutableObject"/>. /// </returns> public virtual IMaintainableMutableObject GetLatest(IMaintainableMutableObject maintainableObject, IList<IMaintainableRefObject> allowedDataflows) { if (maintainableObject == null) { return null; } // Create a reference *without* the version, because we want the latest. IStructureReference reference = new StructureReferenceImpl(maintainableObject.AgencyId, maintainableObject.Id, null, maintainableObject.StructureType); IMutableObjects objects = new MutableObjectsImpl(); this.PopulateMutables(objects, new[] { reference }, true, StructureQueryDetailEnumType.Full, allowedDataflows); var maintainable = objects.GetMaintainables(maintainableObject.StructureType).FirstOrDefault(); if (maintainable == null) { throw new SdmxNoResultsException("No structures found for the specific query"); } return maintainable; }
public IStructureReference CreateSdmxCodelistsReference() { IStructureReference reference = new StructureReferenceImpl("SDMX", null, null, SdmxStructureEnumType.CodeList); return reference; }
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); }
public void TestStructureReference(string agency, string id, string version) { foreach (SdmxStructureType sdmxStructureType in SdmxStructureType.Values) { if (sdmxStructureType.IsMaintainable) { var cross = new StructureReferenceImpl(agency, id, version, sdmxStructureType); Assert.AreEqual(agency, cross.AgencyId); Assert.AreEqual(id, cross.MaintainableId); string versionToTest = string.IsNullOrWhiteSpace(version) ? null : version; Assert.AreEqual(versionToTest, cross.Version); } else if (sdmxStructureType.IsIdentifiable && !sdmxStructureType.HasFixedId) { var cross = new StructureReferenceImpl( agency, id, version, sdmxStructureType.EnumType, "ENA", "DYO", "TRIA"); Assert.AreEqual(agency, cross.AgencyId); Assert.AreEqual(id, cross.MaintainableId); string versionToTest = string.IsNullOrWhiteSpace(version) ? null : version; Assert.AreEqual(versionToTest, cross.Version); CollectionAssert.IsNotEmpty(cross.IdentifiableIds); } } }
protected void btnAddDimension_Click(object sender, EventArgs e) { if (!ValidateDimensionData()) { OpenAddDimensionPopUp(); return; } IDimensionMutableObject dim = new DimensionMutableCore(); dim.Id = txtDimID.Text; switch (cmbDimType.SelectedValue) { case "FREQUENCY": dim.FrequencyDimension = true; break; case "MEASURE": dim.MeasureDimension = true; break; case "TIME": dim.TimeDimension = true; break; } #region "***** Concept Reference ******" ArtefactIdentity csIdentity = new ArtefactIdentity(); string[] conceptData = txtDimConcept.Text.Split(','); if (conceptData.Length > 0) { csIdentity.ID = conceptData[0]; csIdentity.Agency = conceptData[1]; csIdentity.Version = conceptData[2].Substring(0, conceptData[2].IndexOf(' ')); string conceptID = conceptData[2].Substring(conceptData[2].LastIndexOf(' ') + 1); IStructureReference conceptRef = new StructureReferenceImpl(csIdentity.Agency, csIdentity.ID, csIdentity.Version, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), new string[] { conceptID }); dim.ConceptRef = conceptRef; } #endregion switch (cmbDimType.SelectedValue) { case "NORMAL": case "FREQUENCY": // Remove NTD Normal Dimension foreach (IDimensionMutableObject dimF in _dsdMutable.Dimensions) { if (dimF.ConceptRef.MaintainableId == _ntdNRName) { _dsdMutable.Dimensions.Remove(dimF); break; } } #region "***** Codelist Reference ******" if (txtDimCodelist.Text != string.Empty) { ArtefactIdentity clIdentity = new ArtefactIdentity(); string[] clData = txtDimCodelist.Text.Split(','); clIdentity.ID = clData[0]; clIdentity.Agency = clData[1]; clIdentity.Version = clData[2]; IStructureReference codelistRef = new StructureReferenceImpl(clIdentity.Agency, clIdentity.ID, clIdentity.Version, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList), null); IRepresentationMutableObject representationRef = new RepresentationMutableCore(); representationRef.Representation = codelistRef; dim.Representation = representationRef; } #endregion break; case "MEASURE": #region "***** ConceptScheme Reference ******" if (txtDimConceptScheme.Text != string.Empty) { ArtefactIdentity cSchemeIdentity = new ArtefactIdentity(); string[] clData = txtDimConceptScheme.Text.Split(','); cSchemeIdentity.ID = clData[0]; cSchemeIdentity.Agency = clData[1]; cSchemeIdentity.Version = clData[2]; IStructureReference cSchemeRef = new StructureReferenceImpl(cSchemeIdentity.Agency, cSchemeIdentity.ID, cSchemeIdentity.Version, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme), null); IRepresentationMutableObject representationRef = new RepresentationMutableCore(); representationRef.Representation = cSchemeRef; dim.Representation = representationRef; } #endregion break; case "TIME": // Remove NTD Time Dimensione foreach (IDimensionMutableObject dimF in _dsdMutable.Dimensions) { if (dimF.ConceptRef.MaintainableId == _ntdTDName) { _dsdMutable.Dimensions.Remove(dimF); break; } } break; } try { _dsdMutable.AddDimension(dim); SetDsdToSession(); SetDimensionTab(_dsdMutable.ImmutableInstance); PopulateLBDimensionList(_dsdMutable, lbAttachmentDimension); PopulateLBDimensionList(_dsdMutable, lbGroupDimension); txtDimID.Text = ""; txtDimConcept.Text = ""; txtDimCodelist.Text = ""; txtDimConceptScheme.Text = ""; cmbDimType.SelectedIndex = 0; Utils.ForceBlackClosing(); } catch (Exception ex) { _dsdMutable.Dimensions.Remove(dim); OpenAddDimensionPopUp(); Utils.ShowDialog(ex.Message, 600, Resources.Messages.err_add_dimension); } }
/// <summary> /// The get dsd reference. /// </summary> /// <param name="parser"> /// The parser. /// </param> /// <returns> /// The <see cref="IMaintainableRefObject"/> . /// </returns> private static IMaintainableRefObject GetDsdReference(XmlReader parser) { if (parser.GetAttribute("keyFamilyURI") != null) { string dsdUri = parser.GetAttribute("keyFamilyURI"); IStructureReference dsdRef = new StructureReferenceImpl(dsdUri); return dsdRef.MaintainableReference; } return null; }
/// <summary> /// The generate or use default structure. /// </summary> /// <param name="parser"> /// The parser. /// </param> /// <param name="datasetHeader"> /// The dataset header. /// </param> /// <returns> /// The <see cref="IDatasetStructureReference"/> . /// </returns> private static IDatasetStructureReference GenerateOrUseDefaultStructure(XmlReader parser, IHeader datasetHeader) { IStructureReference structureReference; IMaintainableRefObject dataflowReference = GetDataflowReference(parser); IMaintainableRefObject dsdReference = GetDsdReference(parser); if (dataflowReference != null) { structureReference = new StructureReferenceImpl( dataflowReference, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)); } else if (dsdReference != null) { structureReference = new StructureReferenceImpl( dsdReference, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd)); } else if (datasetHeader.Structures.Count == 1) { return datasetHeader.Structures[0]; } else { return null; } return new DatasetStructureReferenceCore( "generated", structureReference, null, null, DimensionObject.TimeDimensionFixedId); }
/// <summary> /// Adds new elements to the old versus new references. /// </summary> /// <param name="oldVersionNumber"> /// The old version number. /// </param> /// <param name="newVersion"> /// The new version object. /// </param> /// <param name="oldVsNew"> /// The old vs new map. /// </param> private void AddOldVsNewReferencesToMap( String oldVersionNumber, IIdentifiableObject newVersion, IDictionary<IStructureReference, IStructureReference> oldVsNew) { IStructureReference asReference = newVersion.AsReference; IMaintainableRefObject mRef = asReference.MaintainableReference; IStructureReference oldReference = new StructureReferenceImpl( mRef.AgencyId, mRef.MaintainableId, oldVersionNumber, asReference.TargetReference, asReference.IdentifiableIds); oldVsNew.Add(oldReference, asReference); }
private static ISdmxObjectRetrievalManager GetManagerImmutable() { Estat.Nsi.StructureRetriever.Manager.AuthMutableStructureSearchManager srManager = new Estat.Nsi.StructureRetriever.Manager.AuthMutableStructureSearchManager(SQLConnString_DB); List<IStructureReference> query = new List<IStructureReference>(); IStructureReference sr = new StructureReferenceImpl(new MaintainableRefObjectImpl("", "", ""), Org.Sdmxsource.Sdmx.Api.Constants.SdmxStructureEnumType.Dsd); query.Add(sr); IMutableObjects retObject = srManager.RetrieveStructures(query, true, false, null); ISdmxObjectRetrievalManager retrievalManager = new InMemoryRetrievalManager(retObject.ImmutableObjects); return retrievalManager; }
/// <summary> /// Retrieves all available dataflows. /// </summary> /// <returns> /// The <see cref="string"/>. /// </returns> private string RetrieveDataflows() { var dataflowRefBean = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow)); IRestStructureQuery structureQuery = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Specific), SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), dataflowRefBean, true); IStructureQueryFactory factory = new RestStructureQueryFactory(); IStructureQueryBuilderManager structureQueryBuilderManager = new StructureQueryBuilderManager(factory); IStructureQueryFormat<string> structureQueryFormat = new RestQueryFormat(); string request = structureQueryBuilderManager.BuildStructureQuery(structureQuery, structureQueryFormat); return request; }
/// <summary> /// Retrieves all available categorisations and category schemes. /// </summary> /// <returns> /// The <see cref="string"/>. /// </returns> private string RetrieveCategorySchemesAndCategorisations() { var catSch = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme)); IStructureQueryFormat<string> structureQueryFormat = new RestQueryFormat(); IRestStructureQuery structureQueryCategoryScheme = new RESTStructureQueryCore(StructureQueryDetail.GetFromEnum(StructureQueryDetailEnumType.Full), StructureReferenceDetail.GetFromEnum(StructureReferenceDetailEnumType.Parents), null, catSch, false); IStructureQueryFactory factory = new RestStructureQueryFactory(); IStructureQueryBuilderManager structureQueryBuilderManager = new StructureQueryBuilderManager(factory); string request = structureQueryBuilderManager.BuildStructureQuery(structureQueryCategoryScheme, structureQueryFormat); return request; }
private void CreateEmptyDSD() { IDataStructureMutableObject dsdMutable; dsdMutable = _sdmxUtils.buildDataStructure(_ntdString + "DSD_ID", _ntdString + "AGENCY", _ntdDSDVersion); dsdMutable.AddName("en", _ntdString + "DSD_NAME"); //AnnotationGeneralControl.ClearAnnotationsSession(); #region NormalDimension IDimensionMutableObject dim = new DimensionMutableCore(); dim.Id = _ntdNRName; IStructureReference conceptRef = new StructureReferenceImpl(_ntdNRName, _ntdNRName, "1.0", SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), new string[] { _ntdNRName }); dim.ConceptRef = conceptRef; dsdMutable.AddDimension(dim); #endregion #region TimeDimension IDimensionMutableObject dim2 = new DimensionMutableCore(); dim2.Id = _ntdTDName; dim2.TimeDimension = true; IStructureReference conceptRef2 = new StructureReferenceImpl(_ntdTDName, _ntdTDName, "1.0", SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), new string[] { _ntdTDName }); dim2.ConceptRef = conceptRef2; dsdMutable.AddDimension(dim2); #endregion dsdMutable.AddPrimaryMeasure(new StructureReferenceImpl(_ntdPMName, _ntdPMName, "1.0", SdmxStructureEnumType.Concept, _ntdPMName)); _dsdMutable = dsdMutable; SetDsdToSession(); }
protected void btnAddAttribute_Click(object sender, EventArgs e) { if (!ValidateAttributeData()) { OpenAddAttributePopUp(); return; } /* * Creo l'attribute * ID * Concept * Eventuale Codelist * Assignment status * Attachmentlevel * DimensionGroup * Attachment Dimension * Group * Attached Group ID * */ IAttributeMutableObject attr = new AttributeMutableCore(); attr.Id = txtAttributeID.Text; #region "***** Concept Reference ******" ArtefactIdentity csIdentity = new ArtefactIdentity(); string[] conceptData = txtAttributeConcept.Text.Split(','); if (conceptData.Length > 0) { csIdentity.ID = conceptData[0]; csIdentity.Agency = conceptData[1]; csIdentity.Version = conceptData[2].Substring(0, conceptData[2].IndexOf(' ')); string conceptID = conceptData[2].Substring(conceptData[2].LastIndexOf(' ') + 1); IStructureReference conceptRef = new StructureReferenceImpl(csIdentity.Agency, csIdentity.ID, csIdentity.Version, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), new string[] { conceptID }); attr.ConceptRef = conceptRef; } #endregion #region "***** Codelist Reference ******" if (txtAttributeCodelist.Text != string.Empty) { ArtefactIdentity clIdentity = new ArtefactIdentity(); string[] clData = txtAttributeCodelist.Text.Split(','); clIdentity.ID = clData[0]; clIdentity.Agency = clData[1]; clIdentity.Version = clData[2]; IStructureReference codelistRef = new StructureReferenceImpl(clIdentity.Agency, clIdentity.ID, clIdentity.Version, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList), null); IRepresentationMutableObject representationRef = new RepresentationMutableCore(); representationRef.Representation = codelistRef; attr.Representation = representationRef; } #endregion attr.AssignmentStatus = cmbAssignmentStatus.SelectedValue; attr.AttachmentLevel = (AttributeAttachmentLevel)Enum.Parse(typeof(AttributeAttachmentLevel), cmbAttachLevel.SelectedValue); switch (attr.AttachmentLevel) { case AttributeAttachmentLevel.DataSet: break; case AttributeAttachmentLevel.DimensionGroup: // Aggiungo le dimensioni selezionate nella list box IList<string> lDim = new List<string>(); foreach (ListItem li in lbAttachmentDimension.Items) { if (li.Selected) attr.DimensionReferences.Add(li.Value); } break; case AttributeAttachmentLevel.Group: // Aggiungo il gruppo selezionato nella combo attr.AttachmentGroup = cmbAttachedGroupID.SelectedValue; break; case AttributeAttachmentLevel.Null: break; case AttributeAttachmentLevel.Observation: break; default: break; } try { if (hdnEditAttribute.Value == "true") { foreach (IAttributeMutableObject attrDel in _dsdMutable.Attributes) { if (attrDel.Id == txtAttributeID.Text) { _dsdMutable.Attributes.Remove(attrDel); break; } } } _dsdMutable.AddAttribute(attr); SetDsdToSession(); SetAttributeTab(_dsdMutable.ImmutableInstance); txtAttributeID.Text = ""; txtAttributeConcept.Text = ""; txtAttributeCodelist.Text = ""; cmbAssignmentStatus.SelectedIndex = 0; cmbAttachLevel.SelectedIndex = 0; lbAttachmentDimension.ClearSelection(); if (cmbAttachedGroupID.Items.Count >0) cmbAttachedGroupID.SelectedIndex = 0; pnlAttachedGroupID.Visible = false; pnlAttachmentDimension.Visible = false; Utils.ForceBlackClosing(); } catch (Exception ex) { _dsdMutable.Attributes.Remove(attr); OpenAddAttributePopUp(); Utils.ShowDialog(ex.Message, 600, Resources.Messages.err_add_attribute); } }
/// <summary> /// Salva il DataFlow nel registry /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveDF_Click(object sender, EventArgs e) { /* * 1. Aggiungo all'oggetto _dfMutable: * Le info della General * La collection di Names * La Collecction delle Desctiptions * 2. Richiamo il metodo che prende in input un ISdmxObjects che richiama il SaveStructure * 3. Visualizzo un messaggio di conferma,resetto le Session e faccio un redirect alla lista delle DF */ if (!ValidateDFData()) return; try { _dfMutable.Id = txtDFID.Text; _dfMutable.AgencyId = GetAgencyValue(); _dfMutable.Version = txtVersion.Text; _dfMutable.Names.Clear(); foreach (ITextTypeWrapperMutableObject name in AddTextName.TextObjectList) { _dfMutable.Names.Add(name); } _dfMutable.Descriptions.Clear(); if (AddTextDescription.TextObjectList != null) { foreach (ITextTypeWrapperMutableObject descr in AddTextDescription.TextObjectList) { _dfMutable.Descriptions.Add(descr); } } _dfMutable.FinalStructure = TertiaryBool.ParseBoolean(chkIsFinal.Checked); if (txtURI.Text != String.Empty) _dfMutable.Uri = new Uri(txtURI.Text); if (txtValidFrom.Text != String.Empty) _dfMutable.StartDate = DateTime.ParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); if (txtValidTo.Text != String.Empty) _dfMutable.EndDate = DateTime.ParseExact(txtValidTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); _dfMutable.Annotations.Clear(); if (AnnotationGeneral.AnnotationObjectList != null) foreach (var annotation in AnnotationGeneral.AnnotationObjectList) { _dfMutable.AddAnnotation(annotation); } string[] DSDValues = txtDSD.Text.Split(','); IStructureReference dsdRef = new StructureReferenceImpl(DSDValues[1], DSDValues[0], DSDValues[2], SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), new string[] { _ntdString }); _dfMutable.DataStructureRef = dsdRef; SetDfToSession(); WSModel wsModel = new WSModel(); XmlDocument xRet = wsModel.SubmitStructure(_sdmxObjects); string err = Utils.GetXMLResponseError(xRet); if (err != "") { Utils.ShowDialog(err); return; } //Session[_snInsDf] = null; //Session[_snSdmxObjects] = null; //Utils.ShowDialog("Operation succesfully"); Utils.ResetBeforeUnload(); Utils.AppendScript("location.href='./DataFlow.aspx';"); } catch (Exception ex) { Utils.ShowDialog(ex.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="MetadataTargetCore"/> class. /// </summary> /// <param name="fullTarget">The SDMX v2.0 full target identifier.</param> /// <param name="parent">The parent.</param> protected internal MetadataTargetCore(FullTargetIdentifierType fullTarget, IMetadataStructureDefinitionObject parent) : base(fullTarget, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataTarget), fullTarget.id, fullTarget.uri, fullTarget.Annotations, parent) { if (fullTarget.IdentifierComponent != null) { foreach (var currentIdentifier in fullTarget.IdentifierComponent) { var identifiableTarget = new IdentifiableTargetMutableCore() { Id = currentIdentifier.id, Uri = currentIdentifier.uri }; if (currentIdentifier.Annotations != null && currentIdentifier.Annotations.Annotation != null) { foreach (var annotationType in currentIdentifier.Annotations.Annotation) { var annotation = new AnnotationMutableCore { Title = annotationType.AnnotationTitle, Type = annotationType.AnnotationType1, Uri = annotationType.AnnotationURL }; foreach (var textType in annotationType.AnnotationText) { annotation.AddText(textType.lang, textType.TypedValue); } identifiableTarget.AddAnnotation(annotation); } } if (currentIdentifier.RepresentationScheme != null) { var id = currentIdentifier.RepresentationScheme.representationScheme; var agency = currentIdentifier.RepresentationScheme.representationSchemeAgency; var schemaType = XmlobjectsEnumUtil.GetSdmxStructureTypeFromRepresentationSchemeTypeV20(currentIdentifier.RepresentationScheme.representationSchemeType1); // Only on .NET var version = currentIdentifier.RepresentationScheme.RepresentationSchemeVersionEstat ?? MaintainableObject.DefaultVersion; var representation = new RepresentationMutableCore(); var representationRef = new StructureReferenceImpl(new MaintainableRefObjectImpl(agency, id, version), schemaType); representation.Representation = representationRef; identifiableTarget.Representation = representation; } if (currentIdentifier.TargetObjectClass != null) { identifiableTarget.ReferencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureType(currentIdentifier.TargetObjectClass); } this._identifiableTarget.Add(new IdentifiableTargetCore(identifiableTarget, this)); } } }
/// <summary> /// Build dataflow query. Override to alter the default behavior /// </summary> /// <param name="refType"> /// The Dataflow reference (SDMX v2.0 /// </param> /// <returns> /// The <see cref="IStructureReference"/>. /// </returns> protected virtual IStructureReference BuildDataflowQuery(DataflowRefType refType) { var urn = refType.URN; StructureReferenceImpl structureReferenceImpl; if (ObjectUtil.ValidString(urn)) { structureReferenceImpl = new StructureReferenceImpl(urn); } else { string agencyID = refType.AgencyID; string dataflowID = refType.DataflowID; string version = refType.Version; structureReferenceImpl = new StructureReferenceImpl(agencyID, dataflowID, version, SdmxStructureEnumType.Dataflow); } return structureReferenceImpl; }
public void TestStructureReference(string urn, SdmxStructureEnumType expectedResult, bool hasChildReference) { var impl = new StructureReferenceImpl(urn); Assert.AreEqual(urn, impl.TargetUrn.ToString()); Assert.AreEqual(expectedResult, impl.TargetStructureType.EnumType); Assert.IsTrue(impl.HasAgencyId()); Assert.IsTrue(impl.HasTargetUrn()); Assert.IsTrue(impl.HasMaintainableId()); Assert.AreEqual(hasChildReference, impl.HasChildReference()); Assert.AreEqual(hasChildReference, impl.IdentifiableIds.Count > 0); Assert.AreEqual(impl.TargetUrn, impl.CreateCopy().TargetUrn); Assert.AreEqual(impl.TargetReference, impl.CreateCopy().TargetReference); }
/// <summary> /// Build concept scheme requests from the concept scheme references of the specified KeyFamilyBean object /// </summary> /// <param name="kf"> /// The KeyFamily to look for concept Scheme references /// </param> /// <returns> /// A list of concept scheme requests /// </returns> public static IEnumerable<IStructureReference> BuildConceptSchemeRequest(IDataStructureObject kf) { var conceptSchemeSet = new Dictionary<string, object>(); var ret = new List<IStructureReference>(); var crossDsd = kf as ICrossSectionalDataStructureObject; List<IComponent> components = new List<IComponent>(); components.AddRange(kf.GetDimensions()); components.AddRange(kf.Attributes); if (kf.PrimaryMeasure != null) { components.Add(kf.PrimaryMeasure); } if (crossDsd != null) { components.AddRange(crossDsd.CrossSectionalMeasures); } ICollection<IComponent> comps = components; foreach (IComponent comp in comps) { string key = Utils.MakeKey(comp.ConceptRef.MaintainableReference.MaintainableId, comp.ConceptRef.MaintainableReference.Version, comp.ConceptRef.MaintainableReference.AgencyId); if (!conceptSchemeSet.ContainsKey(key)) { // create concept ref var conceptSchemeRef = new StructureReferenceImpl(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme)) { MaintainableId = comp.ConceptRef.MaintainableReference.MaintainableId, AgencyId = comp.ConceptRef.MaintainableReference.AgencyId, Version = comp.ConceptRef.MaintainableReference.Version }; // add it to request ret.Add(conceptSchemeRef); // added it to set of visited concept schemes conceptSchemeSet.Add(key, null); } } return ret; }
private void CreateEmptyDataFlow() { IDataflowMutableObject dfMutable; dfMutable = _sdmxUtils.buildDataFlow(_ntdString + "DSD_ID", _ntdString + "AGENCY", _ntdDSDVersion); dfMutable.AddName("en", _ntdString + "DSD_NAME"); IStructureReference dsdRef = new StructureReferenceImpl(_ntdString, _ntdString, "1.0", SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd), new string[] { _ntdString }); dfMutable.DataStructureRef = dsdRef; _dfMutable = dfMutable; SetDfToSession(); }
public IStructureReference CreateCategorySchemeReferenceFromUrn() { Uri urn = new Uri("urn:sdmx:org.sdmx.infomodel.categoryscheme.CategoryScheme=SDMX:SDMXStatMatDomainsWD1(1.0)"); IStructureReference reference = new StructureReferenceImpl(urn); return reference; }
/// <summary> /// Build a list of structure references /// </summary> /// <param name="queryMessage"> /// given message query containing lists of references for each structure type. /// </param> /// <returns> /// list of structure references /// </returns> public IList<IStructureReference> Build(QueryMessageType queryMessage) { IList<IStructureReference> reutrnList = new List<IStructureReference>(); if (queryMessage.Query != null) { QueryType queryType = queryMessage.Query; if (queryType.AgencyWhere != null) { if (ObjectUtil.ValidCollection(queryMessage.Query.AgencyWhere)) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "AgencyWhere"); } } if (queryType.CategorySchemeWhere != null) { /* foreach */ foreach (CategorySchemeWhereType structQuery in queryType.CategorySchemeWhere) { string agencyId = structQuery.AgencyID; string maintId = structQuery.ID; string version = structQuery.Version; SdmxStructureType structType = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategoryScheme); IStructureReference refBean = new StructureReferenceImpl(agencyId, maintId, version, structType); reutrnList.Add(refBean); } } if (queryType.CodelistWhere != null) { /* foreach */ foreach (CodelistWhereType structQuery0 in queryType.CodelistWhere) { string codelistId = null; if (structQuery0.Codelist != null) { codelistId = structQuery0.Codelist.id; } string agencyId1 = structQuery0.AgencyID; string maintId2 = codelistId; string version3 = structQuery0.Version; SdmxStructureType structType4 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CodeList); IStructureReference refBean5 = new StructureReferenceImpl( agencyId1, maintId2, version3, structType4); reutrnList.Add(refBean5); if (structQuery0.Or != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "CodelistWhere/Or"); } if (structQuery0.And != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "CodelistWhere/And"); } } } if (queryType.ConceptSchemeWhere != null) { /* foreach */ foreach (ConceptSchemeWhereType structQuery6 in queryType.ConceptSchemeWhere) { string agencyId7 = structQuery6.AgencyID; string maintId8 = structQuery6.ID; string version9 = structQuery6.Version; SdmxStructureType structType10 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme); IStructureReference refBean11 = new StructureReferenceImpl( agencyId7, maintId8, version9, structType10); reutrnList.Add(refBean11); } } if (queryType.ConceptWhere != null) { /* foreach */ foreach (ConceptWhereType structQuery12 in queryType.ConceptWhere) { string agencyId13 = structQuery12.AgencyID; string conceptId = structQuery12.Concept; SdmxStructureType structType14 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept); IStructureReference refBean15 = new StructureReferenceImpl( agencyId13, ConceptSchemeObject.DefaultSchemeId, ConceptSchemeObject.DefaultSchemeVersion, structType14, conceptId); reutrnList.Add(refBean15); if (structQuery12.Or != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "ConceptWhere/Or"); } if (structQuery12.And != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "ConceptWhere/And"); } } } if (queryType.DataflowWhere != null) { /* foreach */ foreach (DataflowWhereType structQuery16 in queryType.DataflowWhere) { string agencyId17 = structQuery16.AgencyID; string maintId18 = structQuery16.ID; string version19 = structQuery16.Version; SdmxStructureType structType20 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow); IStructureReference refBean21 = new StructureReferenceImpl( agencyId17, maintId18, version19, structType20); reutrnList.Add(refBean21); } } if (queryType.DataProviderWhere != null && queryType.DataProviderWhere.Count > 0) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "DataProviderWhere"); } if (queryType.DataWhere != null && queryType.DataWhere.Count > 0) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "DataWhere"); } if (queryType.HierarchicalCodelistWhere != null) { /* foreach */ foreach (HierarchicalCodelistWhereType structQuery22 in queryType.HierarchicalCodelistWhere) { string agencyId23 = structQuery22.AgencyID; string maintId24 = structQuery22.ID; string version25 = structQuery22.Version; SdmxStructureType structType26 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.HierarchicalCodelist); IStructureReference refBean27 = new StructureReferenceImpl( agencyId23, maintId24, version25, structType26); reutrnList.Add(refBean27); } } if (queryType.KeyFamilyWhere != null) { /* foreach */ foreach (KeyFamilyWhereType structQuery28 in queryType.KeyFamilyWhere) { string agencyId29 = structQuery28.AgencyID; string maintId30 = structQuery28.KeyFamily; string version31 = structQuery28.Version; SdmxStructureType structType32 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dsd); IStructureReference refBean33 = new StructureReferenceImpl( agencyId29, maintId30, version31, structType32); reutrnList.Add(refBean33); if (structQuery28.Or != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/Or"); } if (structQuery28.And != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/And"); } if (structQuery28.Dimension != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/Dimensions"); } if (structQuery28.Attribute != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/Attribute"); } if (structQuery28.Codelist != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/Codelist"); } if (structQuery28.Category != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/Category"); } if (structQuery28.Concept != null) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "KeyFamilyWhere/Concept"); } } } if (queryType.MetadataflowWhere != null) { /* foreach */ foreach (MetadataflowWhereType structQuery34 in queryType.MetadataflowWhere) { string agencyId35 = structQuery34.AgencyID; string maintId36 = structQuery34.ID; string version37 = structQuery34.Version; SdmxStructureType structType38 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MetadataFlow); IStructureReference refBean39 = new StructureReferenceImpl( agencyId35, maintId36, version37, structType38); reutrnList.Add(refBean39); } } if (queryType.MetadataWhere != null && queryType.MetadataWhere.Count > 0) { throw new SdmxNotImplementedException(ExceptionCode.Unsupported, "DataWhere"); } if (queryType.OrganisationSchemeWhere != null) { /* foreach */ foreach (OrganisationSchemeWhereType structQuery40 in queryType.OrganisationSchemeWhere) { string agencyId41 = structQuery40.AgencyID; string maintId42 = structQuery40.ID; string version43 = structQuery40.Version; SdmxStructureType structType44 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.OrganisationUnitScheme); IStructureReference refBean45 = new StructureReferenceImpl( agencyId41, maintId42, version43, structType44); reutrnList.Add(refBean45); } } if (queryType.ProcessWhere != null) { /* foreach */ foreach (ProcessWhereType structQuery46 in queryType.ProcessWhere) { string agencyId47 = structQuery46.AgencyID; string maintId48 = structQuery46.ID; string version49 = structQuery46.Version; SdmxStructureType structType50 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Process); IStructureReference refBean51 = new StructureReferenceImpl( agencyId47, maintId48, version49, structType50); reutrnList.Add(refBean51); } } if (queryType.StructureSetWhere != null) { /* foreach */ foreach (StructureSetWhereType structQuery52 in queryType.StructureSetWhere) { string agencyId53 = structQuery52.AgencyID; string maintId54 = structQuery52.ID; string version55 = structQuery52.Version; SdmxStructureType structType56 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.StructureSet); IStructureReference refBean57 = new StructureReferenceImpl( agencyId53, maintId54, version55, structType56); reutrnList.Add(refBean57); } } if (queryType.ReportingTaxonomyWhere != null) { /* foreach */ foreach (ReportingTaxonomyWhereType structQuery58 in queryType.ReportingTaxonomyWhere) { string agencyId59 = structQuery58.AgencyID; string maintId60 = structQuery58.ID; string version61 = structQuery58.Version; SdmxStructureType structType62 = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ReportingTaxonomy); IStructureReference refBean63 = new StructureReferenceImpl( agencyId59, maintId60, version61, structType62); reutrnList.Add(refBean63); } } } return reutrnList; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="ConceptCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="concept"> /// The sdmxObject. /// </param> public ConceptCore(IConceptSchemeObject parent, ConceptType concept) : base(concept, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Concept), parent) { if (concept.CoreRepresentation != null) { this.coreRepresentation = new RepresentationCore(concept.CoreRepresentation, this); } if (concept.ISOConceptReference != null) { this.isoConceptReference = new CrossReferenceImpl( this, concept.ISOConceptReference.ConceptAgency, concept.ISOConceptReference.ConceptSchemeID, null, SdmxStructureEnumType.Concept, concept.ISOConceptReference.ConceptID); } var localItemReferenceType = concept.GetTypedParent<LocalConceptReferenceType>(); if (localItemReferenceType != null) { if (ObjectUtil.ValidCollection(localItemReferenceType.URN)) { IStructureReference structureReference = new StructureReferenceImpl(localItemReferenceType.URN[0]); this.parentConcept = structureReference.ChildReference.Id; this.parentAgency = structureReference.MaintainableReference.AgencyId; } else { this.parentConcept = localItemReferenceType.GetTypedRef<LocalConceptRefType>().id; this.parentAgency = this.MaintainableParent.AgencyId; } } }