11
11
12
12
import java .util .LinkedHashMap ;
13
13
import java .util .Map ;
14
+ import java .util .Set ;
14
15
15
16
public class SampleTimelineAuditEvent extends DetailedAuditTypeEvent
16
17
{
17
18
public static final String EVENT_TYPE = "SampleTimelineEvent" ;
18
19
19
20
public static final String SAMPLE_TIMELINE_EVENT_TYPE = "SampleTimelineEventType" ;
20
21
22
+ public static final Set <String > EXCLUDED_DETAIL_FIELDS = Set .of ("AvailableAliquotVolume" , "AvailableAliquotCount" , "AliquotCount" , "AliquotVolume" , "AliquotUnit" );
23
+
21
24
public enum SampleTimelineEventType
22
25
{
23
26
INSERT ("Sample was registered." , "Registered" ),
@@ -196,14 +199,16 @@ public Map<String, Object> getAuditLogMessageElements()
196
199
197
200
/**
198
201
* 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.
200
204
*/
201
205
@ Override
202
206
public void setOldRecordMap (String oldRecordMap , Container container )
203
207
{
204
208
if (oldRecordMap != null )
205
209
{
206
210
Map <String , String > row = new CaseInsensitiveHashMap <>(AbstractAuditTypeProvider .decodeFromDataMap (oldRecordMap ));
211
+ EXCLUDED_DETAIL_FIELDS .forEach (row ::remove );
207
212
String label = getStatusLabel (row , container );
208
213
if (label != null )
209
214
{
@@ -216,20 +221,20 @@ public void setOldRecordMap(String oldRecordMap, Container container)
216
221
217
222
/**
218
223
* 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.
220
226
*/
221
227
@ Override
222
228
public void setNewRecordMap (String newRecordMap , Container container )
223
229
{
224
230
if (newRecordMap != null )
225
231
{
226
232
Map <String , String > row = new CaseInsensitiveHashMap <>(AbstractAuditTypeProvider .decodeFromDataMap (newRecordMap ));
233
+ EXCLUDED_DETAIL_FIELDS .forEach (row ::remove );
227
234
String label = getStatusLabel (row , container );
228
235
if (label != null )
229
- {
230
236
row .put ("samplestatelabel" , label );
231
- newRecordMap = AbstractAuditTypeProvider .encodeForDataMap (row );
232
- }
237
+ newRecordMap = AbstractAuditTypeProvider .encodeForDataMap (row );
233
238
}
234
239
super .setNewRecordMap (newRecordMap , container );
235
240
}
0 commit comments