2323 */
2424package com .formkiq .module .actions ;
2525
26+ import java .text .ParseException ;
27+ import java .text .SimpleDateFormat ;
28+ import java .util .Date ;
2629import java .util .HashMap ;
2730import java .util .Map ;
2831import com .formkiq .aws .dynamodb .DbKeys ;
2932import com .formkiq .aws .dynamodb .DynamodbRecord ;
33+ import com .formkiq .aws .dynamodb .objects .DateUtil ;
3034import com .formkiq .graalvm .annotations .Reflectable ;
3135import software .amazon .awssdk .services .dynamodb .model .AttributeValue ;
3236
@@ -59,6 +63,9 @@ public class DocumentWorkflowRecord implements DynamodbRecord<DocumentWorkflowRe
5963 /** Cuurent Workflow Name. */
6064 @ Reflectable
6165 private String workflowName ;
66+ /** Record inserted date. */
67+ @ Reflectable
68+ private Date insertedDate ;
6269
6370 /**
6471 * constructor.
@@ -161,6 +168,11 @@ public Map<String, AttributeValue> getAttributes(final String siteIdParam) {
161168 map .put ("actionSk" , AttributeValue .fromS (this .actionSk ));
162169 map .put ("currentStepId" , AttributeValue .fromS (this .currentStepId ));
163170
171+ if (this .insertedDate != null ) {
172+ SimpleDateFormat df = DateUtil .getIsoDateFormatter ();
173+ map .put ("inserteddate" , AttributeValue .fromS (df .format (this .insertedDate )));
174+ }
175+
164176 map .put (DbKeys .GSI1_PK , AttributeValue .fromS (pkGsi1 (siteIdParam )));
165177 map .put (DbKeys .GSI1_SK , AttributeValue .fromS (skGsi1 ()));
166178
@@ -184,6 +196,13 @@ public DocumentWorkflowRecord getFromAttributes(final String siteIdParam,
184196 .workflowName (ss (attrs , "workflowName" )).actionPk (ss (attrs , "actionPk" ))
185197 .actionSk (ss (attrs , "actionSk" )).currentStepId (ss (attrs , "currentStepId" ));
186198
199+ try {
200+ SimpleDateFormat df = DateUtil .getIsoDateFormatter ();
201+ record = record .insertedDate (df .parse (ss (attrs , "inserteddate" )));
202+ } catch (ParseException e ) {
203+ throw new IllegalArgumentException ("invalid 'inserteddate'" );
204+ }
205+
187206 return record ;
188207 }
189208
@@ -294,4 +313,24 @@ public DocumentWorkflowRecord workflowName(final String name) {
294313 this .workflowName = name ;
295314 return this ;
296315 }
316+
317+ /**
318+ * Get Inserted Date.
319+ *
320+ * @return {@link Date}
321+ */
322+ public Date insertedDate () {
323+ return this .insertedDate ;
324+ }
325+
326+ /**
327+ * Set Inserted Date.
328+ *
329+ * @param date {@link Date}
330+ * @return {@link DocumentWorkflowRecord}
331+ */
332+ public DocumentWorkflowRecord insertedDate (final Date date ) {
333+ this .insertedDate = date ;
334+ return this ;
335+ }
297336}
0 commit comments