Skip to content

Commit d67c71b

Browse files
Issue 53091: Don't include calculated aliquot rollup columns in audit details (#6819)
1 parent 4935d72 commit d67c71b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111

1212
import java.util.LinkedHashMap;
1313
import java.util.Map;
14+
import java.util.Set;
1415

1516
public class SampleTimelineAuditEvent extends DetailedAuditTypeEvent
1617
{
1718
public static final String EVENT_TYPE = "SampleTimelineEvent";
1819

1920
public static final String SAMPLE_TIMELINE_EVENT_TYPE = "SampleTimelineEventType";
2021

22+
public static final Set<String> EXCLUDED_DETAIL_FIELDS = Set.of("AvailableAliquotVolume", "AvailableAliquotCount", "AliquotCount", "AliquotVolume", "AliquotUnit");
23+
2124
public enum SampleTimelineEventType
2225
{
2326
INSERT("Sample was registered.", "Registered"),
@@ -196,14 +199,16 @@ public Map<String, Object> getAuditLogMessageElements()
196199

197200
/**
198201
* If the sample state changed, explicitly add in the Status Label value to the map so that it will render in the
199-
* audit log timeline event even if the DataState row is later deleted.
202+
* audit log timeline event even if the DataState row is later deleted. Also, remove the aliquot rollup calculated
203+
* fields from the data.
200204
*/
201205
@Override
202206
public void setOldRecordMap(String oldRecordMap, Container container)
203207
{
204208
if (oldRecordMap != null)
205209
{
206210
Map<String, String> row = new CaseInsensitiveHashMap<>(AbstractAuditTypeProvider.decodeFromDataMap(oldRecordMap));
211+
EXCLUDED_DETAIL_FIELDS.forEach(row::remove);
207212
String label = getStatusLabel(row, container);
208213
if (label != null)
209214
{
@@ -216,20 +221,20 @@ public void setOldRecordMap(String oldRecordMap, Container container)
216221

217222
/**
218223
* If the sample state changed, explicitly add in the Status Label value to the map so that it will render in the
219-
* audit log timeline event even if the DataState row is later deleted.
224+
* audit log timeline event even if the DataState row is later deleted. Also, remove the aliquot rollup calculated
225+
* fields from the data.
220226
*/
221227
@Override
222228
public void setNewRecordMap(String newRecordMap, Container container)
223229
{
224230
if (newRecordMap != null)
225231
{
226232
Map<String, String> row = new CaseInsensitiveHashMap<>(AbstractAuditTypeProvider.decodeFromDataMap(newRecordMap));
233+
EXCLUDED_DETAIL_FIELDS.forEach(row::remove);
227234
String label = getStatusLabel(row, container);
228235
if (label != null)
229-
{
230236
row.put("samplestatelabel", label);
231-
newRecordMap = AbstractAuditTypeProvider.encodeForDataMap(row);
232-
}
237+
newRecordMap = AbstractAuditTypeProvider.encodeForDataMap(row);
233238
}
234239
super.setNewRecordMap(newRecordMap, container);
235240
}

experiment/src/org/labkey/experiment/api/ExpSampleTypeTestCase.jsp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,11 @@ public void testDetailedAuditLog() throws Exception
10221022
Map<String,String> newRecordMap = new CaseInsensitiveHashMap<>(PageFlowUtil.mapFromQueryString(events.get(0).getNewRecordMap()));
10231023
assertEquals("Initial", newRecordMap.get("Measure"));
10241024
assertEquals("1.0", newRecordMap.get("Value"));
1025-
assertEquals("0", newRecordMap.get("AliquotCount"));
1026-
assertEquals("0.0", newRecordMap.get("AliquotVolume"));
1025+
assertNull(newRecordMap.get("AliquotCount"));
1026+
assertNull(newRecordMap.get("AliquotVolume"));
1027+
assertNull(newRecordMap.get("AvailableAliquotVolume"));
1028+
assertNull(newRecordMap.get("AvailableAliquotCount"));
1029+
assertNull(newRecordMap.get("AliquotUnit"));
10271030
10281031
// UPDATE
10291032
rows.clear(); errors.clear();

0 commit comments

Comments
 (0)