/// <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> /// Salva la DSD nel registry /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveDSD_Click(object sender, EventArgs e) { /* * 1. Aggiungo all'oggetto _dsdMutable: * Le info della General * La collection di Names * La Collecction delle Descriptions * La Primary Measure * Le Dimension sono presenti nell'oggetto _dsdMutable * I Gruppi sono presenti nell'oggetto _dsdMutable * Gli Attributes sono presenti nell'oggetto _dsdMutable * 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 DSD */ if (!ValidateDSDData()) return; try { _dsdMutable.Id = txtDSDID.Text; _dsdMutable.AgencyId = cmbAgencies.SelectedValue; _dsdMutable.Version = txtVersion.Text; _dsdMutable.Names.Clear(); foreach (ITextTypeWrapperMutableObject name in AddTextName.TextObjectList) { _dsdMutable.Names.Add(name); } _dsdMutable.Descriptions.Clear(); if (AddTextDescription.TextObjectList != null) { foreach (ITextTypeWrapperMutableObject descr in AddTextDescription.TextObjectList) { _dsdMutable.Descriptions.Add(descr); } } _dsdMutable.FinalStructure = TertiaryBool.ParseBoolean(chkIsFinal.Checked); if (txtDSDURI.Text != String.Empty) _dsdMutable.Uri = new Uri(txtDSDURI.Text); if (txtValidFrom.Text != String.Empty) _dsdMutable.StartDate = DateTime.ParseExact(txtValidFrom.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); if (txtValidTo.Text != String.Empty) _dsdMutable.EndDate = DateTime.ParseExact(txtValidTo.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); // PM string[] pmValues = txtConcept.Text.Substring(0, txtConcept.Text.IndexOf(" ")).Split(','); string pmConcept = txtConcept.Text.Substring(txtConcept.Text.LastIndexOf(" ") + 1); _dsdMutable.AddPrimaryMeasure(new StructureReferenceImpl(pmValues[1], pmValues[0], pmValues[2], SdmxStructureEnumType.Concept, pmConcept)); if (txtCodelist.Text != "") { string[] pmCLValues = txtCodelist.Text.Split(','); IRepresentationMutableObject rep = new RepresentationMutableCore(); rep.Representation = new StructureReferenceImpl(pmCLValues[1], pmCLValues[0], pmCLValues[2], SdmxStructureEnumType.CodeList, null); _dsdMutable.PrimaryMeasure.Representation = rep; } _dsdMutable.Annotations.Clear(); if (AnnotationGeneral.AnnotationObjectList != null) foreach (var annotation in AnnotationGeneral.AnnotationObjectList) { _dsdMutable.AddAnnotation(annotation); } _dsdMutable.PrimaryMeasure.Annotations.Clear(); if (AnnotationPrimaryMeasure.AnnotationObjectList != null) foreach (var annotation in AnnotationPrimaryMeasure.AnnotationObjectList) { _dsdMutable.PrimaryMeasure.AddAnnotation(annotation); } SetDsdToSession(); WSModel wsModel = new WSModel(); XmlDocument xRet = wsModel.SubmitStructure(_sdmxObjects); string err = Utils.GetXMLResponseError(xRet); if (err != "") { Utils.ShowDialog(err); return; } Session[_snInsDSD] = null; Session[_snSdmxObjects] = null; //Utils.ShowDialog("Operation succesfully"); Utils.ResetBeforeUnload(); //Utils.ShowDialog(successMessage, 300); Utils.AppendScript("location.href='./KeyFamily.aspx';"); } catch (Exception ex) { Utils.ShowDialog(ex.Message); } }
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); } }
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> /// The validate dimension. /// </summary> /// <exception cref="SdmxSemmanticException">Throws Validate exception.</exception> private void ValidateDimension() { // FUNC 2.1 validate only the allowed text format attributes have been set if (this.timeDimension) { this.Id = DimensionObject.TimeDimensionFixedId; if (this.HasCodedRepresentation()) { // This is exception is comment out because it was requested by Eurostat to allow coded TimeDimensions. // See CITnet JIRA ticket SDMXRI-22: // https://webgate.ec.europa.eu/CITnet/jira/browse/SDMXRI-22 // Also the original ticket in Agilis JIRA: http://www.agilis-sa.gr:8070/browse/SODIHD-1209 // Also read the documentation at sdmx_maintenance > 2013 > QTM 2013 budget Framework Contract 60402.2012.001-2012.112 LOT2 > 2013.433-SC000030-FC112Lot2-SDMX_tools_corrective_and_evolutive_maintenance-QTM > QTM-2 > Deliverables // CIRCABC link: https://circabc.europa.eu/w/browse/91272b61-b03a-431f-ae91-75db31e324cf // This is part of QTM-4/2014. // based on the above. DO NOT UNCOMMENT the following line when sync with SdmxSource.Java: // throw new SdmxSemmanticException("Time Dimensions can not have coded representation"); _log.Warn("Time Dimensions can not have coded representation."); } else if (this.LocalRepresentation == null || this.LocalRepresentation.TextFormat == null) { IRepresentationMutableObject rep = new RepresentationMutableCore(); rep.TextFormat = new TextFormatMutableCore(); this.LocalRepresentation = new RepresentationCore(rep, this); } else if (this.LocalRepresentation.TextFormat.TextType != null) { if (!this.LocalRepresentation.TextFormat.TextType.IsValidTimeDimensionTextType) { // STRIP THE INVALID TEXT FORMAT _log.Warn( "Invalid Text Format found on Time Dimensions, removing Text Format : " + this.LocalRepresentation.TextFormat.TextType); IRepresentationMutableObject representationMutableCore = new RepresentationMutableCore(); representationMutableCore.TextFormat = new TextFormatMutableCore(); this.LocalRepresentation = new RepresentationCore(representationMutableCore, this); } } } else { if (this.Id.Equals(DimensionObject.TimeDimensionFixedId)) { throw new SdmxSemmanticException( "Only the Time Dimensions can have the id: " + DimensionObject.TimeDimensionFixedId); } } if (this.measureDimension) { base.StructureType = SdmxStructureType.GetFromEnum(SdmxStructureEnumType.MeasureDimension); if (this.Representation == null || this.Representation.Representation == null) { throw new SdmxSemmanticException("Measure Dimensions missing representation"); } if (this.MaintainableParent is ICrossSectionalDataStructureObject) { // Ignore this } else { if (this.Representation.Representation.TargetReference.EnumType != SdmxStructureEnumType.ConceptScheme) { throw new SdmxSemmanticException( "Measure Dimensions representation must reference a concept scheme, currently it references a " + this.Representation.Representation.TargetReference.GetType()); } } } if (this.measureDimension && this.timeDimension) { throw new SdmxSemmanticException("Dimensions can not be both a measure dimension and a time dimension"); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////VALIDATION ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Methods /// <summary> /// The validate. /// </summary> /// <exception cref="SdmxSemmanticException">Throws Validate exception.</exception> private void Validate() { // Sanity Check, make sure we can build both ways string objIdEnum = XmlobjectsEnumUtil.BuildV21(this.referencedStructureType); this.referencedStructureType = XmlobjectsEnumUtil.GetSdmxStructureTypeV21(objIdEnum); if (this.LocalRepresentation == null) { // Create a Local Representation if one doesn't exist. The schema insists on there being an Identifiable Reference ITextFormatMutableObject textFormatMutable = new TextFormatMutableCore(); textFormatMutable.TextType = TextType.GetFromEnum(TextEnumType.IdentifiableReference); IRepresentationMutableObject representationMutable = new RepresentationMutableCore(); representationMutable.TextFormat = textFormatMutable; this.LocalRepresentation = new RepresentationCore(representationMutable, this); return; } if (this.LocalRepresentation.Representation == null) { // Create a local representation if one doesn't exist. The schema insists on there being an Identifiable Reference if (this.LocalRepresentation == null || this.LocalRepresentation.TextFormat == null || this.LocalRepresentation.TextFormat.TextType.EnumType != TextEnumType.IdentifiableReference) { ITextFormatMutableObject textFormatMutable = new TextFormatMutableCore(); textFormatMutable.TextType = TextType.GetFromEnum(TextEnumType.IdentifiableReference); IRepresentationMutableObject representationMutable = new RepresentationMutableCore(); representationMutable.TextFormat = textFormatMutable; this.LocalRepresentation = new RepresentationCore(representationMutable, this); } } else { if (this.LocalRepresentation.TextFormat != null) { throw new SdmxSemmanticException( "Can not have both TextFormat and Representation set on IdentifiableObjectTarget"); } } if (this.referencedStructureType == null) { throw new SdmxSemmanticException("Identifiable target is missing Target CategorisationStructure Type (objectType)"); } }