protected static ModificationStatus getModificationStatus(final ModificationStatus currentStatus, final BaseDO<?> src, final String modifiedField) { HistoryService historyService = HistoryServiceManager.get().getHistoryService(); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); if (currentStatus == ModificationStatus.MAJOR || src instanceof AbstractHistorizableBaseDO == false || historyService.getNoHistoryProperties(emf, src.getClass()) .contains(modifiedField) == false) { return ModificationStatus.MAJOR; } return ModificationStatus.MINOR; }
public static boolean isHistorizable(Class<?> clazz) { long begin = System.currentTimeMillis(); boolean result = HistoryServiceManager.get().getHistoryService().hasHistory(clazz); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.isHistorizable took: " + (end - begin) + " ms."); return result; }
public static List<? extends HistoryEntry> getHistoryEntries(BaseDO<?> ob) { long begin = System.currentTimeMillis(); HistoryService histservice = HistoryServiceManager.get().getHistoryService(); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); List<? extends HistoryEntry> ret = emf.runInTrans((emgr) -> { return histservice.getHistoryEntries(emgr, ob); }); List<? extends HistoryEntry> nret = ret.stream() .sorted((e1, e2) -> e2.getModifiedAt().compareTo(e1.getModifiedAt())).collect(Collectors.toList()); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.getHistoryEntries took: " + (end - begin) + " ms."); return nret; }
@Override protected void registerEvents() { super.registerEvents(); HistoryService historyService = HistoryServiceManager.get().getHistoryService(); historyService.registerEmgrListener(this); historyService.registerStandardHistoryPropertyConverter(this); }
final List<WithHistory> whanots = historyService.internalFindWithHistoryEntity(dbo); if (whanots.isEmpty() == true) { return callback.get(); entity -> { final HistoryProperties p = getOrCreateHistoryProperties(props, entity); p.oldProps = historyService.internalGetPropertiesForHistory(emgr, whanots, entity); entity -> { final HistoryProperties p = getOrCreateHistoryProperties(props, entity); p.newProps = historyService.internalGetPropertiesForHistory(emgr, whanots, entity); (pk, p) -> { if (p.oldProps != null && p.newProps != null) { historyService.internalOnUpdate(emgr, p.entClassName, pk, p.oldProps, p.newProps);
public static void createHistoryEntry(Object entity, Number id, String user, String property, Class<?> valueClass, Object oldValue, Object newValue) { long begin = System.currentTimeMillis(); String oldVals = histValueToString(valueClass, oldValue); String newVals = histValueToString(valueClass, newValue); PfEmgrFactory emf = ApplicationContextProvider.getApplicationContext().getBean(PfEmgrFactory.class); emf.runInTrans((emgr) -> { HistoryServiceManager.get().getHistoryService().insertManualEntry(emgr, EntityOpType.Update, entity.getClass().getName(), id, user, property, valueClass.getName(), oldVals, newVals); return null; }); long end = System.currentTimeMillis(); log.info("HistoryBaseDaoAdapter.createHistoryEntry took: " + (end - begin) + " ms."); }
boolean entWithHistory = HistoryServiceManager.get().getHistoryService().hasHistory(getBaseDao().getEntityClass()); showHistory = entWithHistory; if (entWithHistory == true) {
@Test public void testNonHistorizableProperties() { final TaskDO task = new TaskDO(); Set<String> set = HistoryServiceManager.get().getHistoryService().getNoHistoryProperties(emf, task.getClass()); Assert.assertEquals(2, set.size()); Assert.assertTrue(set.contains("lastUpdate")); Assert.assertTrue(set.contains("created")); Assert.assertTrue(set.contains("lastUpdate")); Assert.assertTrue(set.contains("created")); Assert.assertFalse(set.contains("title")); final AuftragDO order = new AuftragDO(); set = HistoryServiceManager.get().getHistoryService().getNoHistoryProperties(emf, order.getClass()); Assert.assertEquals(3, set.size()); // not, because ransient Assert.assertTrue(set.contains("uiStatus")); Assert.assertTrue(set.contains("uiStatusAsXml")); Assert.assertFalse(set.contains("subject")); } }