Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added support for specifying parameters
  • Loading branch information
rickardoberg committed Dec 12, 2011
1 parent a147641 commit 3e2ce2a
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pom.xml
Expand Up @@ -150,7 +150,7 @@
</execution>
</executions>
</plugin>
<!--

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
Expand All @@ -161,7 +161,7 @@
<attach>true</attach>
<appendAssemblyId>true</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/docs-assembly.xml</descriptor>
<descriptor>src/main/assemblies/docs-assembly.xml</descriptor>
</descriptors>
</configuration>
<goals>
Expand All @@ -170,7 +170,6 @@
</execution>
</executions>
</plugin>
-->
</plugins>
</build>

Expand Down
5 changes: 5 additions & 0 deletions 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.
38 changes: 38 additions & 0 deletions src/main/assemblies/docs-assembly.xml
@@ -0,0 +1,38 @@
<!--
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 <http://www.gnu.org/licenses/>.
-->
<assembly>
<id>docs</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>target/docs</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/docs</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
52 changes: 52 additions & 0 deletions src/main/java/org/neo4j/cypherdsl/CypherQuery.java
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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<String, Object> parameters = new HashMap<String, Object>();

public ExecuteWithParams(Query query)
{
this.query = query;
}

@Override
public Query toQuery()
{
return query;
}

public Map<String, Object> 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();
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/org/neo4j/cypherdsl/Execute.java
Expand Up @@ -30,4 +30,6 @@ public interface Execute
extends AsString
{
Query toQuery();

ExecuteWithParameters parameter(String name, Object value);
}
32 changes: 32 additions & 0 deletions 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 <http://www.gnu.org/licenses/>.
*/

package org.neo4j.cypherdsl;

import java.util.Map;

/**
* TODO
*/
public interface ExecuteWithParameters
extends Execute
{
Map<String, Object> getParameters();
}

0 comments on commit 3e2ce2a

Please sign in to comment.