private void convertHistory(Map<String, Object> map, Base entity) { HistoryConverter historyConverter = new HistoryConverter(entity, fields, documentHistory, monitor); map.putAll(historyConverter.convert()); } }
private List<Object> createEventsList() { List<Object> list = new LinkedList<>(); for (HistoryEvent historyEvent : documentHistory.getHistory(entityInternalId)) { Map<String, Object> map = createEventMap(historyEvent); list.add(map); if (isMerged(historyEvent) && historyEvent.getParameters(HistoryEvents.PARAM_MERGED_ID).isPresent()) { addMergedEventsToList(list, historyEvent); } } return list; }
/** Add history to the map */ public Map<String, Object> convert() { Map<String, Object> map = new IgnoreEmptyKeyMapDecorator<>(new LinkedHashMap<>()); List<Object> list = createEventsList(); map.put(fields.getHistory(), list); return map; }
private void createEventsList(List<Object> list, Collection<HistoryEvent> mergedHistoryEvents) { for (HistoryEvent mergedHistoryEvent : mergedHistoryEvents) { Map<String, Object> map = createEventMap(mergedHistoryEvent); list.add(map); } }
private void addMergedEventsToList(List<Object> list, HistoryEvent historyEvent) { Optional<String> mergedId = historyEvent.getParameters(HistoryEvents.PARAM_MERGED_ID); Optional<Integer> id = mergedId.map(Ints::tryParse); if (id.isPresent()) { Collection<HistoryEvent> mergedEvents = documentHistory.getHistory(id.get()); if (mergedEvents != null) { createEventsList(list, mergedEvents); } else { monitor.warn("Null history for {}", id.get()); } } else { monitor.warn("No merge id for merge history of {}", historyEvent.getRecordable()); } }
new HistoryConverter( e, fields, getSupport().getDocumentHistory(jCas), getMonitor()); Map<String, Object> historyMap = converter.convert(); document.append(FIELD_HISTORY, historyMap);
when(documentHistory.getHistory(internalId)).thenReturn(historyEvents); historyConverter = new HistoryConverter(entity, fields, documentHistory, monitor); Map<String, Object> historyMap = historyConverter.convert(); historyList = (LinkedList<Object>) historyMap.get(HISTORY);