diff --git a/api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java b/api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java index 5c072c8a414..4af2814acb1 100644 --- a/api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java +++ b/api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java @@ -11,6 +11,7 @@ import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; public class SampleTimelineAuditEvent extends DetailedAuditTypeEvent { @@ -18,6 +19,8 @@ public class SampleTimelineAuditEvent extends DetailedAuditTypeEvent public static final String SAMPLE_TIMELINE_EVENT_TYPE = "SampleTimelineEventType"; + public static final Set EXCLUDED_DETAIL_FIELDS = Set.of("AvailableAliquotVolume", "AvailableAliquotCount", "AliquotCount", "AliquotVolume", "AliquotUnit"); + public enum SampleTimelineEventType { INSERT("Sample was registered.", "Registered"), @@ -196,7 +199,8 @@ public Map getAuditLogMessageElements() /** * If the sample state changed, explicitly add in the Status Label value to the map so that it will render in the - * audit log timeline event even if the DataState row is later deleted. + * audit log timeline event even if the DataState row is later deleted. Also, remove the aliquot rollup calculated + * fields from the data. */ @Override public void setOldRecordMap(String oldRecordMap, Container container) @@ -204,6 +208,7 @@ public void setOldRecordMap(String oldRecordMap, Container container) if (oldRecordMap != null) { Map row = new CaseInsensitiveHashMap<>(AbstractAuditTypeProvider.decodeFromDataMap(oldRecordMap)); + EXCLUDED_DETAIL_FIELDS.forEach(row::remove); String label = getStatusLabel(row, container); if (label != null) { @@ -216,7 +221,8 @@ public void setOldRecordMap(String oldRecordMap, Container container) /** * If the sample state changed, explicitly add in the Status Label value to the map so that it will render in the - * audit log timeline event even if the DataState row is later deleted. + * audit log timeline event even if the DataState row is later deleted. Also, remove the aliquot rollup calculated + * fields from the data. */ @Override public void setNewRecordMap(String newRecordMap, Container container) @@ -224,12 +230,11 @@ public void setNewRecordMap(String newRecordMap, Container container) if (newRecordMap != null) { Map row = new CaseInsensitiveHashMap<>(AbstractAuditTypeProvider.decodeFromDataMap(newRecordMap)); + EXCLUDED_DETAIL_FIELDS.forEach(row::remove); String label = getStatusLabel(row, container); if (label != null) - { row.put("samplestatelabel", label); - newRecordMap = AbstractAuditTypeProvider.encodeForDataMap(row); - } + newRecordMap = AbstractAuditTypeProvider.encodeForDataMap(row); } super.setNewRecordMap(newRecordMap, container); } diff --git a/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp b/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp index e29b51d00b6..f34bfb8a7a9 100644 --- a/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp +++ b/experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp @@ -1022,8 +1022,11 @@ public void testDetailedAuditLog() throws Exception Map newRecordMap = new CaseInsensitiveHashMap<>(PageFlowUtil.mapFromQueryString(events.get(0).getNewRecordMap())); assertEquals("Initial", newRecordMap.get("Measure")); assertEquals("1.0", newRecordMap.get("Value")); - assertEquals("0", newRecordMap.get("AliquotCount")); - assertEquals("0.0", newRecordMap.get("AliquotVolume")); + assertNull(newRecordMap.get("AliquotCount")); + assertNull(newRecordMap.get("AliquotVolume")); + assertNull(newRecordMap.get("AvailableAliquotVolume")); + assertNull(newRecordMap.get("AvailableAliquotCount")); + assertNull(newRecordMap.get("AliquotUnit")); // UPDATE rows.clear(); errors.clear();