From 1647be9f390fccc2da0cc9e044f2e841a5029dcf Mon Sep 17 00:00:00 2001 From: Mikko Tiihonen Date: Mon, 27 Apr 2020 15:12:05 +0300 Subject: [PATCH] Move default query-archived state to constant(s) in base class --- CHANGELOG.md | 6 +++--- .../src/main/java/io/nflow/rest/v1/ResourceBase.java | 6 ++++-- .../io/nflow/rest/v1/jaxrs/WorkflowInstanceResource.java | 4 ++-- .../nflow/rest/v1/springweb/WorkflowInstanceResource.java | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17d1772b0..d68903acb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,11 @@ **Details** - `nflow-engine` - - Query interfaces allow to request searching of archived workflow instances. + - Query interfaces allow to request searching of archived workflow instances if not enough matches found from main tables. - `nflow-rest-api-jax-rs` and `nflow-rest-api-spring-web` - - Support for querying archived workflow instances when passing `queryArchive=true` query parameter. + - Support for querying archived workflow instances when passing `queryArchive=true` query parameter if not enough matches found from main tables. - `nflow-explorer` - - Query and show archived workflow instances by default. Configurable in `config.js`. + - Query and show archived workflow instances by default if not enough matches found from main tables. Configurable in `config.js`. ## 7.2.0 (2020-04-27) diff --git a/nflow-rest-api-common/src/main/java/io/nflow/rest/v1/ResourceBase.java b/nflow-rest-api-common/src/main/java/io/nflow/rest/v1/ResourceBase.java index d0285e0c3..f633ba403 100644 --- a/nflow-rest-api-common/src/main/java/io/nflow/rest/v1/ResourceBase.java +++ b/nflow-rest-api-common/src/main/java/io/nflow/rest/v1/ResourceBase.java @@ -68,10 +68,12 @@ public abstract class ResourceBase { new SimpleEntry<>(actionStateVariables, WorkflowInstanceInclude.ACTION_STATE_VARIABLES), new SimpleEntry<>(childWorkflows, WorkflowInstanceInclude.CHILD_WORKFLOW_IDS)) .collect(toMap(Entry::getKey, Entry::getValue))); + protected static final String QUERY_ARCHIVED_DEFAULT_S = "false"; + protected static final boolean QUERY_ARCHIVED_DEFAULT = Boolean.parseBoolean(QUERY_ARCHIVED_DEFAULT_S); public List listWorkflowDefinitions(final List types, - final WorkflowDefinitionService workflowDefinitions, final ListWorkflowDefinitionConverter converter, - final WorkflowDefinitionDao workflowDefinitionDao) { + final WorkflowDefinitionService workflowDefinitions, final ListWorkflowDefinitionConverter converter, + final WorkflowDefinitionDao workflowDefinitionDao) { List> definitions = workflowDefinitions.getWorkflowDefinitions(); Set reqTypes = new HashSet<>(types); Set foundTypes = new HashSet<>(); diff --git a/nflow-rest-api-jax-rs/src/main/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResource.java b/nflow-rest-api-jax-rs/src/main/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResource.java index 9e139d886..e52b1d379 100644 --- a/nflow-rest-api-jax-rs/src/main/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResource.java +++ b/nflow-rest-api-jax-rs/src/main/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResource.java @@ -125,7 +125,7 @@ public Response fetchWorkflowInstance(@ApiParam("Internal id for workflow instan @QueryParam("maxActions") @ApiParam("Maximum number of actions returned for each workflow instance") Long maxActions, @QueryParam("queryArchive") @ApiParam("Query also the archive if not found from main tables") Boolean queryArchive) { return handleExceptions( - () -> ok(super.fetchWorkflowInstance(id, include, maxActions, ofNullable(queryArchive).orElse(false), workflowInstances, listWorkflowConverter))); + () -> ok(super.fetchWorkflowInstance(id, include, maxActions, ofNullable(queryArchive).orElse(QUERY_ARCHIVED_DEFAULT), workflowInstances, listWorkflowConverter))); } @GET @@ -143,7 +143,7 @@ public Response listWorkflowInstances(@QueryParam("id") @ApiParam("Internal id o @QueryParam("maxActions") @ApiParam("Maximum number of actions returned for each workflow instance") Long maxActions, @QueryParam("queryArchive") @ApiParam("Query also the archive if not enough results found from main tables") Boolean queryArchive) { return handleExceptions(() -> ok(super.listWorkflowInstances(ids, types, parentWorkflowId, parentActionId, states, statuses, - businessKey, externalId, include, maxResults, maxActions, ofNullable(queryArchive).orElse(false), workflowInstances, listWorkflowConverter).iterator())); + businessKey, externalId, include, maxResults, maxActions, ofNullable(queryArchive).orElse(QUERY_ARCHIVED_DEFAULT), workflowInstances, listWorkflowConverter).iterator())); } @PUT diff --git a/nflow-rest-api-spring-web/src/main/java/io/nflow/rest/v1/springweb/WorkflowInstanceResource.java b/nflow-rest-api-spring-web/src/main/java/io/nflow/rest/v1/springweb/WorkflowInstanceResource.java index 33ddfe5bb..38b81aa35 100644 --- a/nflow-rest-api-spring-web/src/main/java/io/nflow/rest/v1/springweb/WorkflowInstanceResource.java +++ b/nflow-rest-api-spring-web/src/main/java/io/nflow/rest/v1/springweb/WorkflowInstanceResource.java @@ -110,7 +110,7 @@ public ResponseEntity updateWorkflowInstance(@ApiParam("Internal id for workf public ResponseEntity fetchWorkflowInstance(@ApiParam("Internal id for workflow instance") @PathVariable("id") long id, @RequestParam(value = "include", required = false) @ApiParam(value = INCLUDE_PARAM_DESC, allowableValues = INCLUDE_PARAM_VALUES, allowMultiple = true) String include, @RequestParam(value = "maxActions", required = false) @ApiParam("Maximum number of actions returned for each workflow instance") Long maxActions, - @RequestParam(value = "queryArchive", required = false, defaultValue = "false") @ApiParam("Query also the archive if not found from main tables") boolean queryArchive) { + @RequestParam(value = "queryArchive", required = false, defaultValue = QUERY_ARCHIVED_DEFAULT_S) @ApiParam("Query also the archive if not found from main tables") boolean queryArchive) { return handleExceptions( () -> ok(super.fetchWorkflowInstance(id, include, maxActions, queryArchive, this.workflowInstances, this.listWorkflowConverter))); } @@ -129,7 +129,7 @@ public ResponseEntity listWorkflowInstances( @RequestParam(value = "include", required = false) @ApiParam(value = INCLUDE_PARAM_DESC, allowableValues = INCLUDE_PARAM_VALUES, allowMultiple = true) String include, @RequestParam(value = "maxResults", required = false) @ApiParam("Maximum number of workflow instances to be returned") Long maxResults, @RequestParam(value = "maxActions", required = false) @ApiParam("Maximum number of actions returned for each workflow instance") Long maxActions, - @RequestParam(value = "queryArchive", required = false, defaultValue = "false") @ApiParam("Query also the archive if not enough results found from main tables") boolean queryArchive) { + @RequestParam(value = "queryArchive", required = false, defaultValue = QUERY_ARCHIVED_DEFAULT_S) @ApiParam("Query also the archive if not enough results found from main tables") boolean queryArchive) { return handleExceptions( () -> ok(super.listWorkflowInstances(ids, types, parentWorkflowId, parentActionId, states, statuses, businessKey, externalId, include, maxResults, maxActions, queryArchive, this.workflowInstances, this.listWorkflowConverter).iterator()));