Ejemplo n.º 1
0
        public void ApiGetQueriesTests()
        {
            var singleQuery = SingleQuery.CreateQuery
                              .RootCollection(QueryRootType.Variable, x => x.Name = "T")
                              .SetPivot(PivotType.Transaction, "job")
                              .AddCriteria(CriteriaAppendType.And, "Id", CriteriaComparator.Eq, "42")
                              // TODO: review and fix it according to TS logic

                              /* no more EE collection. Now TS objects
                               *              .AddCollection("ee")
                               *              .SetPivot(PivotType.Task, "pickup")
                               *              .AddCriteria(CriteriaAppendType.And, "Id", CriteriaComparator.Eq, "42")
                               */
                              .AddCollection("md").SetPivot(PivotType.MasterData, "company", "owner")
                              .AddCriteria(CriteriaAppendType.And, "Id", CriteriaComparator.Eq, "42")
                              .AddProperty("vx")
                              .SetPivot(PivotType.Value, "something")
            ;

            var builder = new QueryLanguageBuilder();

            var query = builder.RenderQuery(singleQuery);

            Console.WriteLine(query);
        }
Ejemplo n.º 2
0
        public void ApiSetQueriesTests()
        {
            var singleQuery = SingleQuery.CreateQuery
                              .RootProperty(QuerySource.API)
                              .SetPivot(PivotType.Transaction, "job")
                              // TODO: review and fix it according to TS logic

                              /* no more EE collection. Now TS objects
                               *              .AddCollection("ee")
                               *              .SetPivot(PivotType.Task, "pickup")
                               *              .MethodAdd()
                               *              .AddArgument(x => x.ArgumentSubjectQuery = SingleQuery.CreateQuery.AddProperty("capacity"), x => x.ArgumentValueConstant = "111")
                               *              .AddArgument(x => x.ArgumentSubjectQuery = SingleQuery.CreateQuery.AddProperty("vx").SetPivot(PivotType.Value, "text"), x => x.ArgumentValueConstant = 123)
                               */
                              //.AddArgument(
                              //    x => x.ArgumentValueQuery = SingleQuery.CreateQuery
                              //            .AddCollection("ae")
                              //            .SetPivot(PivotType.Attributes, "aeCode", "PropertyCode")
                              //            .MethodSet()
                              //            .AddArgument(
                              //                    x1 => x1.ArgumentSubjectQuery = SingleQuery.CreateQuery.AddProperty("vx").SetPivot(PivotType.Value, "text"),
                              //                    x1 => x1.ArgumentValueConstant = 123
                              //                    )
                              //            )
            ;

            var builder = new QueryLanguageBuilder();

            var query = builder.RenderQuery(singleQuery);

            Console.WriteLine(query);
        }
Ejemplo n.º 3
0
        public void GenerateIdsTest()
        {
            var query       = @"$x.ae.notes()._add(id = 064ADE4C-3BE6-4377-87CC-9B30329C1B6B)";
            var engine      = new Engine();
            var qlBuilder   = new QueryLanguageBuilder();
            var singleQuery = engine.Parse(query);

            singleQuery.GenerateIds();

            var text = qlBuilder.RenderQuery(singleQuery);

            Console.WriteLine(text);
        }
Ejemplo n.º 4
0
        public void ConvertIdToMasterIdTest()
        {
            var query       = @"$x.job(id = 00000000-0000-0000-0000-000000000000).ae.notes(id = 11111111-1111-1111-1111-111111111111)._Get()";
            var engine      = new Engine();
            var qlBuilder   = new QueryLanguageBuilder();
            var singleQuery = engine.Parse(query);

            singleQuery.ConvertIdToMasterId();

            var text = qlBuilder.RenderQuery(singleQuery);

            Console.WriteLine(text);
        }
Ejemplo n.º 5
0
        public void QueryBuilderTest()
        {
            var engine  = new Engine();
            var builder = new QueryLanguageBuilder();

//            var originalQuery = "job.ae.notes(vx.color = 'red')";
//            var originalQuery = "job.ae.notes((vx.name = 'xxx' && (vx.age = 11 || cc=33)) || vx.color = 'red')";
            var originalQuery = "job(vx.color = 'red' && ae.notes(vx.name = 'xxx'))";
            var singleQuery   = engine.Parse(originalQuery);

            var query = builder.RenderQuery(singleQuery);

            Console.WriteLine(query);
        }
Ejemplo n.º 6
0
        public void ModificationInfoTest()
        {
            var query       = @"$x.job.ae.notes(id = 11111111-1111-1111-1111-111111111111)._Add(vx.name = 'Lukas')";
            var engine      = new Engine();
            var qlBuilder   = new QueryLanguageBuilder();
            var singleQuery = engine.Parse(query);

            singleQuery.GenerateIds();

            var newQueries = singleQuery.GetModificationInfoQueries(JObject.Parse("{'xxx': 'zzz'}"), false);

            var text = qlBuilder.RenderQuery(singleQuery);

            Console.WriteLine(text);
        }
Ejemplo n.º 7
0
        public void BasicTest()
        {
            var query       = @"$x().bp.ac.delivery()._Add()";
            var engine      = new Engine();
            var qlBuilder   = new QueryLanguageBuilder();
            var singleQuery = engine.Parse(query);

            singleQuery.PivotsToCriterias(true);

            singleQuery.NodesList.First.Next.Value.PivotData.GetPivotValues();

            var text = qlBuilder.RenderQuery(singleQuery);

            Console.WriteLine(text);
        }
Ejemplo n.º 8
0
        public void QueryAndSubquery()
        {
            var firstQuery = SingleQuery.CreateQuery
                             .RootCollection(QueryRootType.Model, node => node.Name = "job");
            //.AddCollection("ae")


            var secondQuery = SingleQuery.CreateQuery
                              .RootCollection(QueryRootType.Model, node => node.Name = "job2")
                              .AddCollection("ae")
                              .SetPivot(PivotType.Attributes, "yourMomsFriends");

            firstQuery.AddMethod(QueryMethodType.Add, x => x.ArgumentValueQuery = secondQuery).SetPivot(PivotType.Attributes, "yourMomsFriends");

            var builder = new QueryLanguageBuilder();
            var query   = builder.RenderQuery(firstQuery);
        }