@Test public void testGetEntityId() throws DecoderException { String id = "1234567890123456789012345678901234567890"; String superid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; String extraid = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; Map<String, Object> delta = new HashMap<String, Object>(); delta.put("_id", Hex.decodeHex(id.toCharArray())); assertEquals(id + "_id", DeltaJournal.getEntityId(delta)); delta.put("i", Arrays.asList(Hex.decodeHex(superid.toCharArray()))); assertEquals(superid + "_id" + id + "_id", DeltaJournal.getEntityId(delta)); delta.put("i", Arrays.asList(Hex.decodeHex(superid.toCharArray()), Hex.decodeHex(extraid.toCharArray()))); assertEquals(extraid + "_id" + superid + "_id" + id + "_id", DeltaJournal.getEntityId(delta)); }
public static String getEntityId(Map<String, Object> deltaRecord) { Object deltaId = deltaRecord.get("_id"); if(deltaId instanceof String){ return (String) deltaId; } else if (deltaId instanceof byte[]) { StringBuilder id = new StringBuilder(""); @SuppressWarnings("unchecked") List<byte[]> parts = (List<byte[]>) deltaRecord.get("i"); if (parts != null) { for (byte[] part : parts) { id.insert(0, Hex.encodeHexString(part) + "_id"); } } id.append(Hex.encodeHexString((byte[]) deltaId) + "_id"); return id.toString(); } else { throw new IllegalArgumentException("Illegal id: " + deltaId); } }
DeltaJournal implements InitializingBean { public static String getEntityId(Map<String, Object> deltaRecord) { Object deltaId = deltaRecord.get("_id"); if(deltaId instanceof String){ return (String) deltaId; } else if (deltaId instanceof byte[]) { StringBuilder id = new StringBuilder(""); @SuppressWarnings("unchecked") List<byte[]> parts = (List<byte[]>) deltaRecord.get("i"); if (parts != null) { for (byte[] part : parts) { id.insert(0, Hex.encodeHexString(part) + "_id"); } } id.append(Hex.encodeHexString((byte[]) deltaId) + "_id"); return id.toString(); } else { throw new IllegalArgumentException("Illegal id: " + deltaId); } } }
DeltaJournal implements InitializingBean { public static String getEntityId(Map<String, Object> deltaRecord) { Object deltaId = deltaRecord.get("_id"); if(deltaId instanceof String){ return (String) deltaId; } else if (deltaId instanceof byte[]) { StringBuilder id = new StringBuilder(""); @SuppressWarnings("unchecked") List<byte[]> parts = (List<byte[]>) deltaRecord.get("i"); if (parts != null) { for (byte[] part : parts) { id.insert(0, Hex.encodeHexString(part) + "_id"); } } id.append(Hex.encodeHexString((byte[]) deltaId) + "_id"); return id.toString(); } else { throw new IllegalArgumentException("Illegal id: " + deltaId); } }  }
DeltaJournal implements InitializingBean { public static String getEntityId(Map<String, Object> deltaRecord) { Object deltaId = deltaRecord.get("_id"); if(deltaId instanceof String){ return (String) deltaId; } else if (deltaId instanceof byte[]) { StringBuilder id = new StringBuilder(""); @SuppressWarnings("unchecked") List<byte[]> parts = (List<byte[]>) deltaRecord.get("i"); if (parts != null) { for (byte[] part : parts) { id.insert(0, Hex.encodeHexString(part) + "_id"); } } id.append(Hex.encodeHexString((byte[]) deltaId) + "_id"); return id.toString(); } else { throw new IllegalArgumentException("Illegal id: " + deltaId); } }  @Override void afterPropertiesSet(); void journal(Collection<String> ids, String collection, boolean isDelete); static List<byte[]> getByteId(String id); static String getEntityId(Map<String, Object> deltaRecord); void journal(String id, String collection, boolean isDelete); void journalCollapsedSubDocs(Collection<String> ids, String collection); void journalPurge(long timeOfPurge); Iterator<Map<String, Object>> findDeltaRecordBetween(final long start, final long end); void removeDeltaJournals(String tenant, long cleanUptoTime); }
DeltaJournal implements InitializingBean { public static String getEntityId(Map<String, Object> deltaRecord) { Object deltaId = deltaRecord.get("_id"); if(deltaId instanceof String){ return (String) deltaId; } else if (deltaId instanceof byte[]) { StringBuilder id = new StringBuilder(""); @SuppressWarnings("unchecked") List<byte[]> parts = (List<byte[]>) deltaRecord.get("i"); if (parts != null) { for (byte[] part : parts) { id.insert(0, Hex.encodeHexString(part) + "_id"); } } id.append(Hex.encodeHexString((byte[]) deltaId) + "_id"); return id.toString(); } else { throw new IllegalArgumentException("Illegal id: " + deltaId); } }  @Override void afterPropertiesSet(); void journal(Collection<String> ids, String collection, boolean isDelete); static List<byte[]> getByteId(String id); static String getEntityId(Map<String, Object> deltaRecord); void journal(String id, String collection, boolean isDelete); void journalCollapsedSubDocs(Collection<String> ids, String collection); void journalPurge(long timeOfPurge); Iterator<Map<String, Object>> findDeltaRecordBetween(final long start, final long end); void removeDeltaJournals(String tenant, long cleanUptoTime); static final String DELTA_COLLECTION; static final String PURGE; }