/// <summary>
        /// Builds the categorisation dictionary where dataflow <see cref="IMaintainableRefObject"/> are keys and lists of
        ///     <see cref="ICategorisationMutableObject"/>
        ///     the value.
        /// </summary>
        /// <param name="categorisations">
        /// The categorisations.
        /// </param>
        /// <param name="itemScheme">
        /// The Category Scheme
        /// </param>
        /// <returns>
        /// The categorisation dictionary
        /// </returns>
        private static IDictionaryOfLists<string, ICategorisationMutableObject> BuildCategorisationMap(
            IEnumerable<ICategorisationMutableObject> categorisations, IMaintainableMutableObject itemScheme)
        {
            var categorisationMap = new DictionaryOfLists<string, ICategorisationMutableObject>(StringComparer.Ordinal);
            var categorySchemeRef = new MaintainableRefObjectImpl(
                itemScheme.AgencyId, itemScheme.Id, itemScheme.Version);
            foreach (ICategorisationMutableObject categorisation in categorisations)
            {
                IStructureReference structureReference = categorisation.StructureReference;
                switch (structureReference.MaintainableStructureEnumType.EnumType)
                {
                    case SdmxStructureEnumType.Dataflow:
                        IStructureReference categoryRef = categorisation.CategoryReference;
                        if (categorySchemeRef.Equals(categoryRef.MaintainableReference))
                        {
                            IList<ICategorisationMutableObject> categoryDataflows;
                            string categoryId = categoryRef.ChildReference.GetLastId();
                            if (!categorisationMap.TryGetValue(categoryId, out categoryDataflows))
                            {
                                categoryDataflows = new List<ICategorisationMutableObject>();
                                categorisationMap.Add(categoryId, categoryDataflows);
                            }

                            categoryDataflows.Add(categorisation);
                        }

                        break;
                }
            }

            return categorisationMap;
        }
예제 #2
0
        /// <summary>
        /// Normalizes the SDMXV20 data structure.
        /// </summary>
        /// <param name="dataStructure">The data structure.</param>
        public static void NormalizeSdmxv20DataStructure(this IMaintainableMutableObject dataStructure)
        {
            var dsd = dataStructure as IDataStructureMutableObject;

            if (dsd != null)
            {
                dsd.NormalizeSdmxv20DataStructure();
            }
        }
예제 #3
0
        /// <summary>
        /// Resolve references.
        /// </summary>
        /// <param name="beans">
        /// The beans.
        /// </param>
        /// <param name="numberLevelsDeep">
        /// The number levels deep.
        /// </param>
        /// <param name="retrievalManager">
        /// The retrieval manager.
        /// </param>
        /// <param name="missingReferences">
        /// The missing references.
        /// </param>
        /// <returns>
        /// The <see cref="MaintainableDictionary{IMaintainableMutableObject}"/>.
        /// </returns>
        private MaintainableDictionary <IMaintainableMutableObject> ResolveReferencesInternal(
            IMutableObjects beans, int numberLevelsDeep, Func <IStructureReference, IMaintainableMutableObject> retrievalManager, IDictionaryOfSets <IMaintainableMutableObject, IStructureReference> missingReferences)
        {
            var returnMap  = new MaintainableDictionary <IMaintainableMutableObject>();
            var outerLevel = new Queue <IMaintainableMutableObject>();

            foreach (IMaintainableMutableObject artefact in beans.AllMaintainables)
            {
                outerLevel.Enqueue(artefact);
            }

            int count = 0;

            do
            {
                var innerLevel = new Queue <IMaintainableMutableObject>();
                while (outerLevel.Count > 0)
                {
                    IMaintainableMutableObject parent = outerLevel.Dequeue();
                    var structureReferences           = GetChildStructureReferences(retrievalManager, parent);

                    foreach (IStructureReference structureReference in structureReferences)
                    {
                        if (structureReference == null)
                        {
                            string message = string.Format(CultureInfo.InvariantCulture, "Null reference for parent artefact : {0}+{1}+{2}", parent.AgencyId, parent.Id, parent.Version);
                            _log.Error(message);
                            throw new MappingStoreException(message);
                        }

                        if (this._structureTypeSet.HasStructure(structureReference.MaintainableStructureEnumType))
                        {
                            IMaintainableMutableObject resolved = this.GetMutableObject(retrievalManager, structureReference);

                            if (resolved != null)
                            {
                                returnMap.AddToSet(parent, resolved);
                                if (numberLevelsDeep == 0 || numberLevelsDeep > count)
                                {
                                    innerLevel.Enqueue(resolved);
                                }
                            }
                            else if (missingReferences != null)
                            {
                                missingReferences.AddToSet(parent, structureReference);
                            }
                        }
                    }
                }

                count++;
                outerLevel = innerLevel;
            }while (count < numberLevelsDeep);

            return(returnMap);
        }
        /// <summary>
        ///     Gets the latest.
        /// </summary>
        /// <param name="maintainableObject">The maintainable object.</param>
        /// <param name="allowedDataflows">The allowed dataflows.</param>
        /// <returns>The <see cref="IMaintainableMutableObject" />.</returns>
        public IMaintainableMutableObject GetLatest(IMaintainableMutableObject maintainableObject, IList<IMaintainableRefObject> allowedDataflows)
        {
            var latest = this._mutableStructureSearchManager.GetLatest(maintainableObject);
            if (allowedDataflows != null)
            {
                return allowedDataflows.Any(o => o.IsMatch(latest)) ? latest : null;
            }

            return latest;
        }
예제 #5
0
        /// <summary>
        /// Returns a list of MaintainableObject that cross reference the structure(s) that match the reference parameter
        /// </summary>
        /// <param name="structureReference">
        /// 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(
            IStructureReference structureReference, bool returnStub, IList <IMaintainableRefObject> allowedDataflows, params SdmxStructureType[] structures)
        {
            if (structureReference == null)
            {
                throw new ArgumentNullException("structureReference");
            }

            IMaintainableMutableObject maintainableObject = this.GetMutableMaintainable(structureReference, allowedDataflows, returnStub);

            return(this.GetCrossReferencingStructures(maintainableObject, returnStub, allowedDataflows, structures));
        }
 /// <summary>
 /// Gets the latest.
 /// </summary>
 /// <param name="maintainableObject">The maintainable object.</param>
 /// <returns>The <see cref="IMaintainableMutableObject"/>.</returns>
 public IMaintainableMutableObject GetLatest(IMaintainableMutableObject maintainableObject)
 {
     var immutable = this._sdmxObjectRetrieval.GetMaintainableObject(maintainableObject.ImmutableInstance.AsReference, false, true);
     if (immutable != null)
     {
         return immutable.MutableInstance;
     }
     else
     {
         return null;
     }
 }
예제 #7
0
        /// <summary>
        /// Check if the specified <paramref name="maintainable"/> is <c>SDMX v2.0</c> only.
        /// </summary>
        /// <param name="maintainable">
        /// The maintainable.
        /// </param>
        /// <returns>
        /// True if the specified <paramref name="maintainable"/> is <c>SDMX v2.0</c> only; otherwise false.
        /// </returns>
        public static bool IsSdmxV20Only(this IMaintainableMutableObject maintainable)
        {
            if (maintainable != null)
            {
                switch (maintainable.StructureType.EnumType)
                {
                case SdmxStructureEnumType.Dsd:
                    var crossDsd = maintainable as ICrossSectionalDataStructureMutableObject;
                    if (crossDsd != null)
                    {
                        return(true);
                    }

                    break;
                }
            }

            return(false);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CrossReferenceTreeMutableCore"/> class.
        /// </summary>
        /// <param name="crossReferencingTree">
        /// The cross referencing tree. 
        /// </param>
        /// <param name="serviceRetrievalManager">
        /// The service retrieval manager. 
        /// </param>
        public CrossReferenceTreeMutableCore(
            ICrossReferencingTree crossReferencingTree, IServiceRetrievalManager serviceRetrievalManager)
        {
            this._referencingObjects = new List<ICrossReferenceTreeMutable>();
            if (serviceRetrievalManager != null)
            {
                this._maintainableMutableObject =
                    serviceRetrievalManager.CreateStub(crossReferencingTree.Maintainable).MutableInstance;
            }
            else
            {
                this._maintainableMutableObject = crossReferencingTree.Maintainable.MutableInstance;
            }

            foreach (ICrossReferencingTree currentChildReference in crossReferencingTree.ReferencingStructures)
            {
                this._referencingObjects.Add(new CrossReferenceTreeMutableCore(currentChildReference));
            }
        }
예제 #9
0
        /// <summary>
        /// Returns a set of <see cref="IMaintainableMutableObject"/> that the IMaintainableMutableObject cross references
        /// </summary>
        /// <param name="artefact">
        /// The bean.
        /// </param>
        /// <param name="numberLevelsDeep">
        /// references, an argument of 0 (zero) implies there is no limit, and the resolver engine will continue re-cursing until it has found every directly and indirectly referenced artifact. Note that there is no risk of infinite recursion in calling this.
        /// </param>
        /// <param name="retrievalManager">
        /// - Used to resolve the structure references. Can be null, if supplied this is used to resolve any references that do not exist in the supplied beans
        /// </param>
        /// <exception cref="SdmxReferenceException">
        /// - if any of the references could not be resolved
        /// </exception>
        /// <exception cref="ArgumentNullException"><paramref name="artefact"/> is null.</exception>
        /// <returns>
        /// a set of <see cref="IMaintainableMutableObject"/> that the IMaintainableMutableObject cross references
        /// </returns>
        public ISet <IMaintainableMutableObject> ResolveReferences(IMaintainableMutableObject artefact, int numberLevelsDeep, Func <IStructureReference, IMaintainableMutableObject> retrievalManager)
        {
            if (artefact == null)
            {
                throw new ArgumentNullException("artefact");
            }

            IMutableObjects objects = new MutableObjectsImpl();

            objects.AddIdentifiable(artefact);
            IDictionaryOfSets <IMaintainableMutableObject, IMaintainableMutableObject> dictionaryOfSets = this.ResolveReferences(objects, numberLevelsDeep, retrievalManager);
            ISet <IMaintainableMutableObject> set;

            if (!dictionaryOfSets.TryGetValue(artefact, out set))
            {
                set = new HashSet <IMaintainableMutableObject>();
            }

            return(set);
        }
        /// <summary>
        /// Gets the child structure references.
        /// </summary>
        /// <param name="retrievalManager">
        /// The retrieval manager.
        /// </param>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IStructureReference}"/>.
        /// </returns>
        private static IEnumerable<IStructureReference> GetChildStructureReferences(Func<IStructureReference, IMaintainableMutableObject> retrievalManager, IMaintainableMutableObject parent)
        {
            ISet<IStructureReference> structureReferences;
            if (parent.ExternalReference != null && parent.ExternalReference.IsTrue)
            {
                switch (parent.StructureType.EnumType)
                {
                    case SdmxStructureEnumType.CodeList:
                    case SdmxStructureEnumType.ConceptScheme:
                        structureReferences = new HashSet<IStructureReference>();
                        break;
                    default:
                        {
                            var parentReference = _fromMutable.Build(parent);
                            var parentNoStub = retrievalManager(parentReference);
                            structureReferences = _childBuilder.Build(parentNoStub);
                        }

                        break;
                }
            }
            else
            {
                structureReferences = _childBuilder.Build(parent);
            }
            return structureReferences;
        }
        /// <summary>
        /// Returns a set of <see cref="IMaintainableMutableObject"/> that the IMaintainableMutableObject cross references
        /// </summary>
        /// <param name="artefact">
        /// The bean.
        /// </param>
        /// <param name="numberLevelsDeep">
        /// references, an argument of 0 (zero) implies there is no limit, and the resolver engine will continue re-cursing until it has found every directly and indirectly referenced artifact. Note that there is no risk of infinite recursion in calling this.
        /// </param>
        /// <param name="retrievalManager">
        /// - Used to resolve the structure references. Can be null, if supplied this is used to resolve any references that do not exist in the supplied beans
        /// </param>
        /// <exception cref="SdmxReferenceException">
        /// - if any of the references could not be resolved
        /// </exception>
        /// <exception cref="ArgumentNullException"><paramref name="artefact"/> is null.</exception>
        /// <returns>
        /// a set of <see cref="IMaintainableMutableObject"/> that the IMaintainableMutableObject cross references
        /// </returns>
        public ISet<IMaintainableMutableObject> ResolveReferences(IMaintainableMutableObject artefact, int numberLevelsDeep, Func<IStructureReference, IMaintainableMutableObject> retrievalManager)
        {
            if (artefact == null)
            {
                throw new ArgumentNullException("artefact");
            }

            IMutableObjects objects = new MutableObjectsImpl();
            objects.AddIdentifiable(artefact);
            IDictionaryOfSets<IMaintainableMutableObject, IMaintainableMutableObject> dictionaryOfSets = this.ResolveReferences(objects, numberLevelsDeep, retrievalManager);
            ISet<IMaintainableMutableObject> set;
            if (!dictionaryOfSets.TryGetValue(artefact, out set))
            {
                set = new HashSet<IMaintainableMutableObject>();
            }

            return set;
        }
 /// <summary>
 /// Returns the latest version of the maintainable for the given maintainable input
 /// </summary>
 /// <param name="maintainableObject">
 /// The maintainable Object.
 /// </param>
 /// <returns>
 /// The <see cref="T:Org.Sdmxsource.Sdmx.Api.Model.Mutable.Base.IMaintainableMutableObject"/>.
 /// </returns>
 public IMaintainableMutableObject GetLatest(IMaintainableMutableObject maintainableObject)
 {
     return this._authStructureRetriever.GetLatest(maintainableObject, null);
 }
 /// <summary>
 /// Write the xml attributes of the given IMaintainableMutableObject type object
 /// </summary>
 /// <param name="artefact">
 /// The IMaintainableMutableObject type object to write
 /// </param>
 private void WriteMaintainableArtefactAttributes(IMaintainableMutableObject artefact)
 {
     this.WriteIdentifiableArtefactAttributes(artefact);
     this.TryWriteAttribute(AttributeNameTable.version, artefact.Version);
     this.TryWriteAttribute(AttributeNameTable.validFrom, artefact.StartDate);
     this.TryWriteAttribute(AttributeNameTable.validTo, artefact.EndDate);
     this.TryWriteAttribute(AttributeNameTable.agencyID, artefact.AgencyId);
     this.TryWriteAttribute(AttributeNameTable.isFinal, artefact.FinalStructure);
     this.TryWriteAttribute(AttributeNameTable.isExternalReference, artefact.ExternalReference);
 }
예제 #14
0
 /// <summary>
 /// Gets the reference.
 /// </summary>
 /// <param name="mutableObject">The mutable object.</param>
 /// <returns>
 /// The <see cref="IStructureReference"/>
 /// </returns>
 public static IStructureReference AsReference(this IMaintainableMutableObject mutableObject)
 {
     return(_fromMutableBuilder.Build(mutableObject));
 }
        /// <summary>
        /// Processes the node.
        /// </summary>
        /// <param name="crossReferenceManager">The cross reference manager.</param>
        /// <param name="maintainable">The maintainable.</param>
        /// <param name="specificStructureType">Type of the specific structure.</param>
        /// <param name="returnStub">if set to <c>true</c> [return stub].</param>
        /// <param name="allowedDataflows">The allowed dataflows.</param>
        /// <param name="rootNode">The root node.</param>
        /// <param name="specificObjects">The specific objects.</param>
        /// <param name="stack">The stack.</param>
        private static void ProcessNode(
            IAuthCrossReferenceMutableRetrievalManager crossReferenceManager, 
            IMaintainableMutableObject maintainable, 
            BaseConstantType<SdmxStructureEnumType> specificStructureType, 
            bool returnStub, 
            IList<IMaintainableRefObject> allowedDataflows, 
            RelationNode rootNode, 
            ICollection<IMaintainableMutableObject> specificObjects, 
            Stack<IMaintainableMutableObject> stack)
        {
            var isTarget = rootNode.DestType == specificStructureType.EnumType;
            bool getStub;
            Action<IMaintainableMutableObject> action;
            if (isTarget)
            {
                getStub = returnStub;
                action = specificObjects.Add;
            }
            else
            {
                getStub = rootNode.DestType != SdmxStructureEnumType.Categorisation;
                action = stack.Push;
            }

            var rootFunc = GetFunc(crossReferenceManager, getStub, allowedDataflows, rootNode);
            
            foreach (var maintainableMutableObject in rootFunc(maintainable))
            {
                action(maintainableMutableObject);
            }
        }
        /// <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;
        }
예제 #17
0
        /// <summary>
        /// Gets the child structure references.
        /// </summary>
        /// <param name="retrievalManager">
        /// The retrieval manager.
        /// </param>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IStructureReference}"/>.
        /// </returns>
        private static IEnumerable <IStructureReference> GetChildStructureReferences(Func <IStructureReference, IMaintainableMutableObject> retrievalManager, IMaintainableMutableObject parent)
        {
            ISet <IStructureReference> structureReferences;

            if (parent.ExternalReference != null && parent.ExternalReference.IsTrue)
            {
                switch (parent.StructureType.EnumType)
                {
                case SdmxStructureEnumType.CodeList:
                case SdmxStructureEnumType.ConceptScheme:
                    structureReferences = new HashSet <IStructureReference>();
                    break;

                default:
                {
                    var parentReference = _fromMutable.Build(parent);
                    var parentNoStub    = retrievalManager(parentReference);
                    structureReferences = _childBuilder.Build(parentNoStub);
                }

                break;
                }
            }
            else
            {
                structureReferences = _childBuilder.Build(parent);
            }
            return(structureReferences);
        }
 /// <summary>
 /// Returns a tree structure representing the <paramref name="maintainableObject"/> and all the structures that cross reference it, and the structures that reference them, and so on.
 /// </summary>
 /// <param name="maintainableObject">
 /// The maintainable object to build the tree for.
 /// </param>
 /// <param name="allowedDataflows">
 /// The allowed Dataflows.
 /// </param>
 /// <returns>
 /// The <see cref="IMutableCrossReferencingTree"/>.
 /// </returns>
 public IMutableCrossReferencingTree GetCrossReferenceTree(IMaintainableMutableObject maintainableObject, IList<IMaintainableRefObject> allowedDataflows)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Gets the descendants 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="allowedDataflows">
        /// The allowed dataflows.
        /// </param>
        /// <param name="maintainableMutableObject">
        /// The maintainable mutable object.
        /// </param>
        /// <returns>
        /// The descendants in <see cref="IList{IMaintainableMutableObject}"/>.
        /// </returns>
        protected internal static IList<IMaintainableMutableObject> GetDescendantsReference(
            bool returnStub, 
            IAuthCrossReferenceMutableRetrievalManager crossReferenceMutableRetrievalManager, 
            IList<IMaintainableRefObject> allowedDataflows, 
            IMaintainableMutableObject maintainableMutableObject)
        {
            var descendants = new List<IMaintainableMutableObject>();
            var stack = new Stack<IMaintainableMutableObject>();
            stack.Push(maintainableMutableObject);
            while (stack.Count > 0)
            {
                var descendant = stack.Pop();
                descendants.Add(descendant);
                var children = crossReferenceMutableRetrievalManager.GetCrossReferencedStructures(descendant, returnStub, allowedDataflows);
                for (int i = 0; i < children.Count; i++)
                {
                    stack.Push(children[i]);
                }
            }

            return descendants;
        }
 /// <summary>
 ///     Determines whether the specified maintainable reference matches the <paramref name="maintainable" />.
 /// </summary>
 /// <param name="maintainableReference">The maintainable reference.</param>
 /// <param name="maintainable">The maintainable.</param>
 /// <returns><c>true</c> if the specified maintainable reference is match; otherwise, <c>false</c>.</returns>
 public static bool IsMatch(this IMaintainableRefObject maintainableReference, IMaintainableMutableObject maintainable)
 {
     return maintainable.StructureType.EnumType != SdmxStructureEnumType.Dataflow
            || (maintainable.Id.Equals(maintainableReference.MaintainableId) && (!maintainableReference.HasAgencyId() || maintainable.AgencyId.Equals(maintainableReference.AgencyId))
                && (!maintainableReference.HasVersion() || maintainable.Version.Equals(maintainableReference.Version)));
 }
        /// <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 override IMaintainableMutableObject GetLatest(IMaintainableMutableObject maintainableObject, IList<IMaintainableRefObject> allowedDataflows)
        {
            var maintainableMutableObject = base.GetLatest(maintainableObject, allowedDataflows);
            maintainableMutableObject.NormalizeSdmxv20DataStructure();

            return maintainableMutableObject;
        }
예제 #22
0
 /// <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 specific structures of the specified type <paramref name="specificStructureType"/> related to the <paramref name="maintainable"/>
        /// </summary>
        /// <param name="crossReferenceManager">
        /// The cross reference manager.
        /// </param>
        /// <param name="maintainable">
        /// The maintainable.
        /// </param>
        /// <param name="specificStructureType">
        /// The specific structure type.
        /// </param>
        /// <param name="returnStub">
        /// The return stub.
        /// </param>
        /// <param name="allowedDataflows">
        /// The allowed dataflows.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{IMaintainableMutableObject}"/>.
        /// </returns>
        private static IEnumerable<IMaintainableMutableObject> GetSpecificObjects(
            IAuthCrossReferenceMutableRetrievalManager crossReferenceManager, 
            IMaintainableMutableObject maintainable, 
            BaseConstantType<SdmxStructureEnumType> specificStructureType, 
            bool returnStub, 
            IList<IMaintainableRefObject> allowedDataflows)
        {
            var specificObjects = new List<IMaintainableMutableObject>();
            var relationNodes = RelationBuilder.Build(maintainable.StructureType.EnumType, specificStructureType.EnumType);
            var stack = new Stack<IMaintainableMutableObject>();
            foreach (var rootNode in relationNodes)
            {
                ProcessNode(crossReferenceManager, maintainable, specificStructureType, returnStub, allowedDataflows, rootNode, specificObjects, stack);

                while (stack.Count > 0)
                {
                    var current = stack.Pop();
                    var currentNode = RelationBuilder.Build(current.StructureType.EnumType, specificStructureType.EnumType).FirstOrDefault();
                    if (currentNode != null)
                    {
                        ProcessNode(crossReferenceManager, current, specificStructureType, returnStub, allowedDataflows, currentNode, specificObjects, stack);
                    }
                }
            }

            return specificObjects;
        }
 /// <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="T:Org.Sdmxsource.Sdmx.Api.Model.Mutable.Base.IMaintainableMutableObject"/>.
 /// </returns>
 public IMaintainableMutableObject GetLatest(IMaintainableMutableObject maintainableObject, IList<IMaintainableRefObject> allowedDataflows)
 {
     return this._authStructureRetriever.GetLatest(maintainableObject, allowedDataflows);
 }
 /// <summary>
 /// Add dummy values for validity.
 /// </summary>
 /// <param name="dataflowRefType">
 /// The dataflow ref type.
 /// </param>
 /// <param name="mutable">
 /// The mutable.
 /// </param>
 private static void AddDummyValuesForValidity(DataflowRefType dataflowRefType, IMaintainableMutableObject mutable)
 {
     mutable.AddName("en", "Content Constraint for dataflow"); // TODO: Name is hardcoded.
     mutable.AgencyId = dataflowRefType.AgencyID;
 }
예제 #26
0
 /// <summary>
 /// Returns a tree structure representing the <paramref name="maintainableObject"/> and all the structures that cross reference it, and the structures that reference them, and so on.
 /// </summary>
 /// <param name="maintainableObject">
 /// The maintainable object to build the tree for.
 /// </param>
 /// <param name="allowedDataflows">
 /// The allowed Dataflows.
 /// </param>
 /// <returns>
 /// The <see cref="IMutableCrossReferencingTree"/>.
 /// </returns>
 public IMutableCrossReferencingTree GetCrossReferenceTree(IMaintainableMutableObject maintainableObject, IList <IMaintainableRefObject> allowedDataflows)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Write the given IMaintainableMutableObject type object to the given element.
 /// </summary>
 /// <param name="element">
 /// The xml element
 /// </param>
 /// <param name="artefact">
 /// The IMaintainableMutableObject type object to write
 /// </param>
 protected void WriteMaintainableArtefact(ElementNameTable element, IMaintainableMutableObject artefact)
 {
     this.WriteStartElement(this.DefaultPrefix, element);
     this.WriteMaintainableArtefactAttributes(artefact);
     this.WriteIdentifiableArtefactContent(artefact);
 }
 /// <summary>
 /// Gets the mutable container object.
 /// </summary>
 /// <param name="mutableSearchManager">
 /// The mutable search manager.
 /// </param>
 /// <param name="mockQuery">
 /// The mock query.
 /// </param>
 /// <param name="maintainableMutableObject">
 /// The maintainable mutable object.
 /// </param>
 /// <returns>
 /// The mutable object container.
 /// </returns>
 private static IMutableObjects GetMutables(IMutableStructureSearchManager mutableSearchManager, IRestStructureQuery mockQuery, IMaintainableMutableObject maintainableMutableObject)
 {
     var mutableObject = mutableSearchManager.GetMaintainables(mockQuery);
     Assert.IsNotNull(mutableObject, _fromMutable.Build(maintainableMutableObject).ToString());
     Assert.IsNotEmpty(mutableObject.AllMaintainables, _fromMutable.Build(maintainableMutableObject).ToString());
     return mutableObject;
 }
예제 #29
0
 /// <summary>
 /// Returns a tree structure representing the <paramref name="maintainableObject"/> and all the structures that cross reference it, and the structures that reference them, and so on.
 /// </summary>
 /// <param name="maintainableObject">
 /// The maintainable object to build the tree for.
 /// </param>
 /// <returns>
 /// The <see cref="IMutableCrossReferencingTree"/>.
 /// </returns>
 public IMutableCrossReferencingTree GetCrossReferenceTree(IMaintainableMutableObject maintainableObject)
 {
     return(this._authCrossReferenceManager.GetCrossReferenceTree(maintainableObject, null));
 }