/// <summary> /// Gets the structure. /// </summary> /// <param name="state">The state.</param> /// <param name="reference">The reference.</param> /// <returns>The <see cref="ItemStatusCollection"/></returns> public ItemSchemeFinalStatus GetStructure(DbTransactionState state, IStructureReference reference) { ItemSchemeFinalStatus returnObjet; if (!this._dictionary.TryGetValue(reference, out returnObjet)) { var artefactFinalStatus = ArtefactBaseEngine.GetFinalStatus(state, reference); ItemStatusCollection collection = null; if (artefactFinalStatus != null && artefactFinalStatus.IsFinal && reference.HasChildReference()) { switch (reference.TargetReference.EnumType) { case SdmxStructureEnumType.Component: case SdmxStructureEnumType.Dimension: case SdmxStructureEnumType.TimeDimension: case SdmxStructureEnumType.MeasureDimension: case SdmxStructureEnumType.DataAttribute: case SdmxStructureEnumType.PrimaryMeasure: case SdmxStructureEnumType.CrossSectionalMeasure: var map = GetComponentMapIds(state, reference); collection = new ItemStatusCollection(map.Select(pair => new ItemStatus(pair.Key, pair.Value))); break; default: collection = GetId(state, reference.TargetReference.EnumType, artefactFinalStatus.PrimaryKey); break; } } returnObjet = new ItemSchemeFinalStatus(artefactFinalStatus ?? ArtefactFinalStatus.Empty, collection); } return(returnObjet); }
/// <summary> /// Returns an error message with the specified <paramref name="format"/> for <paramref name="reference"/> /// </summary> /// <param name="format"> /// The format. /// </param> /// <param name="reference"> /// The component. /// </param> /// <returns> /// The error message. /// </returns> private static string GetError(string format, IStructureReference reference) { IMaintainableRefObject maintainableRefObject = reference.MaintainableReference; return(reference.HasChildReference() ? string.Format(format, maintainableRefObject.MaintainableId, maintainableRefObject.AgencyId, maintainableRefObject.Version, reference.ChildReference.Id) : string.Format(format, maintainableRefObject.MaintainableId, maintainableRefObject.AgencyId, maintainableRefObject.Version)); }
/// <summary> /// Returns an error message with the specified <paramref name="format"/> for <paramref name="reference"/> /// </summary> /// <param name="format"> /// The format. /// </param> /// <param name="reference"> /// The component. /// </param> /// <returns> /// The error message. /// </returns> public string GetError(string format, IStructureReference reference) { IMaintainableRefObject maintainableRefObject = reference.MaintainableReference; return reference.HasChildReference() ? string.Format( format, maintainableRefObject.MaintainableId, maintainableRefObject.AgencyId, maintainableRefObject.Version, reference.ChildReference.Id, reference.TargetReference) : string.Format(format, maintainableRefObject.MaintainableId, maintainableRefObject.AgencyId, maintainableRefObject.Version, reference.TargetReference); }
/// <summary> /// Gets the structure. /// </summary> /// <param name="state">The state.</param> /// <param name="reference">The reference.</param> /// <returns>The <see cref="ItemStatusCollection"/></returns> public ItemSchemeFinalStatus GetStructure(DbTransactionState state, IStructureReference reference) { ItemSchemeFinalStatus returnObjet; if (!this._dictionary.TryGetValue(reference, out returnObjet)) { var artefactFinalStatus = ArtefactBaseEngine.GetFinalStatus(state, reference); ItemStatusCollection collection = null; if (artefactFinalStatus != null && artefactFinalStatus.IsFinal && reference.HasChildReference()) { switch (reference.TargetReference.EnumType) { case SdmxStructureEnumType.Component: case SdmxStructureEnumType.Dimension: case SdmxStructureEnumType.TimeDimension: case SdmxStructureEnumType.MeasureDimension: case SdmxStructureEnumType.DataAttribute: case SdmxStructureEnumType.PrimaryMeasure: case SdmxStructureEnumType.CrossSectionalMeasure: var map = GetComponentMapIds(state, reference); collection = new ItemStatusCollection(map.Select(pair => new ItemStatus(pair.Key, pair.Value))); break; default: collection = GetId(state, reference.TargetReference.EnumType, artefactFinalStatus.PrimaryKey); break; } } returnObjet = new ItemSchemeFinalStatus(artefactFinalStatus ?? ArtefactFinalStatus.Empty, collection); } return returnObjet; }
/// <summary> /// Gets a value indicating whether the getChildReference returns a value /// </summary> /// <returns> /// The <see cref="bool" /> . /// </returns> public bool HasChildReference() { return(StructureReference.HasChildReference()); }
/// <summary> /// Sets reference. /// </summary> /// <param name="refBase"> /// The refBase. /// </param> /// <param name="crossReference"> /// The cross reference. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="crossReference"/> is null /// -or- /// <paramref name="refBase"/> is null /// </exception> /// <exception cref="ValidationException"> /// URN class is null /// </exception> protected internal void SetReference(RefBaseType refBase, IStructureReference crossReference) { if (refBase == null) { throw new ArgumentNullException("refBase"); } if (crossReference == null) { throw new ArgumentNullException("crossReference"); } IMaintainableRefObject maintRef = crossReference.MaintainableReference; if (crossReference.HasChildReference()) { string fullId = GetFullIdentifiableId(crossReference); int lastIndexOf = fullId.LastIndexOf(DELIMITER); if (lastIndexOf > -1) { string containerId = fullId.Substring(0, lastIndexOf); string targetId = fullId.Substring(lastIndexOf, fullId.Length - lastIndexOf); refBase.containerID = containerId; refBase.id = targetId; } else { refBase.id = fullId; } string value = maintRef.MaintainableId; if (!string.IsNullOrWhiteSpace(value)) { refBase.maintainableParentID = maintRef.MaintainableId; } string value1 = maintRef.Version; if (!string.IsNullOrWhiteSpace(value1)) { refBase.maintainableParentVersion = maintRef.Version; } } else { string value = maintRef.MaintainableId; if (!string.IsNullOrWhiteSpace(value)) { refBase.id = maintRef.MaintainableId; } string value1 = maintRef.Version; if (!string.IsNullOrWhiteSpace(value1)) { refBase.version = maintRef.Version; } } string value2 = maintRef.AgencyId; if (!string.IsNullOrWhiteSpace(value2)) { refBase.agencyID = maintRef.AgencyId; } //// TODO because of differences in the Xml and LINQ2XSD generated code setting package and class might not be needed. SdmxStructureType sdmxStructureType = crossReference.TargetReference; //// TODO Assume that the PackageTypeCodelistType are the same as in SdmxStructureType.UrnPackage string urnPackage = sdmxStructureType.UrnPackage; refBase.package = urnPackage; //// PackageTypeCodelistType.TypeDefinition. string classEnum; switch (crossReference.TargetReference.EnumType) { //Place any exclusions to the rule in this case statement case SdmxStructureEnumType.DataAttribute: classEnum = ObjectTypeCodelistTypeConstants.Attribute; break; default: string urnClass = crossReference.TargetReference.UrnClass; classEnum = urnClass;//ObjectTypeCodelistType.Enum.forString(urnClass); break; } if (classEnum == null) { throw new SdmxSemmanticException("Unknown urnClass : " + crossReference.TargetReference.UrnClass); } refBase.@class = classEnum; }