Skip to content

Commit de87aa4

Browse files
committed
update
1 parent 0004bb9 commit de87aa4

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

actions/src/main/java/com/formkiq/module/actions/DocumentWorkflowRecord.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@
2323
*/
2424
package com.formkiq.module.actions;
2525

26+
import java.text.ParseException;
27+
import java.text.SimpleDateFormat;
28+
import java.util.Date;
2629
import java.util.HashMap;
2730
import java.util.Map;
2831
import com.formkiq.aws.dynamodb.DbKeys;
2932
import com.formkiq.aws.dynamodb.DynamodbRecord;
33+
import com.formkiq.aws.dynamodb.objects.DateUtil;
3034
import com.formkiq.graalvm.annotations.Reflectable;
3135
import 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

Comments
 (0)