public void TestDataLayersForItem()
        {
            var dataLayers = new DataLayers();
            var data = new DataLayerData(dataLayers);
            IDataLayerLogic logic = new DataLayerLogic(data);
            dataLayers.SetRelationsForDefaultDataLayers(logic);

            var dataExtent = new MofUriExtent("Data");
            var umlExtent = new MofUriExtent("Uml");

            logic.AssignToDataLayer(dataExtent, dataLayers.Data);
            logic.AssignToDataLayer(umlExtent, dataLayers.Uml);

            var value = new MofElement(null, null);
            var logicLayer = logic.GetDataLayerOfObject(value);
            Assert.That(logicLayer, Is.SameAs(dataLayers.Data)); // Per Default, only the Data

            umlExtent.elements().add(value);
            logicLayer = logic.GetDataLayerOfObject(value);
            Assert.That(logicLayer, Is.SameAs(dataLayers.Uml));
        }
        public void TestDataLayers()
        {
            var dataLayers = new DataLayers();
            var data = new DataLayerData(dataLayers);
            IDataLayerLogic logic = new DataLayerLogic(data);
            dataLayers.SetRelationsForDefaultDataLayers(logic);

            var dataExtent = new MofUriExtent("Data");
            var typeExtent = new MofUriExtent("Types");
            var umlExtent = new MofUriExtent("Uml");
            var unAssignedExtent = new MofUriExtent("Unassigned");

            logic.AssignToDataLayer(dataExtent, dataLayers.Data);
            logic.AssignToDataLayer(typeExtent, dataLayers.Types);
            logic.AssignToDataLayer(umlExtent, dataLayers.Uml);

            Assert.That(logic.GetDataLayerOfExtent(dataExtent), Is.EqualTo(dataLayers.Data));
            Assert.That(logic.GetDataLayerOfExtent(typeExtent), Is.EqualTo(dataLayers.Types));
            Assert.That(logic.GetDataLayerOfExtent(umlExtent), Is.EqualTo(dataLayers.Uml));
            Assert.That(logic.GetDataLayerOfExtent(unAssignedExtent), Is.EqualTo(dataLayers.Data));
            Assert.That(logic.GetMetaLayerFor(dataLayers.Data), Is.EqualTo(dataLayers.Types));
        }
Beispiel #3
0
        public IContainer UseDatenMeister(ContainerBuilder kernel)
        {
            if (_settings == null)
            {
                Debug.WriteLine("No integration settings were given. Loading the default values.");
                _settings = new IntegrationSettings();
            }

            kernel.RegisterSource(new AnyConcreteTypeNotAlreadyRegisteredSource());

            var watch = new Stopwatch();
            watch.Start();

            // Defines the factory method for a certain extent type
            var factoryMapper = new DefaultFactoryMapper();
            kernel.RegisterInstance(factoryMapper).As<IFactoryMapper>();

            // Finds the loader for a certain extent type
            var storageMap = new ManualConfigurationToExtentStorageMapper();
            kernel.RegisterInstance(storageMap).As<IConfigurationToExtentStorageMapper>();

            // Workspace collection
            var workspaceCollection = new WorkspaceCollection();
            workspaceCollection.Init();
            kernel.RegisterInstance(workspaceCollection).As<IWorkspaceCollection>();

            // Defines the extent storage data
            var extentStorageData = new ExtentStorageData();
            kernel.RegisterInstance(extentStorageData).As<ExtentStorageData>();
            kernel.RegisterType<ExtentStorageLoader>().As<IExtentStorageLoader>();

            // Defines the datalayers
            var dataLayers = new DataLayers();
            kernel.RegisterInstance(dataLayers).As<DataLayers>();

            var dataLayerData = new DataLayerData(dataLayers);
            kernel.RegisterInstance(dataLayerData).As<DataLayerData>();
            kernel.RegisterType<DataLayerLogic>().As<IDataLayerLogic>();

            // Adds the name resolution
            kernel.RegisterType<UmlNameResolution>().As<IUmlNameResolution>();

            var builder = kernel.Build();
            using (var scope = builder.BeginLifetimeScope())
            {
                // Is used by .Net Provider to include the mappings for extent storages and factory types
                _settings?.Hooks?.OnStartScope(scope);

                var dataLayerLogic = scope.Resolve<IDataLayerLogic>();
                dataLayers.SetRelationsForDefaultDataLayers(dataLayerLogic);

                // Load the default extents

                // Performs the bootstrap
                var paths =
                    new Bootstrapper.FilePaths()
                    {
                        PathPrimitive = Path.Combine(_settings.PathToXmiFiles, "PrimitiveTypes.xmi"),
                        PathUml = Path.Combine(_settings.PathToXmiFiles, "UML.xmi"),
                        PathMof = Path.Combine(_settings.PathToXmiFiles, "MOF.xmi")
                    };

                if (_settings.PerformSlimIntegration)
                {
                    throw new InvalidOperationException("Slim integration is currently not supported");
                }
                else
                {
                    Bootstrapper.PerformFullBootstrap(
                        paths,
                        workspaceCollection.GetWorkspace("UML"),
                        dataLayerLogic,
                        dataLayers.Uml);
                    Bootstrapper.PerformFullBootstrap(
                        paths,
                        workspaceCollection.GetWorkspace("MOF"),
                        dataLayerLogic,
                        dataLayers.Mof);
                }

                // Creates the workspace and extent for the types layer which are belonging to the types
                var extentTypes = new MofUriExtent("dm:///types");
                var typeWorkspace = workspaceCollection.GetWorkspace("Types");
                typeWorkspace.AddExtent(extentTypes);
                dataLayerLogic.AssignToDataLayer(extentTypes, dataLayers.Types);

                // Boots up the typical DatenMeister Environment
                if (_settings.EstablishDataEnvironment)
                {
                    EstablishDataEnvironment(builder, scope);
                }
            }

            watch.Stop();
            Debug.WriteLine($"Elapsed time for bootstrap: {watch.Elapsed}");

            return builder;
        }