@Test public void substituteSingleRelationship() { Multimap<String, Object> valueMap = HashMultimap.create(); valueMap.put("node_id", "HP_123"); valueMap.put("rel_id", "RO_1"); String actual = util.substituteRelationships("({node_id})-[:${rel_id}!]-(end)", valueMap); assertThat(actual, is("({node_id})-[:RO_1!]-(end)")); }
String substituteRelationships(String query, final Multimap<String, Object> valueMap) { StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() { @Override public String lookup(String key) { Collection<String> resolvedRelationshipTypes = transform(valueMap.get(key), new Function<Object, String>() { @Override public String apply(Object input) { if (input.toString().matches(".*(\\s).*")) { throw new IllegalArgumentException( "Cypher relationship templates must not contain spaces"); } return curieUtil.getIri(input.toString()).orElse(input.toString()); } }); return on("|").join(resolvedRelationshipTypes); } }); return substitutor.replace(query); }
CypherUtil { String substituteRelationships(String query, final Multimap<String, Object> valueMap) { StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() { @Override public String lookup(String key) { Collection<String> resolvedRelationshipTypes = transform(valueMap.get(key), new Function<Object, String>() { @Override public String apply(Object input) { if (input.toString().matches(".*(\\s).*")) { throw new IllegalArgumentException( "Cypher relationship templates must not contain spaces"); } return curieUtil.getIri(input.toString()).orElse(input.toString()); } }); return on("|").join(resolvedRelationshipTypes); } }); return substitutor.replace(query); } }
CypherUtil { String substituteRelationships(String query, final Multimap<String, Object> valueMap) { StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() { @Override public String lookup(String key) { Collection<String> resolvedRelationshipTypes = transform(valueMap.get(key), new Function<Object, String>() { @Override public String apply(Object input) { if (input.toString().matches(".*(\\s).*")) { throw new IllegalArgumentException( "Cypher relationship templates must not contain spaces"); } return curieUtil.getIri(input.toString()).orElse(input.toString()); } }); return on("|").join(resolvedRelationshipTypes); } }); return substitutor.replace(query); } @Inject  CypherUtil(GraphDatabaseService graphDb, CurieUtil curieUtil); }
CypherUtil { String substituteRelationships(String query, final Multimap<String, Object> valueMap) { StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() { @Override public String lookup(String key) { Collection<String> resolvedRelationshipTypes = transform(valueMap.get(key), new Function<Object, String>() { @Override public String apply(Object input) { if (input.toString().matches(".*(\\s).*")) { throw new IllegalArgumentException( "Cypher relationship templates must not contain spaces"); } return curieUtil.getIri(input.toString()).orElse(input.toString()); } }); return on("|").join(resolvedRelationshipTypes); } }); return substitutor.replace(query); } @Inject  CypherUtil(GraphDatabaseService graphDb, CurieUtil curieUtil); Result execute(String query, Multimap<String, Object> params, long timeout, TimeUnit unit); Result execute(String query, long timeout, TimeUnit unit); Result execute(String query, Multimap<String, Object> params); Result execute(String query); Set<RelationshipType> getEntailedRelationshipTypes(Collection<String> parents); @Deprecated String resolveStartQuery(String cypher); String resolveNodeIris(String cypher); String resolveRelationships(String cypher); Map<String, String> getCurieMap(); }
CypherUtil { String substituteRelationships(String query, final Multimap<String, Object> valueMap) { StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() { @Override public String lookup(String key) { Collection<String> resolvedRelationshipTypes = transform(valueMap.get(key), new Function<Object, String>() { @Override public String apply(Object input) { if (input.toString().matches(".*(\\s).*")) { throw new IllegalArgumentException( "Cypher relationship templates must not contain spaces"); } return curieUtil.getIri(input.toString()).orElse(input.toString()); } }); return on("|").join(resolvedRelationshipTypes); } }); return substitutor.replace(query); } @Inject  CypherUtil(GraphDatabaseService graphDb, CurieUtil curieUtil); Result execute(String query, Multimap<String, Object> params, long timeout, TimeUnit unit); Result execute(String query, long timeout, TimeUnit unit); Result execute(String query, Multimap<String, Object> params); Result execute(String query); Set<RelationshipType> getEntailedRelationshipTypes(Collection<String> parents); @Deprecated String resolveStartQuery(String cypher); String resolveNodeIris(String cypher); String resolveRelationships(String cypher); Map<String, String> getCurieMap();  }