@Test public void getNode_nodeReturnedForValidLabel() { Optional<Node> node = graphApi.getNode("a", Optional.of("alabel")); assertThat(node.isPresent(), is(true)); assertThat(node.get(), is(a)); }
public Optional<Node> getNode(String id, Optional<String> lblHint) { String iriResolved = curieUtil.getIri(id).orElse(id); Optional<Node> node = Optional.empty(); if (lblHint.isPresent()) { Label hintLabel = Label.label(lblHint.get()); Node hit = graphDb.findNode(hintLabel, NodeProperties.IRI, iriResolved); if (hit != null) { node = Optional.of(hit); } } else { String startQuery = "MATCH (n {" + NodeProperties.IRI + ": \"" + iriResolved + "\"}) RETURN n"; Result res = cypherUtil.execute(startQuery); if (res.hasNext()) { node = Optional.of((Node) res.next().get("n")); } } return node; }
GraphApi { public Optional<Node> getNode(String id, Optional<String> lblHint) { String iriResolved = curieUtil.getIri(id).orElse(id); Optional<Node> node = Optional.empty(); if (lblHint.isPresent()) { Label hintLabel = Label.label(lblHint.get()); Node hit = graphDb.findNode(hintLabel, NodeProperties.IRI, iriResolved); if (hit != null) { node = Optional.of(hit); } } else { String startQuery = "MATCH (n {" + NodeProperties.IRI + ": \"" + iriResolved + "\"}) RETURN n"; Result res = cypherUtil.execute(startQuery); if (res.hasNext()) { node = Optional.of((Node) res.next().get("n")); } } return node; } }
GraphApi { public Optional<Node> getNode(String id, Optional<String> lblHint) { String iriResolved = curieUtil.getIri(id).orElse(id); Optional<Node> node = Optional.empty(); if (lblHint.isPresent()) { Label hintLabel = Label.label(lblHint.get()); Node hit = graphDb.findNode(hintLabel, NodeProperties.IRI, iriResolved); if (hit != null) { node = Optional.of(hit); } } else { String startQuery = "MATCH (n {" + NodeProperties.IRI + ": \"" + iriResolved + "\"}) RETURN n"; Result res = cypherUtil.execute(startQuery); if (res.hasNext()) { node = Optional.of((Node) res.next().get("n")); } } return node; } @Inject  GraphApi(GraphDatabaseService graphDb, CypherUtil cypherUtil, CurieUtil curieUtil); }
GraphApi { public Optional<Node> getNode(String id, Optional<String> lblHint) { String iriResolved = curieUtil.getIri(id).orElse(id); Optional<Node> node = Optional.empty(); if (lblHint.isPresent()) { Label hintLabel = Label.label(lblHint.get()); Node hit = graphDb.findNode(hintLabel, NodeProperties.IRI, iriResolved); if (hit != null) { node = Optional.of(hit); } } else { String startQuery = "MATCH (n {" + NodeProperties.IRI + ": \"" + iriResolved + "\"}) RETURN n"; Result res = cypherUtil.execute(startQuery); if (res.hasNext()) { node = Optional.of((Node) res.next().get("n")); } } return node; } @Inject  GraphApi(GraphDatabaseService graphDb, CypherUtil cypherUtil, CurieUtil curieUtil); Collection<Node> getEntailment(Node parent, DirectedRelationshipType relationship,
      boolean traverseEquivalentEdges); @AddCuries Graph getNeighbors(Set<Node> nodes, int depth, Set<DirectedRelationshipType> types,
      final Optional<Predicate<Node>> includeNode); Graph getEdges(RelationshipType type, boolean entail, long skip, long limit); Optional<Node> getNode(String id, Optional<String> lblHint); Graph getReachableNodes(Node start, List<String> rels, Set<String> lbls); Collection<RelationshipType> getAllRelationshipTypes(); Collection<String> getAllPropertyKeys(); }
GraphApi { public Optional<Node> getNode(String id, Optional<String> lblHint) { String iriResolved = curieUtil.getIri(id).orElse(id); Optional<Node> node = Optional.empty(); if (lblHint.isPresent()) { Label hintLabel = Label.label(lblHint.get()); Node hit = graphDb.findNode(hintLabel, NodeProperties.IRI, iriResolved); if (hit != null) { node = Optional.of(hit); } } else { String startQuery = "MATCH (n {" + NodeProperties.IRI + ": \"" + iriResolved + "\"}) RETURN n"; Result res = cypherUtil.execute(startQuery); if (res.hasNext()) { node = Optional.of((Node) res.next().get("n")); } } return node; } @Inject  GraphApi(GraphDatabaseService graphDb, CypherUtil cypherUtil, CurieUtil curieUtil); Collection<Node> getEntailment(Node parent, DirectedRelationshipType relationship,
      boolean traverseEquivalentEdges); @AddCuries Graph getNeighbors(Set<Node> nodes, int depth, Set<DirectedRelationshipType> types,
      final Optional<Predicate<Node>> includeNode); Graph getEdges(RelationshipType type, boolean entail, long skip, long limit); Optional<Node> getNode(String id, Optional<String> lblHint); Graph getReachableNodes(Node start, List<String> rels, Set<String> lbls); Collection<RelationshipType> getAllRelationshipTypes(); Collection<String> getAllPropertyKeys();  }