Skip to content

Commit d938221

Browse files
authored
v1.14.0 (#213)
Features * #203 - Add /objects/examine/pdf endpoints for getting metadata from PDF * #214 - Document Rulesets (/rulesets) API * #28 - add limit parameter to /documents/{id}/versions * #209 - Add next and limit to GET /document/{id}/actions endpoint * #30 - Move OPA and other configuration options into /sites resource * #212 - /search add range queries * Update Console to v3.4.0 Bugs * #204 - Template may not exceed 1000000 bytes in size * #205 - VPC CloudFormation Templates fails in ca-central-1 * Fulltext Action handling when document doesn't exist in Opensearch
1 parent 9f0ad33 commit d938221

File tree

204 files changed

+43850
-25157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+43850
-25157
lines changed

actions/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ dependencies {
1616
testImplementation project(':dynamodb-documents')
1717
testImplementation project(':fkq-test-utils')
1818
testImplementation project(':fkq-plugins')
19-
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.10.0'
20-
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.19.0'
19+
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.10.1'
20+
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.19.4'
2121
}
2222

2323
test {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import static com.formkiq.aws.dynamodb.SiteIdKeyGenerator.createDatabaseKey;
2727
import static com.formkiq.aws.dynamodb.objects.Strings.isEmpty;
28-
import static software.amazon.awssdk.services.dynamodb.model.AttributeValue.fromS;
2928
import java.text.ParseException;
3029
import java.text.SimpleDateFormat;
3130
import java.util.Date;
@@ -186,6 +185,11 @@ public Map<String, AttributeValue> getAttributes(final String siteId) {
186185
return attrs;
187186
}
188187

188+
@Override
189+
public Map<String, AttributeValue> getDataAttributes() {
190+
return null;
191+
}
192+
189193
private Date getDate(final SimpleDateFormat df, final Map<String, AttributeValue> attrs,
190194
final String key) {
191195

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ public Map<String, AttributeValue> getAttributes(final String siteIdParam) {
170170
return map;
171171
}
172172

173+
@Override
174+
public Map<String, AttributeValue> getDataAttributes() {
175+
return null;
176+
}
177+
173178
@Override
174179
public DocumentWorkflowRecord getFromAttributes(final String siteIdParam,
175180
final Map<String, AttributeValue> attrs) {
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/**
2+
* MIT License
3+
*
4+
* Copyright (c) 2018 - 2020 FormKiQ
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.formkiq.module.actions;
25+
26+
import static com.formkiq.aws.dynamodb.SiteIdKeyGenerator.createDatabaseKey;
27+
import java.util.HashMap;
28+
import java.util.Map;
29+
import com.formkiq.aws.dynamodb.DbKeys;
30+
import com.formkiq.aws.dynamodb.DynamodbRecord;
31+
import com.formkiq.graalvm.annotations.Reflectable;
32+
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
33+
34+
/**
35+
*
36+
* Queue object.
37+
*
38+
*/
39+
@Reflectable
40+
public class Queue implements DynamodbRecord<Queue> {
41+
42+
/** Queue Document Id. */
43+
@Reflectable
44+
private String documentId;
45+
/** Record inserted date. */
46+
/** Name of Queue. */
47+
@Reflectable
48+
private String name;
49+
/** Transient Field. */
50+
@Reflectable
51+
private String queueId;
52+
53+
/**
54+
* constructor.
55+
*/
56+
public Queue() {
57+
58+
}
59+
60+
/**
61+
* Get Document Id.
62+
*
63+
* @return {@link String}
64+
*/
65+
public String documentId() {
66+
return this.documentId;
67+
}
68+
69+
/**
70+
* Set Document Id.
71+
*
72+
* @param document {@link String}
73+
* @return {@link Queue}
74+
*/
75+
public Queue documentId(final String document) {
76+
this.documentId = document;
77+
return this;
78+
}
79+
80+
@Override
81+
public Map<String, AttributeValue> getAttributes(final String siteId) {
82+
83+
Map<String, AttributeValue> map = new HashMap<>();
84+
85+
map.put(DbKeys.PK, fromS(pk(siteId)));
86+
map.put(DbKeys.SK, fromS(sk()));
87+
map.put(DbKeys.GSI1_PK, fromS(pkGsi1(siteId)));
88+
map.put(DbKeys.GSI1_SK, fromS(skGsi1()));
89+
map.put("documentId", fromS(this.documentId));
90+
map.put("name", fromS(this.name));
91+
92+
return map;
93+
}
94+
95+
@Override
96+
public Map<String, AttributeValue> getDataAttributes() {
97+
return null;
98+
}
99+
100+
@Override
101+
public Queue getFromAttributes(final String siteId, final Map<String, AttributeValue> attrs) {
102+
103+
Queue record = null;
104+
105+
if (!attrs.isEmpty()) {
106+
record = new Queue().documentId(ss(attrs, "documentId")).name(ss(attrs, "name"));
107+
}
108+
109+
return record;
110+
}
111+
112+
/**
113+
* Get Workflow Name.
114+
*
115+
* @return {@link String}
116+
*/
117+
public String name() {
118+
return this.name;
119+
}
120+
121+
/**
122+
* Set Workflow Name.
123+
*
124+
* @param workflowName {@link String}
125+
* @return {@link Queue}
126+
*/
127+
public Queue name(final String workflowName) {
128+
this.name = workflowName;
129+
return this;
130+
}
131+
132+
@Override
133+
public String pk(final String siteId) {
134+
if (this.documentId == null) {
135+
throw new IllegalArgumentException("'documentId' is required");
136+
}
137+
return createDatabaseKey(siteId, "queues#" + this.documentId);
138+
139+
}
140+
141+
@Override
142+
public String pkGsi1(final String siteId) {
143+
return createDatabaseKey(siteId, "queues#");
144+
}
145+
146+
@Override
147+
public String pkGsi2(final String siteId) {
148+
return null;
149+
}
150+
151+
/**
152+
* Get Queue Id.
153+
*
154+
* @return {@link String}
155+
*/
156+
public String queueId() {
157+
return this.queueId;
158+
}
159+
160+
/**
161+
* Set Queue Id.
162+
*
163+
* @param id {@link String}
164+
* @return {@link Queue}
165+
*/
166+
public Queue queueId(final String id) {
167+
this.queueId = id;
168+
return this;
169+
}
170+
171+
@Override
172+
public String sk() {
173+
return "queue";
174+
}
175+
176+
@Override
177+
public String skGsi1() {
178+
if (this.name == null || this.documentId == null) {
179+
throw new IllegalArgumentException("'name' and 'documentId' is required");
180+
}
181+
return "queue#" + this.name + "#" + this.documentId;
182+
}
183+
184+
@Override
185+
public String skGsi2() {
186+
return null;
187+
}
188+
}

actions/src/main/java/com/formkiq/module/actions/services/ActionsService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ PaginationResults<String> findDocumentsWithStatus(String siteId, ActionStatus st
8888
*/
8989
List<Action> getActions(String siteId, String documentId);
9090

91+
/**
92+
* Get {@link List} {@link Action} for a document.
93+
*
94+
* @param siteId {@link String}
95+
* @param documentId {@link String}
96+
* @param exclusiveStartKey {@link Map}
97+
* @param limit int
98+
* @return {@link PaginationResults} {@link Action}
99+
*/
100+
PaginationResults<Action> getActions(String siteId, String documentId,
101+
Map<String, AttributeValue> exclusiveStartKey, int limit);
102+
91103
/**
92104
* Whether SiteId / DocumentId combination has any actions.
93105
*

actions/src/main/java/com/formkiq/module/actions/services/ActionsServiceDynamoDb.java

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ private void deleteAction(final String siteId, final Action action) {
110110
@Override
111111
public void deleteActions(final String siteId, final String documentId) {
112112

113-
List<Action> actions = queryActions(siteId, documentId, Arrays.asList(PK, SK, "type"), null);
113+
List<Action> actions =
114+
queryActions(siteId, documentId, Arrays.asList(PK, SK, "type"), null, null).getResults();
114115

115116
for (Action action : actions) {
116117

@@ -189,12 +190,19 @@ public PaginationResults<String> findDocumentsWithStatus(final String siteId,
189190

190191
@Override
191192
public List<Action> getActions(final String siteId, final String documentId) {
192-
return queryActions(siteId, documentId, null, null);
193+
return queryActions(siteId, documentId, null, null, null).getResults();
194+
}
195+
196+
@Override
197+
public PaginationResults<Action> getActions(final String siteId, final String documentId,
198+
final Map<String, AttributeValue> exclusiveStartKey, final int limit) {
199+
return queryActions(siteId, documentId, null, exclusiveStartKey, Integer.valueOf(limit));
193200
}
194201

195202
@Override
196203
public boolean hasActions(final String siteId, final String documentId) {
197-
List<Action> actions = queryActions(siteId, documentId, Arrays.asList(PK), null);
204+
List<Action> actions =
205+
queryActions(siteId, documentId, Arrays.asList(PK), null, null).getResults();
198206
return !actions.isEmpty();
199207
}
200208

@@ -223,10 +231,12 @@ public void insertBeforeAction(final String siteId, final String documentId,
223231
* @param documentId {@link String}
224232
* @param projectionExpression {@link List} {@link String}
225233
* @param limit {@link Integer}
226-
* @return {@link List} {@link Action}
234+
* @param startKey {@link Map}
235+
* @return {@link PaginationResults} {@link Action}
227236
*/
228-
private List<Action> queryActions(final String siteId, final String documentId,
229-
final List<String> projectionExpression, final Integer limit) {
237+
private PaginationResults<Action> queryActions(final String siteId, final String documentId,
238+
final List<String> projectionExpression, final Map<String, AttributeValue> startKey,
239+
final Integer limit) {
230240

231241
String pk = new Action().documentId(documentId).pk(siteId);
232242
String sk = "action" + TAG_DELIMINATOR;
@@ -235,7 +245,7 @@ private List<Action> queryActions(final String siteId, final String documentId,
235245
Map<String, AttributeValue> values = Map.of(":pk", AttributeValue.builder().s(pk).build(),
236246
":sk", AttributeValue.builder().s(sk).build());
237247

238-
Builder q = QueryRequest.builder().tableName(this.documentTableName)
248+
Builder q = QueryRequest.builder().tableName(this.documentTableName).exclusiveStartKey(startKey)
239249
.keyConditionExpression(expression).expressionAttributeValues(values).limit(limit);
240250

241251
if (!Objects.notNull(projectionExpression).isEmpty()) {
@@ -250,10 +260,14 @@ private List<Action> queryActions(final String siteId, final String documentId,
250260
q = q.projectionExpression(String.join(",", names.keySet())).expressionAttributeNames(names);
251261
}
252262

253-
QueryResponse result = this.dbClient.query(q.build());
263+
QueryResponse response = this.dbClient.query(q.build());
264+
265+
List<Action> actions =
266+
response.items().stream().map(a -> new Action().getFromAttributes(siteId, a))
267+
.sorted(new ActionIndexComparator()).collect(Collectors.toList());
254268

255-
return result.items().stream().map(a -> new Action().getFromAttributes(siteId, a))
256-
.sorted(new ActionIndexComparator()).collect(Collectors.toList());
269+
PaginationMapToken pagination = new QueryResponseToPagination().apply(response);
270+
return new PaginationResults<>(actions, pagination);
257271
}
258272

259273
@Override

actions/src/main/java/com/formkiq/module/actions/services/ActionsValidator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,21 @@ public interface ActionsValidator {
3939
/**
4040
* Validates {@link Action}.
4141
*
42+
* @param siteId {@link String}
4243
* @param action {@link Action}
4344
* @param configs {@link DynamicObject}
4445
* @return {@link Collection} {@link ValidationError}
4546
*/
46-
Collection<ValidationError> validation(Action action, DynamicObject configs);
47+
Collection<ValidationError> validation(String siteId, Action action, DynamicObject configs);
4748

4849
/**
4950
* Validates {@link List} {@link Action}.
5051
*
52+
* @param siteId {@link String}
5153
* @param action {@link Action}
5254
* @param configs {@link DynamicObject}
5355
* @return {@link List} {@link Collection} {@link ValidationError}
5456
*/
55-
List<Collection<ValidationError>> validation(List<Action> action, DynamicObject configs);
57+
List<Collection<ValidationError>> validation(String siteId, List<Action> action,
58+
DynamicObject configs);
5659
}

0 commit comments

Comments
 (0)