Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
* fixed bugs in createRelationship
Browse files Browse the repository at this point in the history
  • Loading branch information
Klemens Burchardi committed Sep 15, 2011
1 parent 663c35e commit e28edbb
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/main/java/org/neo4j/rest/graphdb/BatchRestAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,38 @@ public BatchRestAPI( URI uri, String user, String password ) {
super(uri, user, password);
}

public BatchRestAPI(URI uri, ExecutingRestRequest executingRestRequest){
super(uri);
this.restRequest = new RecordingRestRequest(executingRestRequest);
}

@Override
protected RestRequest createRestRequest( URI uri, String user, String password){
return new RecordingRestRequest(new ExecutingRestRequest(uri, user, password));
}


@Override
public Node createNode(Map<String, Object> props) {
RequestResult requestResult = restRequest.post("node", props);

final long batchId = requestResult.getBatchId();
final String location = requestResult.getLocation().toString();
return new RestNode(batchId, location, this );
public Node createRestNode(RequestResult requestResult) {
final long batchId = requestResult.getBatchId();
return new RestNode(batchId);
}

@Override
public RestRelationship createRelationship(Node startNode, Node endNode, RelationshipType type, Map<String, Object> props) {
final RestRequest restRequest = ((RestNode)startNode).getRestRequest();
public RestRelationship createRelationship(Node startNode, Node endNode, RelationshipType type, Map<String, Object> props) {

Map<String, Object> data = MapUtil.map("to", ((RestNode)endNode).getUri(), "type", type.name());
if (props!=null && props.size()>0) {
data.put("data",props);
}

RequestResult requestResult = restRequest.post( "relationships", data);
final long batchId = requestResult.getBatchId();
final String location = requestResult.getLocation().toString();
return new RestRelationship(batchId, location, ((RestNode)startNode).getRestApi() );
}
RequestResult requestResult = this.restRequest.post( ((RestNode)startNode).getUri()+"/relationships", data);
return createRestRelationship(requestResult, startNode);
}

@Override
public RestRelationship createRestRelationship(RequestResult requestResult, Node startNode) {
final long batchId = requestResult.getBatchId();
return new RestRelationship(batchId);
}

public Collection<RestOperation> getRecordedOperations(){
Expand Down

0 comments on commit e28edbb

Please sign in to comment.