@Test public void testGenerateDiff() { OpObject opObject = null; String field = F_TAGS + "."; Map<String, Object> change = new TreeMap<>(); Map<String, Object> current = new TreeMap<>(); Map<String, Object> oldM = new TreeMap<>(); oldM.put("addr:city", "台北市"); oldM.put("amenity", "cafe"); oldM.put("http: Map<String, Object> newM = new TreeMap<>(); newM.put("addr:city", "rets"); newM.put("amenity", "bar"); newM.put("http: PlaceOpObjectHelper.generateDiff(opObject, field, change, current, oldM, newM); assertEquals("{tags.addr:city=台北市, tags.amenity=cafe, tags.{http: assertEquals("{tags.addr:city={set=rets}, tags.amenity={set=bar}, tags.{http: }
protected static void generateDiff(OpObject editObject, String field, Map<String, Object> change, Map<String, Object> current, Map<String, Object> oldM, Map<String, Object> newM) { TreeSet<String> removedTags = new TreeSet<>(oldM.keySet()); removedTags.removeAll(newM.keySet()); for(String removedTag : removedTags) { change.put(field + addQuotes(removedTag), OpBlockChain.OP_CHANGE_DELETE); current.put(field + addQuotes(removedTag), oldM.get(removedTag)); } for(String tag : newM.keySet()) { Object po = oldM.get(tag); Object no = newM.get(tag); if(!OUtils.equals(po, no)) { change.put(field + addQuotes(tag), set(no)); if(po != null) { current.put(field + addQuotes(tag), po); } } } }
PlaceOpObjectHelper { protected static void generateDiff(OpObject editObject, String field, Map<String, Object> change, Map<String, Object> current, Map<String, Object> oldM, Map<String, Object> newM) { TreeSet<String> removedTags = new TreeSet<>(oldM.keySet()); removedTags.removeAll(newM.keySet()); for(String removedTag : removedTags) { change.put(field + addQuotes(removedTag), OpBlockChain.OP_CHANGE_DELETE); current.put(field + addQuotes(removedTag), oldM.get(removedTag)); } for(String tag : newM.keySet()) { Object po = oldM.get(tag); Object no = newM.get(tag); if(!OUtils.equals(po, no)) { change.put(field + addQuotes(tag), set(no)); if(po != null) { current.put(field + addQuotes(tag), po); } } } } }
PlaceOpObjectHelper { protected static void generateDiff(OpObject editObject, String field, Map<String, Object> change, Map<String, Object> current, Map<String, Object> oldM, Map<String, Object> newM) { TreeSet<String> removedTags = new TreeSet<>(oldM.keySet()); removedTags.removeAll(newM.keySet()); for(String removedTag : removedTags) { change.put(field + addQuotes(removedTag), OpBlockChain.OP_CHANGE_DELETE); current.put(field + addQuotes(removedTag), oldM.get(removedTag)); } for(String tag : newM.keySet()) { Object po = oldM.get(tag); Object no = newM.get(tag); if(!OUtils.equals(po, no)) { change.put(field + addQuotes(tag), set(no)); if(po != null) { current.put(field + addQuotes(tag), po); } } } }  }
PlaceOpObjectHelper { protected static void generateDiff(OpObject editObject, String field, Map<String, Object> change, Map<String, Object> current, Map<String, Object> oldM, Map<String, Object> newM) { TreeSet<String> removedTags = new TreeSet<>(oldM.keySet()); removedTags.removeAll(newM.keySet()); for(String removedTag : removedTags) { change.put(field + addQuotes(removedTag), OpBlockChain.OP_CHANGE_DELETE); current.put(field + addQuotes(removedTag), oldM.get(removedTag)); } for(String tag : newM.keySet()) { Object po = oldM.get(tag); Object no = newM.get(tag); if(!OUtils.equals(po, no)) { change.put(field + addQuotes(tag), set(no)); if(po != null) { current.put(field + addQuotes(tag), po); } } } }  static OpObject generateNewOprObject(Entity entity, TreeMap<String, Object> osmObject ); static OpOperation generateSetOperation(OpOperation op, List<String> id, 
			String field, String oldValue, String newValue); static TreeMap<String, Object> createOsmObject(String osmTag, Entity entity); static OpOperation generateEditDeleteOsmIdsForPlace(OpOperation opOperation, PlaceObject po); @SuppressWarnings("unchecked") static OpOperation generateEditValuesForPlace(OpOperation op, PlaceObject po, Map<String, Object> osmObj); @SuppressWarnings("unchecked") static SyncRequest parseSyncRequest(SyncRequest cp, Object o); static OpOperation generateEditOpForBotObject(OpOperation opOperation, SyncRequest r, OpObject botObject); static OpOperation generateEditBeginObject(OpOperation opOperation, SyncRequest r, OpObject botObject); static OpOperation generateEditOpForBotObject(OpOperation opOperation, String field, String ptimestamp, 
			String timestamp, OpObject botObject); static void generateEntityInfo(TreeMap<String, Object> osmObject, EntityInfo entityInfo); }
PlaceOpObjectHelper { protected static void generateDiff(OpObject editObject, String field, Map<String, Object> change, Map<String, Object> current, Map<String, Object> oldM, Map<String, Object> newM) { TreeSet<String> removedTags = new TreeSet<>(oldM.keySet()); removedTags.removeAll(newM.keySet()); for(String removedTag : removedTags) { change.put(field + addQuotes(removedTag), OpBlockChain.OP_CHANGE_DELETE); current.put(field + addQuotes(removedTag), oldM.get(removedTag)); } for(String tag : newM.keySet()) { Object po = oldM.get(tag); Object no = newM.get(tag); if(!OUtils.equals(po, no)) { change.put(field + addQuotes(tag), set(no)); if(po != null) { current.put(field + addQuotes(tag), po); } } } }  static OpObject generateNewOprObject(Entity entity, TreeMap<String, Object> osmObject ); static OpOperation generateSetOperation(OpOperation op, List<String> id, 
			String field, String oldValue, String newValue); static TreeMap<String, Object> createOsmObject(String osmTag, Entity entity); static OpOperation generateEditDeleteOsmIdsForPlace(OpOperation opOperation, PlaceObject po); @SuppressWarnings("unchecked") static OpOperation generateEditValuesForPlace(OpOperation op, PlaceObject po, Map<String, Object> osmObj); @SuppressWarnings("unchecked") static SyncRequest parseSyncRequest(SyncRequest cp, Object o); static OpOperation generateEditOpForBotObject(OpOperation opOperation, SyncRequest r, OpObject botObject); static OpOperation generateEditBeginObject(OpOperation opOperation, SyncRequest r, OpObject botObject); static OpOperation generateEditOpForBotObject(OpOperation opOperation, String field, String ptimestamp, 
			String timestamp, OpObject botObject); static void generateEntityInfo(TreeMap<String, Object> osmObject, EntityInfo entityInfo); static final String F_SOURCE; static final String F_OLD_OSM_IDS; static final String F_OSM; static final String F_TAGS; static final String F_OSM_TAG; static final String F_OSM_VALUE; static final String F_VERSION; static final String F_CHANGESET; static final String F_TIMESTAMP; }