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

Commit

Permalink
* changed constructor to need only the batchid
Browse files Browse the repository at this point in the history
  • Loading branch information
Klemens Burchardi committed Sep 15, 2011
1 parent 9f00317 commit 3a0d374
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/neo4j/rest/graphdb/RestEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RestEntity implements PropertyContainer {
private Map<?, ?> structuralData;
private Map<String, Object> propertyData;
private long lastTimeFetchedPropertyData;
private RestAPI restApi;
protected RestAPI restApi;
private long batchId;
private boolean isBatch = false;

Expand All @@ -33,8 +33,7 @@ public RestEntity( String uri, RestAPI restApi ) {
this.restApi = restApi;
}

public RestEntity(long batchId , String uri, RestAPI restApi){
this(uri, restApi );
public RestEntity(long batchId){
this.batchId = batchId;
this.isBatch = true;
}
Expand Down Expand Up @@ -149,6 +148,9 @@ static long getEntityId( String uri ) {
}

public long getId() {
if (isBatch){
return this.batchId;
}
return getEntityId( getUri() );
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/neo4j/rest/graphdb/RestNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public RestNode( Map<?, ?> data, RestAPI restApi ) {
super( data, restApi );
}

public RestNode(long batchId , String uri, RestAPI restApi){
super(batchId, uri, restApi);
public RestNode(long batchId){
super(batchId);
}

public Relationship createRelationshipTo( Node toNode, RelationshipType type ) {
return RestRelationship.create(this,(RestNode)toNode,type,null);
return this.restApi.createRelationship(this,(RestNode)toNode,type,null);
}

public Iterable<Relationship> getRelationships() {
Expand Down
20 changes: 4 additions & 16 deletions src/main/java/org/neo4j/rest/graphdb/RestRelationship.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class RestRelationship extends RestEntity implements Relationship {
super( uri, restApi );
}

public RestRelationship( long batchId, String uri, RestAPI restApi ) {
super( batchId, uri, restApi );
public RestRelationship( long batchId) {
super( batchId);
}

public RestRelationship( Map<?, ?> data, RestAPI restApi ) {
Expand Down Expand Up @@ -67,20 +67,8 @@ public boolean isType( RelationshipType type ) {
}


public static RestRelationship create(RestNode startNode, RestNode endNode, RelationshipType type, Map<String, Object> props) {
final RestRequest restRequest = startNode.getRestRequest();
Map<String, Object> data = MapUtil.map("to", endNode.getUri(), "type", type.name());
if (props!=null && props.size()>0) {
data.put("data",props);
}

RequestResult requestResult = restRequest.post( "relationships", data);
if ( requestResult.statusOtherThan(javax.ws.rs.core.Response.Status.CREATED ) ) {
final int status = requestResult.getStatus();
throw new RuntimeException( "" + status);
}
final URI location = requestResult.getLocation();
return new RestRelationship(location, startNode.getRestApi() );
public RestRelationship create(RestNode startNode, RestNode endNode, RelationshipType type, Map<String, Object> props) {
return this.restApi.createRelationship(startNode, endNode, type, props);
}

}

0 comments on commit 3a0d374

Please sign in to comment.