private static Optional<Date> findLastChangeOfEmployeeStatusInHistory(final EmployeeDO employee) { final Predicate<HistoryEntry> hasStatusChangeHistoryEntries = historyEntry -> ((HistoryEntry<?>) historyEntry) .getDiffEntries() .stream() .anyMatch( diffEntry -> diffEntry.getPropertyName().startsWith("status") ); return HistoryBaseDaoAdapter .getHistoryEntries(employee) .stream() .filter(hasStatusChangeHistoryEntries) .map(HistoryEntry::getModifiedAt) .findFirst(); // the history entries are already sorted by date } }
public List<DisplayHistoryEntry> convert(final HistoryEntry<?> entry, final Session session) { if (entry.getDiffEntries().isEmpty() == true) { final DisplayHistoryEntry se = new DisplayHistoryEntry(getUserGroupCache(), entry); return Collections.singletonList(se); } List<DisplayHistoryEntry> result = new ArrayList<>(); for (DiffEntry prop : entry.getDiffEntries()) { DisplayHistoryEntry se = new DisplayHistoryEntry(getUserGroupCache(), entry, prop, session); result.add(se); } return result; }
public static List<SimpleHistoryEntry> getSimpleHistoryEntries(final BaseDO<?> ob, UserGroupCache userGroupCache) { long begin = System.currentTimeMillis(); List<SimpleHistoryEntry> ret = new ArrayList<>(); List<? extends HistoryEntry> hel = getHistoryEntries(ob); for (HistoryEntry he : hel) { List<DiffEntry> deltas = he.getDiffEntries(); if (deltas.isEmpty() == true) { SimpleHistoryEntry se = new SimpleHistoryEntry(userGroupCache, he); ret.add(se); } else { for (DiffEntry de : deltas) { final SimpleHistoryEntry se = new SimpleHistoryEntry(userGroupCache, he, diffEntryToPropertyDelta(de)); ret.add(se); } } } long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.getSimpleHistoryEntries took: " + (end - begin) + " ms."); return ret; }
@Override public List<DisplayHistoryEntry> convert(final HistoryEntry<?> entry, final Session session) if (entry.getDiffEntries().isEmpty() == true) { final DisplayHistoryEntry se = new DisplayHistoryEntry(getUserGroupCache(), entry); return Collections.singletonList(se); for (DiffEntry prop : entry.getDiffEntries()) { DisplayHistoryEntry se = new DisplayHistoryEntry(getUserGroupCache(), entry, prop, session)