Skip to content

Issue 53091: Don't include calculated aliquot rollup columns in audit details #6819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions api/src/org/labkey/api/audit/SampleTimelineAuditEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public class SampleTimelineAuditEvent extends DetailedAuditTypeEvent
{
public static final String EVENT_TYPE = "SampleTimelineEvent";

public static final String SAMPLE_TIMELINE_EVENT_TYPE = "SampleTimelineEventType";

public static final Set<String> EXCLUDED_DETAIL_FIELDS = Set.of("AvailableAliquotVolume", "AvailableAliquotCount", "AliquotCount", "AliquotVolume", "AliquotUnit");

public enum SampleTimelineEventType
{
INSERT("Sample was registered.", "Registered"),
Expand Down Expand Up @@ -196,14 +199,16 @@ public Map<String, Object> 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)
{
if (oldRecordMap != null)
{
Map<String, String> row = new CaseInsensitiveHashMap<>(AbstractAuditTypeProvider.decodeFromDataMap(oldRecordMap));
EXCLUDED_DETAIL_FIELDS.forEach(row::remove);
String label = getStatusLabel(row, container);
if (label != null)
{
Expand All @@ -216,20 +221,20 @@ 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)
{
if (newRecordMap != null)
{
Map<String, String> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,11 @@ public void testDetailedAuditLog() throws Exception
Map<String,String> 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();
Expand Down