Examples of RestNode


Examples of org.modeshape.web.jcr.rest.model.RestNode

        String parentUrl = isRoot ? RestHelper.urlFrom(baseUrl, ITEMS_METHOD_NAME, "..", "..") : RestHelper.urlFrom(baseUrl,
                                                                                                                    ITEMS_METHOD_NAME,
                                                                                                                    encodedPath(
                                                                                                                            node.getParent()
                                                                                                                                    .getPath()));
        RestNode restNode = new RestNode(nodeName(node), node.getIdentifier(), nodeUrl, parentUrl);

        // add the properties
        for (PropertyIterator propertyIterator = node.getProperties(); propertyIterator.hasNext();) {
            Property property = propertyIterator.nextProperty();
            restNode.addJcrProperty(createRestProperty(session, property, baseUrl));
        }

        // add the children
        for (NodeIterator nodeIterator = node.getNodes(); nodeIterator.hasNext();) {
            Node childNode = nodeIterator.nextNode();
            RestNode restChild = null;
            if (depth > 0) {
                restChild = createRestNode(session, childNode, baseUrl, depth - 1);
            } else if (depth < 0) {
                restChild = createRestNode(session, childNode, baseUrl, -1);
            } else {
                String childUrl = RestHelper.urlFrom(baseUrl, ITEMS_METHOD_NAME, encodedPath(childNode.getPath()));
                restChild = new RestNode(nodeName(childNode), childNode.getIdentifier(), childUrl, nodeUrl);
            }
            restNode.addChild(restChild);
        }
        return restNode;
    }
View Full Code Here

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

    }

    @Override
    public GraphInfo create(GraphInfo info) {
        if (isEmpty(info)) info = info.withId(Util.randomId());
        final RestNode node = restAPI.getOrCreateNode(index, "id", info.getId(), info.toMap());
        return new GraphInfo(node);
    }
View Full Code Here

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

  }

    @Test
    public void testCreateNodeUniquely() {
        final RestIndex<Node> index = restAPI.createIndex(Node.class, "unique-node", LuceneIndexImplementation.EXACT_CONFIG);
        final RestNode node1 = restAPI.getOrCreateNode(index, "uid", "42", map("name", "Michael"), NO_LABELS);
        final RestNode node2 = restAPI.getOrCreateNode(index, "uid", "42", map("name", "Michael2"), NO_LABELS);
        assertEquals(node1,node2);
        assertEquals("Michael",node1.getProperty("name"));
        assertEquals("Michael",node2.getProperty("name"));
        final RestNode node3 = restAPI.getOrCreateNode(index, "uid", "41", map("name", "Emil"), NO_LABELS);
        assertEquals(false, node1.equals(node3));
    }
View Full Code Here

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

        assertEquals(false, node1.equals(node3));
    }
    @Test
    public void testCreateRelationshipUniquely() {
        final RestIndex<Relationship> index = restAPI.createIndex(Relationship.class, "unique-rel", LuceneIndexImplementation.EXACT_CONFIG);
        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);
View Full Code Here

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

        assertEquals(false, rel3.equals(rel1));
    }

    @Test
    public void testGetNodeLabel() {
        RestNode node = restAPI.createNode(map());
        node.addLabel(LABEL_FOO);
        int count=0;
        for (Label label1 : node.getLabels()) {
            assertEquals(LABEL_FOO.name(),label1.name());
            count++;
        }
        assertEquals("one label",1,count);
    }
View Full Code Here

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

        }
        assertEquals("one label",1,count);
    }
    @Test
    public void testRemoveNodeLabel() {
        RestNode node = restAPI.createNode(map());
        node.addLabel(LABEL_FOO);
        node.removeLabel(LABEL_FOO);
        assertFalse(node.getLabels().iterator().hasNext());
    }
View Full Code Here

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

        assertFalse(node.getLabels().iterator().hasNext());
    }

    @Test
    public void testGetNodeByLabel() throws Exception {
        RestNode node = restAPI.createNode(map());
        node.addLabel(LABEL_FOO);
        int count=0;
        for (RestNode restNode : restAPI.getNodesByLabel(LABEL_FOO.name())) {
            assertEquals(node,restNode);
            count++;
        }
View Full Code Here

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

        assertEquals("one node with label",1,count);
    }

    @Test
    public void testSetNodeLabel() throws Exception {
        RestNode n1 = restAPI.createNode(map("name", "node1"));
        n1.addLabel(LABEL_FOO);
        n1.addLabel(LABEL_BAR);
        Collection<String> labels = IteratorUtil.asCollection(new IterableWrapper<String, Label>(n1.getLabels()) {
            protected String underlyingObjectToObject(Label label) {
                return label.name();
            }
        });
        assertThat(labels, hasItems(LABEL_FOO.name(), LABEL_BAR.name()));
View Full Code Here

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

        assertThat(labels, hasItems(LABEL_FOO.name(), LABEL_BAR.name()));
    }

    @Test
    public void testRemoveNodeLabel2() throws Exception {
        RestNode n1 = restAPI.createNode(map("name", "node1"));
        n1.addLabel(LABEL_FOO);
        n1.addLabel(LABEL_BAR);

        n1.removeLabel(LABEL_BAR);
        Collection<String> labels = IteratorUtil.asCollection(new IterableWrapper<String, Label>(n1.getLabels()) {
            protected String underlyingObjectToObject(Label label) {
                return label.name();
            }
        });
        assertThat(labels, hasItems(LABEL_FOO.name()));
View Full Code Here

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

        assertThat(labels, hasItems(LABEL_FOO.name()));
    }

    @Test
    public void testGetNodeByLabelAndProperty() throws Exception {
        RestNode node = restAPI.createNode(map("name","foo bar"));
        node.addLabel(LABEL_FOO);
        int count=0;
        for (RestNode restNode : restAPI.getNodesByLabelAndProperty(LABEL_FOO.name(),"name","foo bar")) {
            assertEquals(node,restNode);
            count++;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.