/// <summary>
        ///     Initialize the instance.
        /// </summary>
        private void Init()
        {
            if (this._retrieveCrossRefefences)
            {
                ICrossReferenceResolverEngine crossRefResolver = new CrossReferenceResolverEngineCore();
                this._crossReferencedObjects = crossRefResolver.ResolveReferences(
                    this._sdmxObjects, this._retrieveAgencies, this._resolutionDepth, this._retrievalManager);
            }

            this._allSdmxObjects = new SdmxObjectsImpl(this._sdmxObjects);
            if (this._crossReferencedObjects != null)
            {
                /* foreach */
                foreach (ISet<IIdentifiableObject> currentBeanSet in this._crossReferencedObjects.Values)
                {
                    /* foreach */
                    foreach (IIdentifiableObject currentBean in currentBeanSet)
                    {
                        this._allSdmxObjects.AddIdentifiable(currentBean);
                    }
                }
            }
        }
 /// <summary>
 /// </summary>
 /// <param name="structures"> The structures</param>
 /// <param name="resolveAgencies"> Flag indicating resolve agencies .</param>
 /// <param name="resolutionDepth"> The resolution depth. </param>
 /// <param name="retrievalManager"> The retrieval manager </param>
 /// <returns> The references </returns>
 public IDictionary<IIdentifiableObject, ISet<IIdentifiableObject>> ResolveReferences(
     ISdmxObjects structures,
     bool resolveAgencies,
     int resolutionDepth,
     IIdentifiableRetrievalManager retrievalManager)
 {
     ICrossReferenceResolverEngine crossReferenceResolver = new CrossReferenceResolverEngineCore();
     return crossReferenceResolver.ResolveReferences(
         structures, resolveAgencies, resolutionDepth, retrievalManager);
 }
 public void TestGetMissingAgencies()
 {
     ICodelistObject immutableInstance = CreateSampleCodelist();
     ICrossReferenceResolverEngine crossReferenceResolverEngine = new CrossReferenceResolverEngineCore();
     IDictionary<string, ISet<IMaintainableObject>> missingAgencies = crossReferenceResolverEngine.GetMissingAgencies(new SdmxObjectsImpl(immutableInstance), beanRetrivalManager.Object);
     Assert.IsNotEmpty(missingAgencies);
 }
 public void TestGetMissingCrossReferences()
 {
     ICrossReferenceResolverEngine crossReferenceResolverEngine = new CrossReferenceResolverEngineCore();
     InMemoryRetrievalManager retrievalManager = new InMemoryRetrievalManager();
     ISdmxObjects objects = new SdmxObjectsImpl(dataStructureObject);
     IDictionary<IIdentifiableObject, ISet<ICrossReference>> missingCrossRef = crossReferenceResolverEngine.GetMissingCrossReferences(objects, 10, retrievalManager);
     Assert.IsNotEmpty(missingCrossRef);
     Assert.AreEqual(dataStructureObject.DimensionList.Dimensions[0].Urn, missingCrossRef.First().Key.Urn);
     Assert.IsTrue(missingCrossRef.Any(pair => pair.Key.Urn.Equals(this.dataStructureObject.PrimaryMeasure.Urn)));
     Assert.IsTrue(missingCrossRef.Any(pair => pair.Key.Urn.Equals(this.dataStructureObject.TimeDimension.Urn)));
 }
        public void TestResolveCrossReference(string file)
        {

            ICrossReferenceResolverEngine crossReferenceResolverEngine = new CrossReferenceResolverEngineCore();
            ISdmxObjects structureBeans;
            using (IReadableDataLocation fileReadableDataLocation = new FileReadableDataLocation(file))
            {
                IStructureWorkspace structureWorkspace = this.parsingManager.ParseStructures(fileReadableDataLocation);
                Assert.NotNull(structureWorkspace);
                structureBeans = structureWorkspace.GetStructureObjects(false);
            }

            var retrievalManager = new InMemoryRetrievalManager(structureBeans);
            ICodelistObject immutableInstance = CreateSampleCodelist();
            var cross = new CrossReferenceImpl(immutableInstance, "urn:sdmx:org.sdmx.infomodel.datastructure.DataStructure=TFFS:CRED_EXT_DEBT(1.0)");

            int i = 0;

            foreach (IMaintainableObject maintainableObject in this.maintainableObjectSet)
            {
                beanRetrivalManager.Setup(m => m.GetMaintainableObject(It.IsAny<IStructureReference>(), false, false)).Returns(maintainableObject);
                beanRetrivalManager.Setup(m => m.GetIdentifiableObject(It.IsAny<ICrossReference>())).Returns(maintainableObject);
                IIdentifiableObject ret = crossReferenceResolverEngine.ResolveCrossReference(cross, beanRetrivalManager.Object);
                Assert.IsNotNull(ret);
                Assert.AreEqual(maintainableObject.Urn, ret.Urn);
                i++;
            } 
        }
        public void TestResolveReference(string file)
        {
            ICrossReferenceResolverEngine crossReferenceResolverEngine = new CrossReferenceResolverEngineCore();
            ISdmxObjects structureBeans;
            using (IReadableDataLocation fileReadableDataLocation = new FileReadableDataLocation(file))
            {
                IStructureWorkspace structureWorkspace = this.parsingManager.ParseStructures(fileReadableDataLocation);
                Assert.NotNull(structureWorkspace);
                structureBeans = structureWorkspace.GetStructureObjects(false);
            }

            var retrievalManager = new InMemoryRetrievalManager(structureBeans);
            foreach (var maintainableObject in structureBeans.DataStructures)
            {
                ISet<IIdentifiableObject> identifiableObjects = crossReferenceResolverEngine.ResolveReferences(maintainableObject, false, 10, retrievalManager);
                Assert.IsNotEmpty(identifiableObjects);
            }
        }