Esempio n. 1
0
        public static GremlinScript In(this GremlinScript query, params string[] relationshipName)
        {
            if (relationshipName.Count() == 1)
            {
                return(query.Append(".in({0})", relationshipName[0]));
            }

            // Can not send more then one element via parameters
            var relationships = relationshipName.Aggregate(new StringBuilder(), (sb, item) => sb.AppendFormat("{1}'{0}'", item, sb.Length == 0 ? string.Empty : ","));

            return(query.Append(string.Format(".in({0})", relationships)));
        }
Esempio n. 2
0
        public void FilterClause()
        {
            GremlinScript script = new GremlinScript();
            script.Append("g.v(0)")
                .Filter(it => it.GetProperty("MyProp") == "SomeValue");

            Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp') == 'SomeValue'}");
        }
Esempio n. 3
0
        public void FilterClauseCompareToIgnoreCase2()
        {
            GremlinScript script = new GremlinScript();
            script.Append("g.v(0)")
                .Filter(it => it.GetProperty("MyProp").CompareToIgnoreCase(it.GetProperty("CompareProperty").Name()));

            Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp').compareToIgnoreCase(it.getProperty('CompareProperty').name)}");
        }
Esempio n. 4
0
        public void FilterClauseChainCommands()
        {
            GremlinScript script = new GremlinScript();
            script.Append("g.v(0)")
                .Filter(it => it.GetProperty("MyProp").ToLowerCase().Contains("ContainThis"));

            Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp').toLowerCase().contains('ContainThis')}");
        }
Esempio n. 5
0
        public static GremlinScript RelationshipIndexLookup(this GremlinScript query, IEnumerable <KeyValuePair <string, string> > propertyKeyValue)
        {
            var sb = new StringBuilder();

            foreach (var kvp in propertyKeyValue)
            {
                sb.AppendFormat("{0}'{1}':'{2}'", sb.Length > 0 ? "," : "", kvp.Key, kvp.Value);
            }

            return(query.Append("g.E[[{0}]]", sb.ToString()));
        }
Esempio n. 6
0
        public static GremlinScript NodeIndexLookup(this GremlinScript query, IEnumerable <KeyValuePair <string, object> > propertyKeyValue)
        {
            var sb = new StringBuilder();

            foreach (var kvp in propertyKeyValue)
            {
                if (kvp.Value is string)
                {
                    sb.AppendFormat("{0}'{1}':'{2}'", sb.Length > 0 ? "," : "", kvp.Key, kvp.Value);
                }
                else if (kvp.Value is bool)
                {
                    sb.AppendFormat("{0}'{1}':{2}", sb.Length > 0 ? "," : "", kvp.Key, (bool)kvp.Value ? "true" : "false");
                }
                else
                {
                    sb.AppendFormat("{0}'{1}':{2}", sb.Length > 0 ? "," : "", kvp.Key, kvp.Value);
                }
            }

            return(query.Append("g.V[[{0}]]", sb.ToString()));
        }
Esempio n. 7
0
 public static GremlinScript Retain(this GremlinScript query, string variable)
 {
     return(query.Append(".retain({0})", variable));
 }
Esempio n. 8
0
 public static GremlinScript Unique(this GremlinScript query)
 {
     return(query.Append(".unique()"));
 }
Esempio n. 9
0
 public static GremlinScript BothV(this GremlinScript query)
 {
     return(query.Append(".bothV()"));
 }
Esempio n. 10
0
 public static GremlinScript Except(this GremlinScript query, string variable)
 {
     return(query.Append(".except({0})", variable));
 }
Esempio n. 11
0
 public static GremlinScript gE(this GremlinScript query, IEnumerable <long> Ids)
 {
     return(query.Append("g.e({0})", string.Join(",", Ids)));
 }
Esempio n. 12
0
 public static GremlinScript Back(this GremlinScript query, int steps)
 {
     return(query.Append(string.Format(".back({0})", steps)));
 }
Esempio n. 13
0
        public static GremlinScript Table(this GremlinScript query, string name, params string[] columnNames)
        {
            string names = string.Join(",", columnNames.Select(r => string.Concat("'", r, "'")));

            return(query.Append(string.Format(".table({0}, [{1}])", name, names)));
        }
Esempio n. 14
0
 public static GremlinScript NewArray(this GremlinScript query, string name)
 {
     return(query.Append(string.Format("{0} = [];", name)));
 }
Esempio n. 15
0
 public static GremlinScript Each(this GremlinScript query, string each, params object[] args)
 {
     return(query.Append(string.Format(".each{{{0}}}", string.Format(each, args))));
 }
Esempio n. 16
0
 public static GremlinScript BothV(this GremlinScript query, params string[] relationshipName)
 {
     return(query.Append(".bothV({0})", string.Join(",", relationshipName)));
 }
Esempio n. 17
0
 public static GremlinScript Reverse(this GremlinScript query)
 {
     return(query.Append(".reverse()"));
 }
Esempio n. 18
0
 public static GremlinScript Sort(this GremlinScript query, Expression <Func <JavaObject, object> > func)
 {
     return(query.Append(string.Format(".sort{{{0}}}", new ParseJavaLambda().Parse(func)), false));
 }
Esempio n. 19
0
 public static GremlinScript Sort(this GremlinScript query, string sort, params object[] args)
 {
     return(query.Append(string.Format(".sort({{{0}}})", string.Format(sort, args)), false));
 }
Esempio n. 20
0
 public static GremlinScript Filter(this GremlinScript query, string filter, params object[] args)
 {
     return(query.Append(string.Format(".filter{{{0}}}", string.Format(filter, args))));
 }
Esempio n. 21
0
 public static GremlinScript Filter(this GremlinScript query, string filter)
 {
     return(query.Append(string.Format(".filter{{{0}}}", filter), false));
 }
Esempio n. 22
0
 public static GremlinScript Table(this GremlinScript query, string name)
 {
     return(query.Append(string.Format(".table({0})", name)));
 }
Esempio n. 23
0
 public static GremlinScript ToList(this GremlinScript query)
 {
     return(query.Append(".toList()"));
 }
Esempio n. 24
0
 public static GremlinScript NewTable(this GremlinScript query, string name)
 {
     return(query.Append(string.Format("{0} = new Table();", name)));
 }
Esempio n. 25
0
 public static GremlinScript ToPipe(this GremlinScript query)
 {
     return(query.Append("._()"));
 }
Esempio n. 26
0
 public static GremlinScript gE(this GremlinScript query, long Id)
 {
     return(query.Append("g.e({0})", Id));
 }
Esempio n. 27
0
        public void FilterClauseCompound()
        {
            GremlinScript script = new GremlinScript();
            script.Append("g.v(0)")
                .Filter(it => it.GetProperty("MyProp") && !it.GetProperty("NotProp") || it.GetProperty("OrProp").ToLowerCase() == "lower Value");

            Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp') && !it.getProperty('NotProp') || it.getProperty('OrProp').toLowerCase() == 'lower Value'}");
        }
Esempio n. 28
0
 public static GremlinScript In(this GremlinScript query)
 {
     return(query.Append(".in()"));
 }
Esempio n. 29
0
 public static GremlinScript Back(this GremlinScript query, string label)
 {
     return(query.Append(string.Format(".back('{0}')", label)));
 }
Esempio n. 30
0
 public static GremlinScript Array <T>(this GremlinScript query, params T[] items)
 {
     return(query.Append(string.Format("[{0}]",
                                       items.Aggregate(new StringBuilder(), (sb, item) => sb.AppendFormat("{1}{2}{0}{2}", item, sb.Length > 0 ? "," : string.Empty, typeof(T) == typeof(string) ? "'" : string.Empty)))));
 }
Esempio n. 31
0
 public static GremlinScript g(this GremlinScript query, IEnumerable <Relationship> relationships)
 {
     return(query.Append("g.e({0})", string.Join(",", relationships.Select(s => s.Id).ToArray())));
 }
Esempio n. 32
0
 public static GremlinScript As(this GremlinScript query, string label)
 {
     return(query.Append(".as({0})", label));
 }
Esempio n. 33
0
 public static GremlinScript Aggregate(this GremlinScript query, string variable)
 {
     return(query.Append(".aggregate({0})", variable));
 }
Esempio n. 34
0
        public void FilterClauseEqualBool()
        {
            GremlinScript script = new GremlinScript();
            script.Append("g.v(0)")
                .Filter(it => it.GetProperty("MyProp") == true);

            Assert.IsTrue(script.ToString() == "g.v(0).filter{it.getProperty('MyProp') == true}");
        }
Esempio n. 35
0
 public static GremlinScript g(this GremlinScript query, Relationship relationship)
 {
     return(query.Append("g.e({0})", relationship.Id));
 }