Skip to content

Commit

Permalink
v1.14.0 (#213)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mfriesen authored Apr 3, 2024
1 parent 9f0ad33 commit d938221
Show file tree
Hide file tree
Showing 204 changed files with 43,850 additions and 25,157 deletions.
4 changes: 2 additions & 2 deletions actions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ dependencies {
testImplementation project(':dynamodb-documents')
testImplementation project(':fkq-test-utils')
testImplementation project(':fkq-plugins')
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.10.0'
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.19.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.10.1'
testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.19.4'
}

test {
Expand Down
6 changes: 5 additions & 1 deletion actions/src/main/java/com/formkiq/module/actions/Action.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

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

@Override
public Map<String, AttributeValue> getDataAttributes() {
return null;
}

private Date getDate(final SimpleDateFormat df, final Map<String, AttributeValue> attrs,
final String key) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public Map<String, AttributeValue> getAttributes(final String siteIdParam) {
return map;
}

@Override
public Map<String, AttributeValue> getDataAttributes() {
return null;
}

@Override
public DocumentWorkflowRecord getFromAttributes(final String siteIdParam,
final Map<String, AttributeValue> attrs) {
Expand Down
188 changes: 188 additions & 0 deletions actions/src/main/java/com/formkiq/module/actions/Queue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
/**
* MIT License
*
* Copyright (c) 2018 - 2020 FormKiQ
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.formkiq.module.actions;

import static com.formkiq.aws.dynamodb.SiteIdKeyGenerator.createDatabaseKey;
import java.util.HashMap;
import java.util.Map;
import com.formkiq.aws.dynamodb.DbKeys;
import com.formkiq.aws.dynamodb.DynamodbRecord;
import com.formkiq.graalvm.annotations.Reflectable;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;

/**
*
* Queue object.
*
*/
@Reflectable
public class Queue implements DynamodbRecord<Queue> {

/** Queue Document Id. */
@Reflectable
private String documentId;
/** Record inserted date. */
/** Name of Queue. */
@Reflectable
private String name;
/** Transient Field. */
@Reflectable
private String queueId;

/**
* constructor.
*/
public Queue() {

}

/**
* Get Document Id.
*
* @return {@link String}
*/
public String documentId() {
return this.documentId;
}

/**
* Set Document Id.
*
* @param document {@link String}
* @return {@link Queue}
*/
public Queue documentId(final String document) {
this.documentId = document;
return this;
}

@Override
public Map<String, AttributeValue> getAttributes(final String siteId) {

Map<String, AttributeValue> map = new HashMap<>();

map.put(DbKeys.PK, fromS(pk(siteId)));
map.put(DbKeys.SK, fromS(sk()));
map.put(DbKeys.GSI1_PK, fromS(pkGsi1(siteId)));
map.put(DbKeys.GSI1_SK, fromS(skGsi1()));
map.put("documentId", fromS(this.documentId));
map.put("name", fromS(this.name));

return map;
}

@Override
public Map<String, AttributeValue> getDataAttributes() {
return null;
}

@Override
public Queue getFromAttributes(final String siteId, final Map<String, AttributeValue> attrs) {

Queue record = null;

if (!attrs.isEmpty()) {
record = new Queue().documentId(ss(attrs, "documentId")).name(ss(attrs, "name"));
}

return record;
}

/**
* Get Workflow Name.
*
* @return {@link String}
*/
public String name() {
return this.name;
}

/**
* Set Workflow Name.
*
* @param workflowName {@link String}
* @return {@link Queue}
*/
public Queue name(final String workflowName) {
this.name = workflowName;
return this;
}

@Override
public String pk(final String siteId) {
if (this.documentId == null) {
throw new IllegalArgumentException("'documentId' is required");
}
return createDatabaseKey(siteId, "queues#" + this.documentId);

}

@Override
public String pkGsi1(final String siteId) {
return createDatabaseKey(siteId, "queues#");
}

@Override
public String pkGsi2(final String siteId) {
return null;
}

/**
* Get Queue Id.
*
* @return {@link String}
*/
public String queueId() {
return this.queueId;
}

/**
* Set Queue Id.
*
* @param id {@link String}
* @return {@link Queue}
*/
public Queue queueId(final String id) {
this.queueId = id;
return this;
}

@Override
public String sk() {
return "queue";
}

@Override
public String skGsi1() {
if (this.name == null || this.documentId == null) {
throw new IllegalArgumentException("'name' and 'documentId' is required");
}
return "queue#" + this.name + "#" + this.documentId;
}

@Override
public String skGsi2() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ PaginationResults<String> findDocumentsWithStatus(String siteId, ActionStatus st
*/
List<Action> getActions(String siteId, String documentId);

/**
* Get {@link List} {@link Action} for a document.
*
* @param siteId {@link String}
* @param documentId {@link String}
* @param exclusiveStartKey {@link Map}
* @param limit int
* @return {@link PaginationResults} {@link Action}
*/
PaginationResults<Action> getActions(String siteId, String documentId,
Map<String, AttributeValue> exclusiveStartKey, int limit);

/**
* Whether SiteId / DocumentId combination has any actions.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ private void deleteAction(final String siteId, final Action action) {
@Override
public void deleteActions(final String siteId, final String documentId) {

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

for (Action action : actions) {

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

@Override
public List<Action> getActions(final String siteId, final String documentId) {
return queryActions(siteId, documentId, null, null);
return queryActions(siteId, documentId, null, null, null).getResults();
}

@Override
public PaginationResults<Action> getActions(final String siteId, final String documentId,
final Map<String, AttributeValue> exclusiveStartKey, final int limit) {
return queryActions(siteId, documentId, null, exclusiveStartKey, Integer.valueOf(limit));
}

@Override
public boolean hasActions(final String siteId, final String documentId) {
List<Action> actions = queryActions(siteId, documentId, Arrays.asList(PK), null);
List<Action> actions =
queryActions(siteId, documentId, Arrays.asList(PK), null, null).getResults();
return !actions.isEmpty();
}

Expand Down Expand Up @@ -223,10 +231,12 @@ public void insertBeforeAction(final String siteId, final String documentId,
* @param documentId {@link String}
* @param projectionExpression {@link List} {@link String}
* @param limit {@link Integer}
* @return {@link List} {@link Action}
* @param startKey {@link Map}
* @return {@link PaginationResults} {@link Action}
*/
private List<Action> queryActions(final String siteId, final String documentId,
final List<String> projectionExpression, final Integer limit) {
private PaginationResults<Action> queryActions(final String siteId, final String documentId,
final List<String> projectionExpression, final Map<String, AttributeValue> startKey,
final Integer limit) {

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

Builder q = QueryRequest.builder().tableName(this.documentTableName)
Builder q = QueryRequest.builder().tableName(this.documentTableName).exclusiveStartKey(startKey)
.keyConditionExpression(expression).expressionAttributeValues(values).limit(limit);

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

QueryResponse result = this.dbClient.query(q.build());
QueryResponse response = this.dbClient.query(q.build());

List<Action> actions =
response.items().stream().map(a -> new Action().getFromAttributes(siteId, a))
.sorted(new ActionIndexComparator()).collect(Collectors.toList());

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ public interface ActionsValidator {
/**
* Validates {@link Action}.
*
* @param siteId {@link String}
* @param action {@link Action}
* @param configs {@link DynamicObject}
* @return {@link Collection} {@link ValidationError}
*/
Collection<ValidationError> validation(Action action, DynamicObject configs);
Collection<ValidationError> validation(String siteId, Action action, DynamicObject configs);

/**
* Validates {@link List} {@link Action}.
*
* @param siteId {@link String}
* @param action {@link Action}
* @param configs {@link DynamicObject}
* @return {@link List} {@link Collection} {@link ValidationError}
*/
List<Collection<ValidationError>> validation(List<Action> action, DynamicObject configs);
List<Collection<ValidationError>> validation(String siteId, List<Action> action,
DynamicObject configs);
}
Loading

0 comments on commit d938221

Please sign in to comment.