@Override public MapValue properties() { MapValue m = properties; if ( m == null ) { synchronized ( this ) { m = properties; if ( m == null ) { m = properties = ValueUtils.asMapValue( relationship.getAllProperties() ); } } } return m; } }
private void cloneProperties( Relationship oldRelationship, Relationship newRelationship ) { for ( Map.Entry<String, Object> property : oldRelationship.getAllProperties().entrySet() ) { newRelationship.setProperty( property.getKey(), property.getValue() ); } }
public Map<String, Object> getRelationshipProperties( long relationshipId ) { try ( Transaction tx = database.getGraph().beginTransaction( implicit, AnonymousContext.read() ) ) { Relationship relationship = database.getGraph().getRelationshipById( relationshipId ); Map<String, Object> allProperties = relationship.getAllProperties(); tx.success(); return allProperties; } }
private Map<String, Object> addRelProperties(Map<String, Object> mMap, String typeName, Relationship r) { Map<String, Object> rProps = r.getAllProperties(); if (rProps.isEmpty()) return mMap; String prefix = typeName + "."; rProps.forEach((k, v) -> mMap.put(prefix + k, v)); return mMap; }
public static String formatRelationshipProperties(String id, Relationship relationship, boolean jsonStyle) { StringBuilder result = formatProperties(id, relationship.getAllProperties(), jsonStyle); return result.length() > 0 ? result.substring(2) : ""; }
private void writeRel(Reporter reporter, JsonGenerator jsonGenerator, Relationship rel, ExportConfig config) throws IOException { Map<String, Object> allProperties = rel.getAllProperties(); JsonFormatSerializer.DEFAULT.writeRelationship(jsonGenerator, rel, config); reporter.update(0, 1, allProperties.size()); }
private Relationship mergeRels(Relationship source, Relationship target, boolean delete, RefactorConfig conf) { Map<String, Object> properties = source.getAllProperties(); if (delete) source.delete(); PropertiesManager.mergeProperties(properties, target, conf); return target; }
assertTrue( rel1.hasProperty( key3 ) ); Map<String,Object> properties = rel1.getAllProperties(); assertEquals( properties.get( key1 ), int1 ); assertEquals( properties.get( key2 ), int2 );
@Override public void writeRelationship(JsonGenerator jsonGenerator, Relationship rel, ExportConfig config) throws IOException { Node startNode = rel.getStartNode(); Node endNode = rel.getEndNode(); jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("id", String.valueOf(rel.getId())); jsonGenerator.writeStringField("type", "relationship"); jsonGenerator.writeStringField("label", rel.getType().toString()); serializeProperties(jsonGenerator, rel.getAllProperties()); writeRelationshipNode(jsonGenerator, "start", startNode, config); writeRelationshipNode(jsonGenerator, "end", endNode, config); jsonGenerator.writeEndObject(); }
@UserFunction("apoc.meta.cypher.types") @Description("apoc.meta.cypher.types(node-relationship-map) - returns a map of keys to types") public Map<String,Object> typesCypher(@Name("properties") Object target) { Map<String,Object> properties = Collections.emptyMap(); if (target instanceof Node) properties = ((Node)target).getAllProperties(); if (target instanceof Relationship) properties = ((Relationship)target).getAllProperties(); if (target instanceof Map) { //noinspection unchecked properties = (Map<String, Object>) target; } Map<String,Object> result = new LinkedHashMap<>(properties.size()); properties.forEach((key,value) -> { result.put(key, typeCypher(value)); }); return result; }
@Deprecated @UserFunction @Description("apoc.meta.types(node-relationship-map) - returns a map of keys to types") public Map<String,Object> types(@Name("properties") Object target) { Map<String,Object> properties = Collections.emptyMap(); if (target instanceof Node) properties = ((Node)target).getAllProperties(); if (target instanceof Relationship) properties = ((Relationship)target).getAllProperties(); if (target instanceof Map) { //noinspection unchecked properties = (Map<String, Object>) target; } Map<String,Object> result = new LinkedHashMap<>(properties.size()); properties.forEach((key,value) -> { result.put(key, typeName(value)); }); return result; }
public List<Relationship> getRelationships(Node n, Map<String, Number> filter, int relsPerNode) { List<Relationship> rels = fixAggregates(Iterables.asList(n.getRelationships())); if (filter != null) rels.removeIf(r -> !filter(r.getType().name(),r.getAllProperties(),filter)); if (relsPerNode > -1) rels = rels.subList(0, Math.min(relsPerNode, rels.size())); return rels; }
String relationship = cypherName(config, "relationship", () -> "", Util::quote); String end = cypherName(config,"end", ()->toCypher(rel.getEndNode(),config),(s)->'('+quote(s)+')'); return start+"-["+relationship+type+' '+ toCypher(rel.getAllProperties(), config)+"]->"+ end;
@Override public Map<String, Object> getAllProperties() { return actual.getAllProperties(); }
assertBar(((Node)r.get("bar"))); assertEquals("EDGE_LABEL", ((Relationship)r.get("rel")).getType().name()); assertEquals(Util.map("name", "foo"), ((Relationship)r.get("rel")).getAllProperties()); }); TestUtil.testCall(db, "MATCH (bar:BAR)-[test:TEST]->(foo:FOO) RETURN bar, test, foo", null, (r) -> {
@Override public MapValue properties() { MapValue m = properties; if ( m == null ) { synchronized ( this ) { m = properties; if ( m == null ) { m = properties = ValueUtils.asMapValue( relationship.getAllProperties() ); } } } return m; } }
@Test public void testMergeRelationships() throws Exception { db.execute("create (:Person{name:'Foo'}), (:Person{name:'Bar'})"); testCall(db, "MERGE (s:Person{name:'Foo'}) MERGE (e:Person{name:'Bar'}) WITH s,e CALL apoc.merge.relationship(s, 'KNOWS', {rid:123}, {since:'Thu'}, e) YIELD rel RETURN rel", (row) -> { Relationship rel = (Relationship) row.get("rel"); assertEquals("KNOWS", rel.getType().name()); assertEquals(123l, rel.getProperty("rid")); assertEquals("Thu", rel.getProperty("since")); }); testCall(db, "MERGE (s:Person{name:'Foo'}) MERGE (e:Person{name:'Bar'}) WITH s,e CALL apoc.merge.relationship(s, 'KNOWS', {rid:123}, {since:'Fri'}, e) YIELD rel RETURN rel", (row) -> { Relationship rel = (Relationship) row.get("rel"); assertEquals("KNOWS", rel.getType().name()); assertEquals(123l, rel.getProperty("rid")); assertEquals("Thu", rel.getProperty("since")); }); testCall(db, "MERGE (s:Person{name:'Foo'}) MERGE (e:Person{name:'Bar'}) WITH s,e CALL apoc.merge.relationship(s, 'OTHER', null, null, e) YIELD rel RETURN rel", (row) -> { Relationship rel = (Relationship) row.get("rel"); assertEquals("OTHER", rel.getType().name()); assertTrue(rel.getAllProperties().isEmpty()); }); }
protected static void connectStateToRs(Node sourceState, Node newState) { streamOfIterable(sourceState.getRelationships(Direction.OUTGOING)) .filter(rel -> rel.getEndNode().hasLabel(Label.label("R"))) .forEach(rel -> RelationshipProcedure.createRelationship(newState, rel.getEndNode(), rel.getType().name(), rel.getAllProperties())); } }
private int writeRelationship(Output output, Relationship relationship) { // WRITE RELATIONSHIP kryo.writeObject(output, KryoSerializationTypes.RELATIONSHIP.name()); kryo.writeObject(output, relationship.getId()); // WRITE SOURCE kryo.writeObject(output, relationship.getStartNode().getId()); // WRITE TARGET kryo.writeObject(output, relationship.getEndNode().getId()); // WRITE LABEL kryo.writeObject(output, relationship.getType().name()); // WRITE PROPERTIES Map<String, Object> properties = relationship.getAllProperties(); kryo.writeObject(output, relationship.getAllProperties()); return properties.size(); } }
private RelationshipModel buildRelationship(Relationship relationship) { RelationshipModel relationshipModel = new RelationshipModel(); relationshipModel.setId(relationship.getId()); relationshipModel.setStartNode(relationship.getStartNode().getId()); relationshipModel.setEndNode(relationship.getEndNode().getId()); relationshipModel.setType(relationship.getType().name()); relationshipModel.setProperties(relationship.getAllProperties()); return relationshipModel; } }