Esempio n. 1
0
        public void TestGetUriAndRetrieveElement()
        {
            var dataLayerLogic = new DataLayerLogic(new DataLayerData());
            var dataLayers = new DataLayers();
            dataLayers.SetRelationsForDefaultDataLayers(dataLayerLogic);
            var strapper = Bootstrapper.PerformFullBootstrap(
                new Bootstrapper.FilePaths()
                {
                    PathPrimitive = "Xmi/PrimitiveTypes.xmi",
                    PathUml = "Xmi/UML.xmi",
                    PathMof = "Xmi/MOF.xmi"
                },
                dataLayerLogic,
                dataLayers.Uml);
            var umlExtent = strapper.UmlInfrastructure;
            var element = umlExtent.elements().ElementAt(0) as IElement;

            var elementUri = umlExtent.uri(element);
            var foundElement = umlExtent.element(elementUri);
            Assert.That(foundElement, Is.Not.Null);
            Assert.That(foundElement, Is.EqualTo(element));

            // Retrieve another element
            element = AllDescendentsQuery.getDescendents(umlExtent).ElementAt(300) as IElement;
            elementUri = umlExtent.uri(element);
            foundElement = umlExtent.element(elementUri);
            Assert.That(foundElement, Is.Not.Null);
            Assert.That(foundElement, Is.EqualTo(element));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a filled MOF and UML instance which can be used for further testing
        /// </summary>
        /// <param name="mof">Mof instance to be returned</param>
        /// <param name="uml">Uml instance to be returned</param>
        public static void CreateUmlAndMofInstance(out _MOF mof, out _UML uml)
        {
            var dataLayerLogic = new DataLayerLogic(new DataLayerData());
            var dataLayers = new DataLayers();
            dataLayers.SetRelationsForDefaultDataLayers(dataLayerLogic);
            var strapper = Bootstrapper.PerformFullBootstrap(
                new Bootstrapper.FilePaths()
                {
                    PathPrimitive = "Xmi/PrimitiveTypes.xmi",
                    PathUml = "Xmi/UML.xmi",
                    PathMof = "Xmi/MOF.xmi"
                },
                dataLayerLogic,
                dataLayers.Mof);
            Assert.That(strapper, Is.Not.Null);
            Assert.That(strapper.UmlInfrastructure, Is.Not.Null);

            Assert.That(
                AllDescendentsQuery.getDescendents(strapper.UmlInfrastructure).Count(),
                Is.GreaterThan(500));

            // Check, if the filled classes are working
            mof = dataLayerLogic.Get<_MOF>(dataLayers.Mof);
            uml = dataLayerLogic.Get<_UML>(dataLayers.Mof);
            Assert.That(mof, Is.Not.Null);
            Assert.That(uml, Is.Not.Null);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        public void TestClassTreeUsage()
        {
            var dataLayerLogic = new DataLayerLogic(new DataLayerData());
            var dataLayers = new DataLayers();
            dataLayers.SetRelationsForDefaultDataLayers(dataLayerLogic);

            var strapper = Bootstrapper.PerformFullBootstrap(
                new Bootstrapper.FilePaths()
                {
                    PathPrimitive = "Xmi/PrimitiveTypes.xmi",
                    PathUml = "Xmi/UML.xmi",
                    PathMof = "Xmi/MOF.xmi"
                },
                dataLayerLogic,
                dataLayers.Uml);

            var primitiveTypes = dataLayerLogic.Create<FillThePrimitiveTypes, _PrimitiveTypes>(dataLayers.Uml);
            Assert.That(primitiveTypes, Is.Not.Null );
            Assert.That(primitiveTypes.__Real, Is.Not.Null);
            Assert.That(primitiveTypes.__Real, Is.Not.TypeOf<object>());

            var primitiveTypes2 = dataLayerLogic.Create<FillThePrimitiveTypes, _PrimitiveTypes>(dataLayers.Uml);
            Assert.That(primitiveTypes2, Is.SameAs(primitiveTypes));
        }
Esempio n. 6
0
        private static _UML GetFilledUml()
        {
            var dataLayerLogic = new DataLayerLogic(new DataLayerData());
            var dataLayers = new DataLayers();
            dataLayers.SetRelationsForDefaultDataLayers(dataLayerLogic);
            var strapper = Bootstrapper.PerformFullBootstrap(
                new Bootstrapper.FilePaths()
                {
                    PathPrimitive = "Xmi/PrimitiveTypes.xmi",
                    PathUml = "Xmi/UML.xmi",
                    PathMof = "Xmi/MOF.xmi"
                },
                dataLayerLogic,
                dataLayers.Mof);

            return dataLayerLogic.Get<_UML>(dataLayers.Mof);
        }
Esempio n. 7
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;
        }
Esempio n. 8
0
 public DataLayerData(DataLayers dataLayers)
 {
     Default = dataLayers.Data;
 }