Exemple #1
0
        private void TbSaveSchemaClick(object sender, EventArgs e)
        {
            var serviceParameters = new ServiceParameters(OrganizationService, MetadataService, NotificationService, ExceptionService);
            var controller        = new SchemaController();

            controller.SaveSchema(serviceParameters, checkedEntity, entityRelationships, entityAttributes, attributeMapping, crmSchemaConfiguration, tbSchemaPath);
        }
 public SchemaDiagrammerController(MainWindow window, EditModel editModelScreen)
 {
     this.window = window;
     controller = new SchemaController(window.Controller);
     controller.EditModel = editModelScreen;
     window.LayoutFinished += window_LayoutFinished;
 }
        public void SchemaSource_httpPost_when_model_schemadefinitionfromurl_is_null_returns_redirect_to_action_Create()
        {
            //arrange
            var nameValueCollection = new NameValueCollection()
            {
            };

            nameValueCollection.Add("useUrl", "yes");
            var mockRequestBase = new Mock <HttpRequestBase>();

            //mockRequestBase.Setup(x => x.Params).Returns(nameValueCollection);
            mockRequestBase.SetReturnsDefault(nameValueCollection);
            _mockHttpContextBase.SetupGet(x => x.Request).Returns(mockRequestBase.Object);


            var controller = new SchemaController(_esdFunctionService, _dataShareSchemaImportService, _datasetSchemaService,
                                                  _dataSetSchemaColumnService, _categoryService, _systemConfigurationService);

            controller.ControllerContext = new ControllerContext(_mockHttpContextBase.Object, new RouteData(), controller);
            var model = new SchemaSourceViewModel()
            {
                SchemaDefinitionFromUrl = null
            };
            //act
            var result = (RedirectToRouteResult)controller.SchemaSource(model, "categoryname");

            //assert
            Assert.AreEqual("Create", result.RouteValues["action"]);
            //cleanup
        }
Exemple #4
0
 public SchemaDiagrammerController(MainWindow window, EditModel editModelScreen)
 {
     this.window            = window;
     controller             = new SchemaController(window.Controller);
     controller.EditModel   = editModelScreen;
     window.LayoutFinished += window_LayoutFinished;
 }
        public void TestAddUriStructureOkController()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            UriStructure            newUriStructure        = CreateUriStructureExample("newUriExample");
            ResourcesClass          newResourcesClass      = CreateResourceClassExample("newUriExample", "rsp", "pipaon");
            List <ResourcesClass>   lista = new List <ResourcesClass>();

            lista.Add(newResourcesClass);
            InfoUriStructure structure = new InfoUriStructure();

            structure.ResourcesClass = lista;
            structure.UriStructure   = newUriStructure;
            var result = schemaController.AddUriStructure(structure);

            if (result is BadRequestObjectResult)
            {
                Assert.True(false);
            }
            else
            {
                Assert.True(true);
            }
        }
Exemple #6
0
        public TypeMappingTests()
        {
            IConfigurationRoot configuration = new ConfigurationBuilder().AddYamlFile("config.yaml", optional: false).Build();

            Global.ConnectionString = configuration["Cms:SqlConnection"];
            controller       = new GraphController(Global.ConnectionString);
            schemaController = new SchemaController(new MsSqlGraphSchemaService());
        }
Exemple #7
0
        public SchemaControllerTests()
        {
            var schemaInformation = new SchemaInformation();
            var urlResolver       = Substitute.For <IUrlResolver>();

            urlResolver.ResolveRouteNameUrl(RouteNames.Script, Arg.Any <IDictionary <string, object> >()).Returns(new Uri("https://localhost/script"));
            _schemaController = new SchemaController(schemaInformation, urlResolver, NullLogger <SchemaController> .Instance);
        }
        public void Setup()
        {
            SetupServiceMocks();
            inputEntityRelationships = new Dictionary <string, HashSet <string> >();
            inputEntityAttributes    = new Dictionary <string, HashSet <string> >();
            inputWorkingstate        = true;
            inputCheckedEntity       = new HashSet <string>();

            systemUnderTest = new SchemaController();
        }
Exemple #9
0
        public void Node_Can_Deserialize_And_Create_SqlSchema()
        {
            var yaml = @"Version: 15.0.0.0
Name: person
Attributes:
- Name: FirstName
  Type: Text
- Name: LastName
  Type: Text
- Name: DateOfBirth
  Type: DateTime
Edges:
- Name: likes
  Constraints:
  - Name: person
  Attributes:
  - Name: rating
    Type: int
- Name: married
  Constraints:
  - Name: person
  Attributes: []
- Name: friend
  Constraints:
  - Name: person
  Attributes: []
";
            SchemaController controller = new SchemaController(new MsSqlGraphSchemaService());
            var r   = controller.Deserialize(yaml);
            var sql = controller.Service.CreateScript(r);

            Assert.True(sql == @"CREATE TABLE node.person (
ID INTEGER PRIMARY KEY,
FirstName  NTEXT,LastName  NTEXT,
) AS NODE;
CREATE TABLE edge.likes (
rating INTEGER,CONSTRAINT EC_LIKES CONNECTION (
node.person TO node.person
)
) AS EDGE;

CREATE TABLE edge.married (
CONSTRAINT EC_MARRIED CONNECTION (
node.person TO node.person
)
) AS EDGE;

CREATE TABLE edge.friend (
CONSTRAINT EC_FRIEND CONNECTION (
node.person TO node.person
)
) AS EDGE;

");
        }
Exemple #10
0
        protected DatabaseViewFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, IDatabase database)
        {
            this.diagramController = diagramController;
            this.schemaController  = schemaController;
            this.database          = database;

            if (database == null)
            {
                throw new Exception("Database is null for this table.");
            }
        }
        protected DatabaseViewFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, IDatabase database)
        {
            this.diagramController = diagramController;
            this.schemaController = schemaController;
            this.database = database;

            if (database == null)
            {
                throw new Exception("Database is null for this table.");
            }
        }
        public void SchemaSource_returns_defaultview()
        {
            //arrange
            var controller = new SchemaController(_esdFunctionService, _dataShareSchemaImportService, _datasetSchemaService,
                                                  _dataSetSchemaColumnService, _categoryService, _systemConfigurationService);
            //act
            var result = (ViewResult)controller.SchemaSource("categoryname");

            //assert
            Assert.AreEqual("", result.ViewName);
            //cleanup
        }
        public void Index_when_category_name_is_not_null_returns_schema_view()
        {
            //arrange
            var controller = new SchemaController(_esdFunctionService, _dataShareSchemaImportService, _datasetSchemaService,
                                                  _dataSetSchemaColumnService, _categoryService, _systemConfigurationService);
            //act
            var result = (ViewResult)controller.Index("categoryname");

            //assert
            Assert.AreEqual("Schema", result.ViewName);
            //cleanup
        }
Exemple #14
0
        public void GetDefinition()
        {
            var obj = new SchemaDefinition {
                Name = "sch1"
            };

            _ops.Setup(c => c.Definition("conn", _loggingService))
            .Returns(obj);

            var controller = new SchemaController(_ops.Object, _loggingService);

            var results = controller.Get("conn");

            Assert.AreEqual("sch1", obj.Name);
        }
        public SchemaControllerTests()
        {
            _schemaInformation = new SchemaInformation((int)TestSchemaVersion.Version1, (int)TestSchemaVersion.Version3);
            _mediator          = Substitute.For <IMediator>();

            var urlHelperFactory = Substitute.For <IUrlHelperFactory>();
            var urlHelper        = Substitute.For <IUrlHelper>();

            urlHelper.RouteUrl(Arg.Any <UrlRouteContext>()).Returns("https://localhost/script");
            urlHelperFactory.GetUrlHelper(Arg.Any <ActionContext>()).Returns(urlHelper);

            var scriptProvider = Substitute.For <IScriptProvider>();

            _schemaController = new SchemaController(_schemaInformation, scriptProvider, urlHelperFactory, _mediator, NullLogger <SchemaController> .Instance);
        }
 public void TestGetSchemaController()
 {
     try
     {
         ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
         ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
         SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
         var result = schemaController.GetSchema();
         Assert.True(true);
     }
     catch (Exception)
     {
         Assert.True(false);
     }
 }
Exemple #17
0
        public void CanReadSchemaPackage()
        {
            var schemaPackage           = @"SchemaSequence:
Schemas:
- Name: openId
- Name: persoon
- Name: bestand
";
            SchemaController controller = new SchemaController(new MsSqlGraphSchemaService());
            var package = controller.SchemaSequence(schemaPackage);

            Assert.NotNull(package.Schemas);
            Assert.True(package.Schemas.Count == 3);
            Assert.True(package.Schemas[0].Name != string.Empty);
        }
Exemple #18
0
        private void ButtonSchemaFolderPathClick(object sender, EventArgs e)
        {
            using (var fileDialog = new SaveFileDialog
            {
                Filter = "XML Files|*.xml",
                OverwritePrompt = false
            })
            {
                var dialogResult         = fileDialog.ShowDialog();
                var controller           = new SchemaController();
                var collectionParameters = new CollectionParameters(entityAttributes, entityRelationships, null, null, null, null);

                controller.SchemaFolderPathAction(NotificationService, tbSchemaPath, workingstate, collectionParameters /*entityAttributes, entityRelationships*/, dialogResult, fileDialog, LoadSchemaFile);
            }
        }
        public void TestGetUriController()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            var result = schemaController.GetUriStructureInfo("uriResourceStructure");

            if (result is BadRequestObjectResult)
            {
                Assert.True(false);
            }
            else
            {
                Assert.True(true);
            }
        }
        private void InitButtons()
        {
            controller = new SchemaController();

            for (int l = 0; l < GRID_LENGTH; l++)
            {
                for (int c = 0; c < GRID_LENGTH; c++)
                {
                    var forme = controller.CreateFormeRonde(c, l).Get();
                    Grid.SetRow(forme, l);
                    Grid.SetColumn(forme, c);
                    SchemaGrid.Children.Add(forme);
                }
            }
            controller.CreateSchemaToFind();
        }
Exemple #21
0
        /*
         * {
         * "@context": "https://json-ld.org/contexts/person.jsonld",
         * "@id": "http://dbpedia.org/resource/John_Lennon",
         * "name": "John Lennon",
         * "born": "1940-10-09",
         * "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
         * }
         */
        public void CreateJsonLdFromSchema()
        {
            var schemaController = new SchemaController(null);
            var nameSpace        = "Vs.GraphData";
            var schema           = schemaController.Deserialize(@"Name: codeTest
Attributes:
- Name: term
  Type: text
- Name: omschrijving
  Type: text
- Name: versie
  Type: int
- Name: periode
  Type: periode
");
            //var code = schemaController.CreateJsonLd<INode>(schema, nameSpace);
        }
Exemple #22
0
        public void Node_Create_Person()
        {
            NodeSchema n = new NodeSchema(name: "person");

            n.Attributes.Add(new Attribute(name: "FirstName", type: new AttributeText()));
            n.Attributes.Add(new Attribute(name: "LastName", type: new AttributeText()));
            n.Attributes.Add(new Attribute(name: "DateOfBirth", new AttributeDatum()));
            n.Edges.Add(new EdgeSchema(name: "likes"));
            n.Edges.Add(new EdgeSchema(name: "married"));
            n.Edges.Add(new EdgeSchema(name: "friend"));

            n.Edges[0].Constraints.Add(new Constraint(name: "person"));
            n.Edges[1].Constraints.Add(new Constraint(name: "person"));
            n.Edges[2].Constraints.Add(new Constraint(name: "person"));

            n.Edges[0].Attributes.Add(new Attribute(name: "rating", type: new AttributeEuro()));

            SchemaController controller = new SchemaController(new MsSqlGraphSchemaService());
            var yaml = controller.Serialize(n);
            var r    = controller.Deserialize(yaml);
            var sql  = controller.Service.CreateScript(r);

            Assert.True(sql == @"CREATE TABLE node.person (
ID INTEGER PRIMARY KEY,
FirstName  NTEXT,LastName  NTEXT,DateOfBirth DATETIME,
) AS NODE;
CREATE TABLE edge.likes (
rating DECIMAL,CONSTRAINT EC_LIKES CONNECTION (
node.person TO node.person
)
) AS EDGE;

CREATE TABLE edge.married (
CONSTRAINT EC_MARRIED CONNECTION (
node.person TO node.person
)
) AS EDGE;

CREATE TABLE edge.friend (
CONSTRAINT EC_FRIEND CONNECTION (
node.person TO node.person
)
) AS EDGE;

");
        }
Exemple #23
0
        private void SaveAllToolStripMenuItemClick(object sender, EventArgs e)
        {
            var controller = new ConfigurationController();

            controller.GenerateImportConfigFile(NotificationService, tbImportConfig, mapper);
            controller.GenerateExportConfigFile(tbExportConfig, tbSchemaPath, filterQuery, lookupMaping, NotificationService);

            var serviceParameters = new ServiceParameters(OrganizationService, MetadataService, NotificationService, ExceptionService);
            var entityController  = new EntityController();

            entityController.CollectCrmEntityFields(checkedEntity, crmSchemaConfiguration, entityRelationships, entityAttributes, attributeMapping, serviceParameters);

            var schemaController = new SchemaController();

            schemaController.GenerateXMLFile(tbSchemaPath, crmSchemaConfiguration);
            crmSchemaConfiguration.Entities.Clear();
        }
        public void Should_be_possible_raising_a_schema_event_on_a_view()
        {
            MockRepository mocks = new MockRepository();

            var fakeView = mocks.DynamicMock<ISchemaView>();

            mocks.ReplayAll();

            var controller = new SchemaController(fakeView);

            var e = new SchemaEventArgs();
            fakeView.Raise(x => x.OnValidateSchema += null, this, e);

            mocks.VerifyAll();

            Assert.IsTrue(controller.OnValidadeSchemaCalled);
            Assert.IsFalse(e.Result);
            Assert.AreEqual(Modulo.Collect.GraphicalConsole.Resource.EmptyDefinitionFilename, e.ShortErrorMessage);
            Assert.IsNull(e.LongErrorMessage);
        }
Exemple #25
0
        public void Should_be_possible_raising_a_schema_event_on_a_view()
        {
            MockRepository mocks = new MockRepository();

            var fakeView = mocks.DynamicMock <ISchemaView>();

            mocks.ReplayAll();

            var controller = new SchemaController(fakeView);

            var e = new SchemaEventArgs();

            fakeView.Raise(x => x.OnValidateSchema += null, this, e);

            mocks.VerifyAll();

            Assert.IsTrue(controller.OnValidadeSchemaCalled);
            Assert.IsFalse(e.Result);
            Assert.AreEqual(Modulo.Collect.GraphicalConsole.Resource.EmptyDefinitionFilename, e.ShortErrorMessage);
            Assert.IsNull(e.LongErrorMessage);
        }
Exemple #26
0
        public void CreateCompilableCodeFromSchema()
        {
            var schemaController = new SchemaController(null);
            var nameSpace        = "Vs.GraphData";
            var schema           = schemaController.Deserialize(@"Name: codeTest
Attributes:
- Name: id
  Type: int
- Name: term
  Type: text
- Name: omschrijving
  Type: text
- Name: versie
  Type: int
- Name: periode
  Type: periode
");
            var code             = schemaController.CreateCode <INode>(schema, nameSpace);
            var assembly         = schemaController.Compile(code);

            Assert.NotNull(assembly);
        }
        public void TestBadFormedJson()
        {
            ConfigJsonHandler       configJsonHandler      = new ConfigJsonHandler();
            ISchemaConfigOperations schemaConfigOperations = new SchemaConfigMemoryOperations(configJsonHandler);
            SchemaController        schemaController       = new SchemaController(configJsonHandler, schemaConfigOperations);
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);

            writer.Write(jsonConfigBad);
            writer.Flush();
            stream.Position = 0;
            var file   = new FormFile(stream, 0, stream.Length, null, "config.json");
            var result = schemaController.ReplaceSchemaConfig(file);

            if (result is BadRequestObjectResult)
            {
                Assert.True(true);
            }
            else
            {
                Assert.True(false);
            }
        }
        public void SchemaSource_httpPost_when_request_use_url_not_yes_returns_redirect_to_action_Create()
        {
            //arrange
            var nameValueCollection = new NameValueCollection();

            nameValueCollection.Add("useUrl", "notyest");
            _mockRequestBase.Setup(x => x.Params).Returns(nameValueCollection);
            _mockHttpContextBase.SetupGet(x => x.Request).Returns(_mockRequestBase.Object);
            _mockHttpContextBase.SetupGet(x => x.Response).Returns(_mockResponseBase.Object);


            var controller = new SchemaController(_esdFunctionService, _dataShareSchemaImportService, _datasetSchemaService,
                                                  _dataSetSchemaColumnService, _categoryService, _systemConfigurationService);

            controller.ControllerContext = new ControllerContext(_mockHttpContextBase.Object, new RouteData(), controller);
            var model = new SchemaSourceViewModel();
            //act
            var result = (RedirectToRouteResult)controller.SchemaSource(model, "categoryname");

            //assert
            Assert.AreEqual("Create", result.RouteValues["action"]);
            //cleanup
        }
Exemple #29
0
 public ReferenceFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, Reference reference)
     : base(diagramController, schemaController, reference.EntitySet.MappingSet)
 {
     this.reference = reference;
 }
Exemple #30
0
 public SchemaControllerTests()
 {
     _schemaController = new SchemaController(NullLogger <SchemaController> .Instance);
 }
 public MappingSetShowAllFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, MappingSet mappingSet)
     : base(diagramController, schemaController, mappingSet)
 {
 }
 public DatabaseShowAllFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, IDatabase database)
     : base(diagramController, schemaController, database)
 {
 }
 protected MappingSetViewFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, MappingSet mappingSet)
 {
     this.diagramController = diagramController;
     this.schemaController = schemaController;
     this.mappingSet = mappingSet;
 }
 public RelatedEntityObjectsFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, ITable table, int degreeOfRelationshipsToShow) : base(diagramController, schemaController, table.Database)
 {
     DegreeOfRelationshipsToShow = degreeOfRelationshipsToShow;
     Table = table;
 }
 public EntitySetShowAllFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, EntitySet entitySet)
     : base(diagramController, schemaController, entitySet.MappingSet)
 {
     this.entitySet = entitySet;
 }
 public EntitySetShowAllFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, EntitySet entitySet)
     : base(diagramController, schemaController, entitySet.MappingSet)
 {
     this.entitySet = entitySet;
 }
Exemple #37
0
        public void CreateEntityFromYamlWithCustomType()
        {
            // create some entities through built-in data provider
            var yaml = @"Version: 15.0.0.0
Name: persoon
Attributes:
- Name: BSN
  Type: elfproef
- Name: periode
  Type: periode
Edges:
- Name: partner
  Constraints:
  - Name: persoon
  Attributes:
  - Name: periode
    Type: periode
- Name: kind
  Constraints:
  - Name: persoon
- Name: ouder
  Constraints:
  - Name: persoon
";

            SchemaController controller = new SchemaController(new MsSqlGraphSchemaService());
            var r = controller.Deserialize(yaml);
            var s = controller.Service.CreateScript(r);

            Assert.True(s == @"CREATE TABLE node.persoon (
ID INTEGER PRIMARY KEY,
BSN VARCHAR(10),periode_begin DATETIME,periode_eind  DATETIME,
) AS NODE;
CREATE TABLE edge.partner (
periode_begin DATETIME,periode_eind  DATETIME,CONSTRAINT EC_PARTNER CONNECTION (
node.persoon TO node.persoon
)
) AS EDGE;

CREATE TABLE edge.kind (
CONSTRAINT EC_KIND CONNECTION (
node.persoon TO node.persoon
)
) AS EDGE;

CREATE TABLE edge.ouder (
CONSTRAINT EC_OUDER CONNECTION (
node.persoon TO node.persoon
)
) AS EDGE;

");

            /*
             *
             * string connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=graph;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";
             *
             * using (SqlConnection connection = new SqlConnection(connectionString))
             * {
             *  SqlCommand command = new SqlCommand(s, connection);
             *  //command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value");
             *  connection.Open();
             *  SqlDataReader reader = command.ExecuteReader();
             *  try
             *  {
             *      while (reader.Read())
             *      {
             *      }
             *  }
             *  finally
             *  {
             *      // Always call Close when done reading.
             *      reader.Close();
             *  }
             * }
             */
        }
 public RelatedEntitiesFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, Entity entity)
     : base(diagramController, schemaController, entity.EntitySet.MappingSet)
 {
     this.entity = entity;
 }
 public RelatedEntityObjectsFilter(SchemaDiagrammerController diagramController, SchemaController schemaController, ITable table, int degreeOfRelationshipsToShow)
     : base(diagramController, schemaController, table.Database)
 {
     DegreeOfRelationshipsToShow = degreeOfRelationshipsToShow;
     Table = table;
 }