diff --git a/pom.xml b/pom.xml index a477d0bbaf..f482afc3c3 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,7 @@ - diff --git a/src/docs/dev/index.txt b/src/docs/dev/index.txt new file mode 100644 index 0000000000..20650fa8ae --- /dev/null +++ b/src/docs/dev/index.txt @@ -0,0 +1,5 @@ +[[cypher-query-lang-dsl]] +Cypher Query Language DSL +========================= + +There is a DSL for the Cypher query language. diff --git a/src/main/assemblies/docs-assembly.xml b/src/main/assemblies/docs-assembly.xml new file mode 100644 index 0000000000..c1294657c5 --- /dev/null +++ b/src/main/assemblies/docs-assembly.xml @@ -0,0 +1,38 @@ + + + docs + false + + jar + + + + target/docs + / + + + src/docs + / + + + diff --git a/src/main/java/org/neo4j/cypherdsl/CypherQuery.java b/src/main/java/org/neo4j/cypherdsl/CypherQuery.java index 9b5ca9c480..89997a36fd 100644 --- a/src/main/java/org/neo4j/cypherdsl/CypherQuery.java +++ b/src/main/java/org/neo4j/cypherdsl/CypherQuery.java @@ -27,6 +27,9 @@ import org.neo4j.cypherdsl.query.StartExpression; import org.neo4j.cypherdsl.query.WhereExpression; +import java.util.HashMap; +import java.util.Map; + import static org.neo4j.cypherdsl.query.Query.checkEmpty; /** @@ -354,10 +357,59 @@ public Query toQuery() return query; } + @Override + public ExecuteWithParameters parameter(String name, Object value) + { + ExecuteWithParams withParams = new ExecuteWithParams(query); + return withParams.parameter(name, value); + } + @Override public String toString() { return CypherQuery.this.toString(); } } + + protected class ExecuteWithParams + implements ExecuteWithParameters + { + private Query query; + private Map parameters = new HashMap(); + + public ExecuteWithParams(Query query) + { + this.query = query; + } + + @Override + public Query toQuery() + { + return query; + } + + public Map getParameters() + { + return parameters; + } + + @Override + public ExecuteWithParameters parameter(String name, Object value) + { + parameters.put(name, value); + return this; + } + + @Override + public void asString(StringBuilder builder) + { + query.asString(builder); + } + + @Override + public String toString() + { + return query.toString(); + } + } } diff --git a/src/main/java/org/neo4j/cypherdsl/Execute.java b/src/main/java/org/neo4j/cypherdsl/Execute.java index 503529fd0c..10e8fa69fd 100644 --- a/src/main/java/org/neo4j/cypherdsl/Execute.java +++ b/src/main/java/org/neo4j/cypherdsl/Execute.java @@ -30,4 +30,6 @@ public interface Execute extends AsString { Query toQuery(); + + ExecuteWithParameters parameter(String name, Object value); } diff --git a/src/main/java/org/neo4j/cypherdsl/ExecuteWithParameters.java b/src/main/java/org/neo4j/cypherdsl/ExecuteWithParameters.java new file mode 100644 index 0000000000..7e62f03f28 --- /dev/null +++ b/src/main/java/org/neo4j/cypherdsl/ExecuteWithParameters.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2002-2011 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.neo4j.cypherdsl; + +import java.util.Map; + +/** + * TODO + */ +public interface ExecuteWithParameters + extends Execute +{ + Map getParameters(); +}