@Test public void testMergeProperties() throws Exception { List<Node> nodes = TestUtil.firstColumn(db, "UNWIND [{name:'Joe',age:42,kids:'Jane'},{name:'Jane',age:32,kids:'June'}] AS data CREATE (p:Person) SET p = data RETURN p"); try (Transaction tx = db.beginTx()) { Node target = Util.rebind(tx, nodes.get(0)); Node source = Util.rebind(tx, nodes.get(1)); PropertiesManager.mergeProperties(source.getAllProperties(), target, new RefactorConfig( map("properties",map("nam.*", RefactorConfig.DISCARD, "age", RefactorConfig.OVERWRITE, "kids", RefactorConfig.COMBINE)))); assertEquals("Joe", target.getProperty("name")); assertEquals(32L, target.getProperty("age")); assertEquals(asList("Jane","June"), asList((String[])target.getProperty("kids"))); tx.commit(); } }
public static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig) { for (Map.Entry<String, Object> prop : properties.entrySet()) { String key = prop.getKey(); String mergeMode = refactorConfig.getMergeMode(key); mergeProperty(target, refactorConfig, prop, key, mergeMode); } }
PropertiesManager { public static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig) { for (Map.Entry<String, Object> prop : properties.entrySet()) { String key = prop.getKey(); String mergeMode = refactorConfig.getMergeMode(key); mergeProperty(target, refactorConfig, prop, key, mergeMode); } } }
PropertiesManager { public static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig) { for (Map.Entry<String, Object> prop : properties.entrySet()) { String key = prop.getKey(); String mergeMode = refactorConfig.getMergeMode(key); mergeProperty(target, refactorConfig, prop, key, mergeMode); } } private  PropertiesManager(); }
PropertiesManager { public static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig) { for (Map.Entry<String, Object> prop : properties.entrySet()) { String key = prop.getKey(); String mergeMode = refactorConfig.getMergeMode(key); mergeProperty(target, refactorConfig, prop, key, mergeMode); } } private  PropertiesManager(); static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig); static void combineProperties(Map.Entry<String, Object> prop, Entity target); }
PropertiesManager { public static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig) { for (Map.Entry<String, Object> prop : properties.entrySet()) { String key = prop.getKey(); String mergeMode = refactorConfig.getMergeMode(key); mergeProperty(target, refactorConfig, prop, key, mergeMode); } } private  PropertiesManager(); static void mergeProperties(Map<String, Object> properties, Entity target, RefactorConfig refactorConfig); static void combineProperties(Map.Entry<String, Object> prop, Entity target);  }