From 41a517928cc0388b698953ac5243c49f4055045d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Sch=C3=B6neberg?= Date: Mon, 26 Aug 2019 17:21:07 +0200 Subject: [PATCH] 5447-app - Optionally include C_Location changes.. bugfix; avoid NPE if C_Location changes were the only changes https://github.com/metasfresh/metasfresh/issues/5447 (cherry picked from commit 38d12c41790a4b0c4a7d42d77fcc9d03e5ae6d31) --- .../ad/table/RecordChangeLogEntryLoader.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/table/RecordChangeLogEntryLoader.java b/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/table/RecordChangeLogEntryLoader.java index 5fcdea844ab..befb467e5c5 100644 --- a/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/table/RecordChangeLogEntryLoader.java +++ b/de.metas.adempiere.adempiere/base/src/main/java/org/adempiere/ad/table/RecordChangeLogEntryLoader.java @@ -123,8 +123,8 @@ public static ImmutableListMultimap for (final TableRecordReference recordRef : locationRecords.keySet()) { - final List locationLogEntries = deriveLocationLogEntries(locationRecords.get(recordRef)); - intermediateResult.get(recordRef).addAll(locationLogEntries); + final List derivedLocationEntries = deriveLocationLogEntries(recordRef, locationRecords.get(recordRef)); + addAllToIntermediateResult(derivedLocationEntries, intermediateResult); } } else @@ -229,16 +229,17 @@ private static ImmutableListMultimap extract } /** - * @param unOrderedLocationRecords may or may not be ordered + * @param unOrderedLocationRecords {@link I_C_Location} records that are referenced from the change log of {@code recordRef}; may or may not be ordered. */ - private static ImmutableList deriveLocationLogEntries( + private static ImmutableList deriveLocationLogEntries( + @NonNull final TableRecordReference recordRef, @NonNull final ImmutableList unOrderedLocationRecords) { // Also if there was only only one C_Location_ID changelog, we have already 2 I_C_Locations, because we also got the first changelog's oldValue. assume(unOrderedLocationRecords.size() >= 2, "Parameter 'unOrderedLocationRecords' needs to contain at least 2 items; unOrderedLocationRecords={}", unOrderedLocationRecords); final POInfo poInfo = POInfo.getPOInfo(I_C_Location.Table_Name); - final ImmutableList.Builder result = ImmutableList.builder(); + final ImmutableList.Builder result = ImmutableList.builder(); final ArrayList orderedLocationRecords = new ArrayList<>(unOrderedLocationRecords); Collections.sort(orderedLocationRecords, Comparator.comparing(I_C_Location::getCreated)); @@ -279,7 +280,7 @@ private static ImmutableList deriveLocationLogEntries( .valueNew(newValue) .valueOld(oldValue) .build(); - result.add(logEntry); + result.add(new RecordRefWithLogEntry(recordRef, logEntry)); } } return result.build();