Skip to content

Commit

Permalink
Nodes are now returnes as node-representation
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Mar 9, 2012
1 parent d96e717 commit 7aa9bff
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ public void send_queries_with_parameters() throws Exception {
assertTrue( response.contains( "data" ) );
}

@Test
@Graph( nodes = {
@NODE( name = "I", properties = {
@PROP( key = "prop", value = "Hello", type = GraphDescription.PropType.STRING ) } ),
@NODE( name = "you" ) },
relationships = {
@REL( start = "I", end = "him", type = "know", properties = {
@PROP( key = "prop", value = "World", type = GraphDescription.PropType.STRING ) } ) } )
public void nodes_are_represented_as_nodes() throws Exception {
data.get();
String script = "start n = node(%I%) match n-[r]->() return n, r";

String response = cypherRestCall( script, Status.OK );

assertThat( response, containsString( "Hello" ) );
assertThat( response, containsString( "World" ) );
}

@Test
@Documented
@Graph( value = { "I know you" }, autoIndexNodes = true )
Expand Down Expand Up @@ -204,9 +222,4 @@ private String cypherUri()
{
return getDataUri() + "cypher";
}

private String cypherAltUri()
{
return getDataUri() + "cypher_alt";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
package org.neo4j.server.rest.repr;

import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.Relationship;
import org.neo4j.server.webadmin.rest.representations.JmxAttributeRepresentationDispatcher;

import java.util.ArrayList;
Expand Down Expand Up @@ -63,12 +66,31 @@ public Representation data()

Representation getRepresentation( Object r )
{
if( r == null ) {
if( r == null )
{
return ValueRepresentation.string( null );
} else if(r instanceof Iterable) {
}

if ( r instanceof Path )
{
return new PathRepresentation<Path>((Path) r );
}

if(r instanceof Iterable)
{
return handleIterable( (Iterable) r );
}

if ( r instanceof Node)
{
return new NodeRepresentation( (Node) r );
}

if ( r instanceof Relationship)
{
return new RelationshipRepresentation( (Relationship) r );
}

JmxAttributeRepresentationDispatcher representationDispatcher = new JmxAttributeRepresentationDispatcher();
return representationDispatcher.dispatch( r, "" );
}
Expand Down

0 comments on commit 7aa9bff

Please sign in to comment.