/// <summary> /// The update references. /// </summary> /// <param name="maintianable"> /// The maintianable. /// </param> /// <param name="updateReferences"> /// The update references. /// </param> /// <param name="newVersionNumber"> /// The new version number. /// </param> /// <returns> /// The <see cref="IHierarchicalCodelistObject"/>. /// </returns> public IHierarchicalCodelistObject UpdateReferences( IHierarchicalCodelistObject maintianable, IDictionary<IStructureReference, IStructureReference> updateReferences, string newVersionNumber) { IHierarchicalCodelistMutableObject codelistMutableObject = maintianable.MutableInstance; codelistMutableObject.Version = newVersionNumber; if (codelistMutableObject.CodelistRef != null) { foreach (ICodelistRefMutableObject codelistRef in codelistMutableObject.CodelistRef) { if (codelistRef.CodelistReference != null) { IStructureReference structureReference = updateReferences[codelistRef.CodelistReference]; if (structureReference != null) { codelistRef.CodelistReference = structureReference; } } } } if (codelistMutableObject.Hierarchies != null) { foreach (IHierarchyMutableObject hierarchyMutable in codelistMutableObject.Hierarchies) { this.UpdateCodeRefs(hierarchyMutable.HierarchicalCodeObjects, updateReferences); } } return codelistMutableObject.ImmutableInstance; }
public HierarchicalCodelistObjectBaseCore(IHierarchicalCodelistObject hcl, IList<ICodelistObject> referencedCodelists) : base(hcl) { this.hierarchies = new HashSet<IHierarchyObjectBase<IHierarchicalCodelistObjectBase>>(); /* foreach */ foreach (IHierarchy Ih in hcl.Hierarchies) { hierarchies.Add(new HierarchyObjectBaseCore(Ih, this, referencedCodelists)); } }
public IHierarchicalCodelistObjectBase Build( IHierarchicalCodelistObject buildFrom, ISdmxRetrievalManager retrievalManager) { CrossReferenceResolverEngineCore resolverEngine = new CrossReferenceResolverEngineCore(); ISet<IIdentifiableObject> identifiables = resolverEngine.ResolveReferences( buildFrom, false, 1, retrievalManager); IList<ICodelistObject> referencedCodelists = new List<ICodelistObject>(); /* foreach */ foreach (IIdentifiableObject currentIdentifiable in identifiables) { IMaintainableObject maint = currentIdentifiable .MaintainableParent; if (!referencedCodelists.Contains(maint)) { if (maint is ICodelistObject) { ILOG.J2CsMapping.Collections.Collections.Add(referencedCodelists,(ICodelistObject) maint); } } } return new HierarchicalCodelistObjectBaseCore(buildFrom, referencedCodelists); }
private void SetHierarchyTab(IHierarchicalCodelistObject hcl) { SetHierarchyElementsTab(); }
private void SetGeneralTab(IHierarchicalCodelistObject hcl) { if (!hcl.Id.Contains(_ntdString)) txtHclID.Text = hcl.Id; cmbAgencies.SelectedValue = hcl.AgencyId; if (hcl.Version != _ntdCCVersion) txtVersion.Text = hcl.Version; chkIsFinal.Checked = hcl.IsFinal.IsTrue; if (hcl.Uri != null) txtURI.Text = hcl.Uri.AbsoluteUri; if (!hcl.Urn.ToString().Contains(_ntdString)) txtURN.Text = hcl.Urn.AbsoluteUri; if (hcl.StartDate != null) txtValidFrom.Text = hcl.StartDate.Date.ToString(); if (hcl.EndDate != null) txtValidTo.Text = hcl.EndDate.Date.ToString(); txtHclName.Text = _localizedUtils.GetNameableName(hcl); txtHclDescription.Text = _localizedUtils.GetNameableDescription(hcl); if (!Utils.ViewMode && _action != Action.INSERT) { DuplicateArtefact1.Visible = true; } if (_action != Action.VIEW) { IHierarchicalCodelistMutableObject hclM = hcl.MutableInstance; foreach (ITextTypeWrapperMutableObject name in hclM.Names) { if (name.Value.Contains(_ntdString)) { hclM.Names.Remove(name); break; } } AddTextName.InitTextObjectMutableList = hclM.Names; AddTextDescription.InitTextObjectList = hcl.Descriptions; } AnnotationGeneral.AnnotationObjectList = hcl.MutableInstance.Annotations; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// #region Constructors and Destructors /// <summary> /// Initializes a new instance of the <see cref="HierarchyCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public HierarchyCore(IHierarchicalCodelistObject parent, IHierarchyMutableObject hierarchy) : base(hierarchy, parent) { // LEVELS MUST BE SET BEFORE ANYTHING ELSE this._hasFormalLevels = hierarchy.FormalLevels; if (hierarchy.ChildLevel != null) { this._level = new LevelCore(this, hierarchy.ChildLevel); } this._codeRefs = new List<IHierarchicalCode>(); if (hierarchy.HierarchicalCodeObjects != null) { foreach (ICodeRefMutableObject currentCoderef in hierarchy.HierarchicalCodeObjects) { this._codeRefs.Add(new HierarchicalCodeCore(currentCoderef, this)); } } try { this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="HierarchyCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public HierarchyCore( IHierarchicalCodelistObject parent, Org.Sdmx.Resources.SdmxMl.Schemas.V20.structure.HierarchyType hierarchy) : base( hierarchy, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Hierarchy), hierarchy.id, null, hierarchy.Name, hierarchy.Description, hierarchy.Annotations, parent) { // LEVELS MUST BE SET BEFORE ANYTHING ELSE this._codeRefs = new List<IHierarchicalCode>(); if (ObjectUtil.ValidCollection(hierarchy.Level)) { var levelMap = new SortedList<int, LevelType>(); foreach (LevelType levl in hierarchy.Level) { levelMap.Add(Convert.ToInt32(levl.Order), levl); } IList<LevelType> levelList = new List<LevelType>(); for (int i = 1; i <= levelMap.Count; i++) { if (levelMap.ContainsKey(i)) { levelList.Add(levelMap[i]); } else { // %%% .Factory.NewInstance(); var defaultLevel = new LevelType(); // %%% defaultLevel.AddNewName().SetStringValue("Default"); defaultLevel.id = "DEFAULT"; var t = new TextType(); t.TypedValue = "Default"; defaultLevel.Name.Add(t); levelList.Add(defaultLevel); } } this._level = new LevelCore(this, levelList, 0); this._hasFormalLevels = true; } if (hierarchy.CodeRef != null) { foreach (CodeRefType currentCoderef in hierarchy.CodeRef) { this._codeRefs.Add(new HierarchicalCodeCore(currentCoderef, this)); } } try { this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM V2.1 SCHEMA ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="HierarchyCore"/> class. /// </summary> /// <param name="parent"> /// The parent. /// </param> /// <param name="hierarchy"> /// The hierarchy. /// </param> /// <exception cref="SdmxSemmanticException"> /// Throws Validate exception. /// </exception> public HierarchyCore(IHierarchicalCodelistObject parent, HierarchyType hierarchy) : base(hierarchy, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Hierarchy), parent) { this._codeRefs = new List<IHierarchicalCode>(); // LEVELS MUST BE SET BEFORE ANYTHING ELSE this._hasFormalLevels = hierarchy.leveled; if (hierarchy.Level != null) { this._level = new LevelCore(this, hierarchy.Level); } if (hierarchy.HierarchicalCode != null) { foreach (HierarchicalCodeType currentCoderef in hierarchy.HierarchicalCode) { this._codeRefs.Add(new HierarchicalCodeCore(currentCoderef, this)); } } try { if (hierarchy.leveled) { if (this._level == null) { throw new SdmxSemmanticException( "Hierarchy declares itself as levelled, but does not define any levels"); } } this.Validate(); } catch (SdmxSemmanticException ex) { throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn); } catch (Exception th) { throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn); } }