Package org.neo4j.rest.graphdb.entity

Examples of org.neo4j.rest.graphdb.entity.RestRelationship


        final RestNode michael = restAPI.createNode(map("name", "Michael"));
        final RestNode david = restAPI.createNode(map("name","David"));
        final RestNode peter = restAPI.createNode(map("name","Peter"));


        final RestRelationship rel1 = restAPI.getOrCreateRelationship(index, "uid", "42", michael, david, "KNOWS", map("at", "Neo4j"));
        final RestRelationship rel2 = restAPI.getOrCreateRelationship(index, "uid", "42", michael, david, "KNOWS", map("at", "Neo4j"));
        assertEquals(rel1,rel2);
        assertEquals("Neo4j",rel1.getProperty("at"));
        assertEquals("Neo4j",rel2.getProperty("at"));
        final RestRelationship rel3 = restAPI.getOrCreateRelationship(index, "uid", "41", michael, david, "KNOWS", map("at", "Neo4j"));
        assertEquals(false, rel3.equals(rel1));
    }
View Full Code Here


    public RestRelationship getRelationshipById(long id) {
        RequestResult requestResult = restRequest.get("relationship/" + id);
        if (requestResult.statusIs(Status.NOT_FOUND)) {
            throw new NotFoundException("" + id);
        }
        return new RestRelationship(requestResult.toMap(), this);
    }
View Full Code Here

        if (requestResult.statusOtherThan(CREATED)) {
            final int status = requestResult.getStatus();
            throw new RuntimeException("Error creating relationship " + status+" "+requestResult.getText());
        }
        final String location = requestResult.getLocation();
        if (requestResult.isMap()) return new RestRelationship(requestResult.toMap(), this);
        return new RestRelationship(location, this);
    }
View Full Code Here

        if (uri == null || uri.isEmpty()) return null;
        if (uri.contains("/node/")) {
            return entityCache.addToCache(new RestNode(data, this));
        }
        if (uri.contains("/relationship/")) {
            return new RestRelationship(data, this);
        }
        return null;
    }
View Full Code Here

    @Override
    public Object convertFromRepresentation(RequestResult requestResult) {
        return new IterableWrapper<Relationship, Object>((Collection<Object>) requestResult.toEntity()) {
            @Override
            protected Relationship underlyingObjectToObject(Object data) {
                return new RestRelationship((Map<?, ?>) data, restAPI);
            }
        };
    }
View Full Code Here

        final Map<?, ?> lastRelationshipData = lastElementMap(relationshipsData);
        final Map<?, ?> startData = (Map<?, ?>) path.get("start");
        final Map<?, ?> endData = (Map<?, ?>) path.get("end");
        final Integer length = (Integer) path.get("length");

        RestRelationship lastRelationship = lastRelationshipData == null ? null : new RestRelationship(lastRelationshipData, restApi);
        return new SimplePath(
                new RestNode(startData,restApi),
                new RestNode(endData,restApi),
                lastRelationship,
                length,
                new IterableWrapper<Node, Map<?,?>>(nodesData) {
                    @Override
                    protected Node underlyingObjectToObject(Map<?, ?> data) {
                        return new RestNode(data,restApi);
                    }
                },
                new IterableWrapper<Relationship, Map<?,?>>(relationshipsData) {
                    @Override
                    protected Relationship underlyingObjectToObject(Map<?, ?> data) {
                        return new RestRelationship(data,restApi);
                    }
                });
    }
View Full Code Here

        final Collection<String> relationshipsData = (Collection<String>) path.get("relationships");
        final String lastRelationshipData = lastElement(relationshipsData);
        final String startData = (String) path.get("start");
        final String endData = (String) path.get("end");
        final Integer length = (Integer) path.get("length");
        RestRelationship lastRelationship = lastRelationshipData == null ? null : new RestRelationship(lastRelationshipData, restApi);
        return new SimplePath(
                new RestNode(startData,restApi),
                new RestNode(endData,restApi),
                lastRelationship,
                length,
                new IterableWrapper<Node, String>(nodesData) {
                    @Override
                    protected Node underlyingObjectToObject(String data) {
                        return new RestNode(data,restApi);
                    }
                },
                new IterableWrapper<Relationship, String>(relationshipsData) {
                    @Override
                    protected Relationship underlyingObjectToObject(String data) {
                        return new RestRelationship(data,restApi);
                    }
                });
    }
View Full Code Here

TOP

Related Classes of org.neo4j.rest.graphdb.entity.RestRelationship

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.