/// <summary> /// Returns a list of MaintainableObject that are cross referenced by the given identifiable structure /// </summary> /// <param name="identifiable"> /// the identifiable bean to retrieve the references for - What Do I Reference? /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="allowedDataflows"> /// The allowed Dataflows. /// </param> /// <param name="structures"> /// an optional parameter to further filter the list by structure type /// </param> /// <returns> /// The <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> public IList <IMaintainableMutableObject> GetCrossReferencedStructures( IIdentifiableMutableObject identifiable, bool returnStub, IList <IMaintainableRefObject> allowedDataflows, params SdmxStructureType[] structures) { if (identifiable == null) { throw new ArgumentNullException("identifiable"); } var sdmxStructureType = identifiable.StructureType; var maintainableMutableObject = identifiable as IMaintainableMutableObject; if (!sdmxStructureType.IsMaintainable || maintainableMutableObject == null) { throw new NotImplementedException(ErrorMessages.CrossReferenceIdentifiable + sdmxStructureType); } if (maintainableMutableObject.ExternalReference != null && maintainableMutableObject.ExternalReference.IsTrue) { var structureReference = this._fromMutable.Build(maintainableMutableObject); maintainableMutableObject = this.GetMutableMaintainable(structureReference, allowedDataflows); } Func <IStructureReference, IMaintainableMutableObject> retrievalManager = reference => this.GetMutableMaintainable(reference, allowedDataflows, returnStub); var crossReferenceEngine = new CrossReferenceResolverMutableEngine(structures); return(new List <IMaintainableMutableObject>(crossReferenceEngine.ResolveReferences(maintainableMutableObject, 1, retrievalManager))); }
/// <summary> /// Builds an <see cref="ISet{IStructureReference}"/> from the specified <paramref name="identifiable"/> /// </summary> /// <param name="identifiable"> /// An Object to build the output object from /// </param> /// <returns> /// The <see cref="ISet{IStructureReference}"/> from the specified <paramref name="identifiable"/> /// </returns> public ISet <IStructureReference> Build(IIdentifiableMutableObject identifiable) { var structureReferences = new HashSet <IStructureReference>(); switch (identifiable.StructureType.EnumType) { case SdmxStructureEnumType.Dataflow: { // TODO categorisations AddReferences(identifiable as IDataflowMutableObject, structureReferences); } break; case SdmxStructureEnumType.Categorisation: { AddReferences(identifiable as ICategorisationMutableObject, structureReferences); } break; case SdmxStructureEnumType.CategoryScheme: // TODO v2.0 DataflowRef break; case SdmxStructureEnumType.Category: // TODO v2.0 DataflowRef break; case SdmxStructureEnumType.Component: case SdmxStructureEnumType.Dimension: case SdmxStructureEnumType.PrimaryMeasure: case SdmxStructureEnumType.MeasureDimension: case SdmxStructureEnumType.TimeDimension: case SdmxStructureEnumType.CrossSectionalMeasure: case SdmxStructureEnumType.DataAttribute: { AddReferences(identifiable as IComponentMutableObject, structureReferences); } break; case SdmxStructureEnumType.Dsd: { AddReferences(identifiable as IDataStructureMutableObject, structureReferences); } break; case SdmxStructureEnumType.HierarchicalCodelist: { AddReferences(identifiable as IHierarchicalCodelistMutableObject, structureReferences); } break; } return(structureReferences); }
/// <summary> /// Returns a list of MaintainableObject that cross reference the given identifiable structure /// </summary> /// <param name="identifiable"> /// the identifiable bean to retrieve the references for - Who References Me? /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="allowedDataflows"> /// The allowed Dataflows. /// </param> /// <param name="structures"> /// an optional parameter to further filter the list by structure type /// </param> /// <returns> /// The <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> public IList <IMaintainableMutableObject> GetCrossReferencingStructures( IIdentifiableMutableObject identifiable, bool returnStub, IList <IMaintainableRefObject> allowedDataflows, params SdmxStructureType[] structures) { var maintainable = identifiable as IMaintainableMutableObject; if (maintainable == null) { throw new NotImplementedException("Only maintainable are supported by this implementation."); } var structureSet = new HashSet <SdmxStructureType>(structures ?? new SdmxStructureType[0]); IStructureReference structureReference = this._fromMutable.Build(maintainable); var mutableObjects = new List <IMaintainableMutableObject>(); switch (identifiable.StructureType.EnumType) { case SdmxStructureEnumType.Dataflow: { if (structureSet.HasStructure(SdmxStructureEnumType.Categorisation)) { ISet <ICategorisationMutableObject> referenced = this._retrievalEngineContainer.CategorisationRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail(), allowedDataflows); mutableObjects.AddRange(referenced); } } break; case SdmxStructureEnumType.CodeList: { if (structureSet.HasStructure(SdmxStructureEnumType.Dsd)) { ISet <IDataStructureMutableObject> referenced = this._retrievalEngineContainer.DSDRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail()); mutableObjects.AddRange(referenced); } if (structureSet.HasStructure(SdmxStructureEnumType.HierarchicalCodelist)) { ISet <IHierarchicalCodelistMutableObject> referenced2 = this._retrievalEngineContainer.HclRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail()); mutableObjects.AddRange(referenced2); } } break; case SdmxStructureEnumType.ConceptScheme: { if (structureSet.HasStructure(SdmxStructureEnumType.Dsd)) { ISet <IDataStructureMutableObject> referenced = this._retrievalEngineContainer.DSDRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail()); mutableObjects.AddRange(referenced); } } break; case SdmxStructureEnumType.CategoryScheme: { if (structureSet.HasStructure(SdmxStructureEnumType.Categorisation)) { ISet <ICategorisationMutableObject> referenced = this._retrievalEngineContainer.CategorisationRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail(), allowedDataflows); mutableObjects.AddRange(referenced); } } break; case SdmxStructureEnumType.Dsd: { if (structureSet.HasStructure(SdmxStructureEnumType.Dataflow)) { ISet <IDataflowMutableObject> referenced = this._retrievalEngineContainer.DataflowRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail(), allowedDataflows); mutableObjects.AddRange(referenced); } } break; } return(mutableObjects); }
/// <summary> /// Returns a list of MaintainableObject that cross reference the given identifiable structure /// </summary> /// <param name="identifiable"> /// the identifiable bean to retrieve the references for - Who References Me? /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="structures"> /// an optional parameter to further filter the list by structure type /// </param> /// <returns> /// The <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> public IList <IMaintainableMutableObject> GetCrossReferencingStructures(IIdentifiableMutableObject identifiable, bool returnStub, params SdmxStructureType[] structures) { return(this.GetCrossReferencingStructures(identifiable, returnStub, null, structures)); }
/// <summary> /// Write the xml attributes of the given IIdentifiableMutableObject type object /// </summary> /// <param name="artefact"> /// The IIdentifiableMutableObject type object to write /// </param> protected void WriteIdentifiableArtefactAttributes(IIdentifiableMutableObject artefact) { this.WriteAttributeString(AttributeNameTable.id, artefact.Id); this.TryWriteAttribute(AttributeNameTable.uri, artefact.Uri); this.TryWriteAttribute(AttributeNameTable.urn, artefact.Urn); }
/// <summary> /// Gets the parents and siblings reference. /// </summary> /// <param name="returnStub"> /// if set to <c>true</c> [return stub]. /// </param> /// <param name="crossReferenceMutableRetrievalManager"> /// The cross reference mutable retrieval manager. /// </param> /// <param name="allowedDataflow"> /// The allowed dataflow. /// </param> /// <param name="maintainableMutableObject"> /// The maintainable mutable object. /// </param> /// <returns> /// The parents and siblings in a <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> protected internal static IList<IMaintainableMutableObject> GetParentsAndSiblingsReference( bool returnStub, IAuthCrossReferenceMutableRetrievalManager crossReferenceMutableRetrievalManager, IList<IMaintainableRefObject> allowedDataflow, IIdentifiableMutableObject maintainableMutableObject) { // get parents var parents = crossReferenceMutableRetrievalManager.GetCrossReferencingStructures(maintainableMutableObject, returnStub, allowedDataflow); var parentsAndSiblings = new List<IMaintainableMutableObject>(parents); foreach (var parent in parents) { // get siblinks var siblings = crossReferenceMutableRetrievalManager.GetCrossReferencedStructures(parent, returnStub, allowedDataflow); parentsAndSiblings.AddRange(siblings); } return parentsAndSiblings; }
/////////////////////////////////////////////////////////////////////////////////////////////////// ////////////BUILD FROM MUTABLE OBJECT ////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <see cref="IdentifiableCore"/> class. /// </summary> /// <param name="itemMutableObject"> /// The agencySchemeMutable. /// </param> /// <param name="parent"> /// The parent. /// </param> protected internal IdentifiableCore(IIdentifiableMutableObject itemMutableObject, ISdmxStructure parent) : base(itemMutableObject, parent) { this._id = itemMutableObject.Id; this.SetUri(itemMutableObject.Uri); this.ValidateIdentifiableAttributes(); }
/// <summary> /// Gets the reference. /// </summary> /// <param name="mutableObject">The mutable object.</param> /// <param name="identifiableMutableObject">The identifiable mutable object.</param> /// <returns> /// The <see cref="IStructureReference" /> /// </returns> public static IStructureReference AsReference(this IMaintainableMutableObject mutableObject, IIdentifiableMutableObject identifiableMutableObject) { return(new StructureReferenceImpl(mutableObject.AgencyId, mutableObject.Id, mutableObject.Version, identifiableMutableObject.StructureType.EnumType, identifiableMutableObject.Id)); }
/// <summary> /// Gets the reference. /// </summary> /// <param name="mutableObject">The mutable object.</param> /// <param name="identifiableMutableObject">The identifiable mutable object.</param> /// <returns> /// The <see cref="IStructureReference" /> /// </returns> public static IStructureReference AsReference(this IMaintainableMutableObject mutableObject, IIdentifiableMutableObject identifiableMutableObject) { return new StructureReferenceImpl(mutableObject.AgencyId, mutableObject.Id, mutableObject.Version, identifiableMutableObject.StructureType.EnumType, identifiableMutableObject.Id); }
/// <summary> /// Returns a list of MaintainableObject that cross reference the given identifiable structure /// </summary> /// <param name="identifiable"> /// the identifiable bean to retrieve the references for - Who References Me? /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="allowedDataflows"> /// The allowed Dataflows. /// </param> /// <param name="structures"> /// an optional parameter to further filter the list by structure type /// </param> /// <returns> /// The <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> public IList<IMaintainableMutableObject> GetCrossReferencingStructures( IIdentifiableMutableObject identifiable, bool returnStub, IList<IMaintainableRefObject> allowedDataflows, params SdmxStructureType[] structures) { var maintainable = identifiable as IMaintainableMutableObject; if (maintainable == null) { throw new NotImplementedException("Only maintainable are supported by this implementation."); } var structureSet = new HashSet<SdmxStructureType>(structures ?? new SdmxStructureType[0]); IStructureReference structureReference = this._fromMutable.Build(maintainable); var mutableObjects = new List<IMaintainableMutableObject>(); switch (identifiable.StructureType.EnumType) { case SdmxStructureEnumType.Dataflow: { if (structureSet.HasStructure(SdmxStructureEnumType.Categorisation)) { ISet<ICategorisationMutableObject> referenced = this._retrievalEngineContainer.CategorisationRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail(), allowedDataflows); mutableObjects.AddRange(referenced); } } break; case SdmxStructureEnumType.CodeList: { if (structureSet.HasStructure(SdmxStructureEnumType.Dsd)) { ISet<IDataStructureMutableObject> referenced = this._retrievalEngineContainer.DSDRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail()); mutableObjects.AddRange(referenced); } if (structureSet.HasStructure(SdmxStructureEnumType.HierarchicalCodelist)) { ISet<IHierarchicalCodelistMutableObject> referenced2 = this._retrievalEngineContainer.HclRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail()); mutableObjects.AddRange(referenced2); } } break; case SdmxStructureEnumType.ConceptScheme: { if (structureSet.HasStructure(SdmxStructureEnumType.Dsd)) { ISet<IDataStructureMutableObject> referenced = this._retrievalEngineContainer.DSDRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail()); mutableObjects.AddRange(referenced); } } break; case SdmxStructureEnumType.CategoryScheme: { if (structureSet.HasStructure(SdmxStructureEnumType.Categorisation)) { ISet<ICategorisationMutableObject> referenced = this._retrievalEngineContainer.CategorisationRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail(), allowedDataflows); mutableObjects.AddRange(referenced); } } break; case SdmxStructureEnumType.Dsd: { if (structureSet.HasStructure(SdmxStructureEnumType.Dataflow)) { ISet<IDataflowMutableObject> referenced = this._retrievalEngineContainer.DataflowRetrievalEngine.RetrieveFromReferenced( structureReference, returnStub.GetComplexQueryDetail(), allowedDataflows); mutableObjects.AddRange(referenced); } } break; } return mutableObjects; }
/// <summary> /// Returns a list of MaintainableObject that cross reference the given identifiable structure /// </summary> /// <param name="identifiable"> /// the identifiable bean to retrieve the references for - Who References Me? /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="structures"> /// an optional parameter to further filter the list by structure type /// </param> /// <returns> /// The <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> public IList<IMaintainableMutableObject> GetCrossReferencingStructures(IIdentifiableMutableObject identifiable, bool returnStub, params SdmxStructureType[] structures) { return this.GetCrossReferencingStructures(identifiable, returnStub, null, structures); }
/// <summary> /// Returns a list of MaintainableObject that are cross referenced by the given identifiable structure /// </summary> /// <param name="identifiable"> /// the identifiable bean to retrieve the references for - What Do I Reference? /// </param> /// <param name="returnStub"> /// The return Stub. /// </param> /// <param name="allowedDataflows"> /// The allowed Dataflows. /// </param> /// <param name="structures"> /// an optional parameter to further filter the list by structure type /// </param> /// <returns> /// The <see cref="IList{IMaintainableMutableObject}"/>. /// </returns> public IList<IMaintainableMutableObject> GetCrossReferencedStructures( IIdentifiableMutableObject identifiable, bool returnStub, IList<IMaintainableRefObject> allowedDataflows, params SdmxStructureType[] structures) { if (identifiable == null) { throw new ArgumentNullException("identifiable"); } var sdmxStructureType = identifiable.StructureType; var maintainableMutableObject = identifiable as IMaintainableMutableObject; if (!sdmxStructureType.IsMaintainable || maintainableMutableObject == null) { throw new NotImplementedException(ErrorMessages.CrossReferenceIdentifiable + sdmxStructureType); } if (maintainableMutableObject.ExternalReference != null && maintainableMutableObject.ExternalReference.IsTrue) { var structureReference = this._fromMutable.Build(maintainableMutableObject); maintainableMutableObject = this.GetMutableMaintainable(structureReference, allowedDataflows); } Func<IStructureReference, IMaintainableMutableObject> retrievalManager = reference => this.GetMutableMaintainable(reference, allowedDataflows, returnStub); var crossReferenceEngine = new CrossReferenceResolverMutableEngine(structures); return new List<IMaintainableMutableObject>(crossReferenceEngine.ResolveReferences(maintainableMutableObject, 1, retrievalManager)); }