@Test public void testGetWorkflowDefinitions() throws Exception { final String response = given().expect().statusCode(SC_OK).when().get(env.host("/")).asString(); final JSONArray json = (JSONArray) parser.parse(response); assertEquals(2, json.size()); final JSONObject wd1 = (JSONObject) json.get(0); assertEquals("example1", wd1.get("identifier")); assertEquals("Example workflow", wd1.get("title")); assertEquals("Example workflow definition", wd1.get("description")); assertArrayEquals(new String[] { "archive", "my-tag" }, ((JSONArray) wd1.get("tags")).toArray()); assertFalse(wd1.containsKey("configuration_panel")); assertFalse(wd1.containsKey("operations")); final JSONObject wd2 = (JSONObject) json.get(1); assertEquals("example2", wd2.get("identifier")); assertEquals("Another workflow", wd2.get("title")); assertEquals("Example workflow definition", wd2.get("description")); assertArrayEquals(new String[] {}, ((JSONArray) wd2.get("tags")).toArray()); assertFalse(wd2.containsKey("configuration_panel")); assertFalse(wd2.containsKey("operations")); }
@GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) public Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader, @QueryParam("withoperations") boolean withOperations, @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit) { Stream<WorkflowDefinition> workflowDefinitions; try { workflowDefinitions = workflowService.listAvailableWorkflowDefinitions().stream(); } catch (WorkflowDatabaseException e) { logger.error("The workflow service was not able to get the workflow definitions:", e); return ApiResponses.serverError("Could not retrieve workflow definitions, reason: '%s'", getMessage(e)); } if (StringUtils.isNotBlank(filter)) { for (String f : filter.split(",")) { int sepIdx = f.indexOf(':'); if (sepIdx < 0 || sepIdx == f.length() - 1) { logger.info("No value for filter {} in filters list: {}", f, filter); continue; } String name = f.substring(0, sepIdx); String value = f.substring(sepIdx + 1); if ("tag".equals(name)) workflowDefinitions = workflowDefinitions.filter(wd -> ArrayUtils.contains(wd.getTags(), value)); } } ComparatorChain<WorkflowDefinition> comparator = new ComparatorChain<>(); if (StringUtils.isNoneBlank(sort)) { Set<SortCriterion> sortCriteria = RestUtils.parseSortQueryParameter(sort); for (SortCriterion criterion : sortCriteria) { switch (criterion.getFieldName()) { case "identifier": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getId()); String s2 = defaultString(wd2.getId()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "title": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getTitle()); String s2 = defaultString(wd2.getTitle()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "displayorder": comparator.addComparator((wd1, wd2) -> { if (criterion.getOrder() == Descending) return Integer.compare(wd2.getDisplayOrder(), wd1.getDisplayOrder()); return Integer.compare(wd1.getDisplayOrder(), wd2.getDisplayOrder()); }); break; default: return RestUtil.R.badRequest( String.format("Unknown search criterion in request: %s", criterion.getFieldName())); } } } if (comparator.size() > 0) { workflowDefinitions = workflowDefinitions.sorted(comparator); } if (offset != null && offset > 0) { workflowDefinitions = workflowDefinitions.skip(offset); } if (limit != null && limit > 0) { workflowDefinitions = workflowDefinitions.limit(limit); } List<JValue> json = workflowDefinitions.map( wd -> workflowDefinitionToJSON(wd, withOperations, withConfigurationPanel)).collect(Collectors.toList()); return ApiResponses.Json.ok(acceptHeader, arr(json)); }
WorkflowDefinitionsEndpoint { @GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) public Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader, @QueryParam("withoperations") boolean withOperations, @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit) { Stream<WorkflowDefinition> workflowDefinitions; try { workflowDefinitions = workflowService.listAvailableWorkflowDefinitions().stream(); } catch (WorkflowDatabaseException e) { logger.error("The workflow service was not able to get the workflow definitions:", e); return ApiResponses.serverError("Could not retrieve workflow definitions, reason: '%s'", getMessage(e)); } if (StringUtils.isNotBlank(filter)) { for (String f : filter.split(",")) { int sepIdx = f.indexOf(':'); if (sepIdx < 0 || sepIdx == f.length() - 1) { logger.info("No value for filter {} in filters list: {}", f, filter); continue; } String name = f.substring(0, sepIdx); String value = f.substring(sepIdx + 1); if ("tag".equals(name)) workflowDefinitions = workflowDefinitions.filter(wd -> ArrayUtils.contains(wd.getTags(), value)); } } ComparatorChain<WorkflowDefinition> comparator = new ComparatorChain<>(); if (StringUtils.isNoneBlank(sort)) { Set<SortCriterion> sortCriteria = RestUtils.parseSortQueryParameter(sort); for (SortCriterion criterion : sortCriteria) { switch (criterion.getFieldName()) { case "identifier": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getId()); String s2 = defaultString(wd2.getId()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "title": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getTitle()); String s2 = defaultString(wd2.getTitle()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "displayorder": comparator.addComparator((wd1, wd2) -> { if (criterion.getOrder() == Descending) return Integer.compare(wd2.getDisplayOrder(), wd1.getDisplayOrder()); return Integer.compare(wd1.getDisplayOrder(), wd2.getDisplayOrder()); }); break; default: return RestUtil.R.badRequest( String.format("Unknown search criterion in request: %s", criterion.getFieldName())); } } } if (comparator.size() > 0) { workflowDefinitions = workflowDefinitions.sorted(comparator); } if (offset != null && offset > 0) { workflowDefinitions = workflowDefinitions.skip(offset); } if (limit != null && limit > 0) { workflowDefinitions = workflowDefinitions.limit(limit); } List<JValue> json = workflowDefinitions.map( wd -> workflowDefinitionToJSON(wd, withOperations, withConfigurationPanel)).collect(Collectors.toList()); return ApiResponses.Json.ok(acceptHeader, arr(json)); } }
WorkflowDefinitionsEndpoint { @GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) public Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader, @QueryParam("withoperations") boolean withOperations, @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit) { Stream<WorkflowDefinition> workflowDefinitions; try { workflowDefinitions = workflowService.listAvailableWorkflowDefinitions().stream(); } catch (WorkflowDatabaseException e) { logger.error("The workflow service was not able to get the workflow definitions:", e); return ApiResponses.serverError("Could not retrieve workflow definitions, reason: '%s'", getMessage(e)); } if (StringUtils.isNotBlank(filter)) { for (String f : filter.split(",")) { int sepIdx = f.indexOf(':'); if (sepIdx < 0 || sepIdx == f.length() - 1) { logger.info("No value for filter {} in filters list: {}", f, filter); continue; } String name = f.substring(0, sepIdx); String value = f.substring(sepIdx + 1); if ("tag".equals(name)) workflowDefinitions = workflowDefinitions.filter(wd -> ArrayUtils.contains(wd.getTags(), value)); } } ComparatorChain<WorkflowDefinition> comparator = new ComparatorChain<>(); if (StringUtils.isNoneBlank(sort)) { Set<SortCriterion> sortCriteria = RestUtils.parseSortQueryParameter(sort); for (SortCriterion criterion : sortCriteria) { switch (criterion.getFieldName()) { case "identifier": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getId()); String s2 = defaultString(wd2.getId()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "title": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getTitle()); String s2 = defaultString(wd2.getTitle()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "displayorder": comparator.addComparator((wd1, wd2) -> { if (criterion.getOrder() == Descending) return Integer.compare(wd2.getDisplayOrder(), wd1.getDisplayOrder()); return Integer.compare(wd1.getDisplayOrder(), wd2.getDisplayOrder()); }); break; default: return RestUtil.R.badRequest( String.format("Unknown search criterion in request: %s", criterion.getFieldName())); } } } if (comparator.size() > 0) { workflowDefinitions = workflowDefinitions.sorted(comparator); } if (offset != null && offset > 0) { workflowDefinitions = workflowDefinitions.skip(offset); } if (limit != null && limit > 0) { workflowDefinitions = workflowDefinitions.limit(limit); } List<JValue> json = workflowDefinitions.map( wd -> workflowDefinitionToJSON(wd, withOperations, withConfigurationPanel)).collect(Collectors.toList()); return ApiResponses.Json.ok(acceptHeader, arr(json)); }  }
WorkflowDefinitionsEndpoint { @GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) public Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader, @QueryParam("withoperations") boolean withOperations, @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit) { Stream<WorkflowDefinition> workflowDefinitions; try { workflowDefinitions = workflowService.listAvailableWorkflowDefinitions().stream(); } catch (WorkflowDatabaseException e) { logger.error("The workflow service was not able to get the workflow definitions:", e); return ApiResponses.serverError("Could not retrieve workflow definitions, reason: '%s'", getMessage(e)); } if (StringUtils.isNotBlank(filter)) { for (String f : filter.split(",")) { int sepIdx = f.indexOf(':'); if (sepIdx < 0 || sepIdx == f.length() - 1) { logger.info("No value for filter {} in filters list: {}", f, filter); continue; } String name = f.substring(0, sepIdx); String value = f.substring(sepIdx + 1); if ("tag".equals(name)) workflowDefinitions = workflowDefinitions.filter(wd -> ArrayUtils.contains(wd.getTags(), value)); } } ComparatorChain<WorkflowDefinition> comparator = new ComparatorChain<>(); if (StringUtils.isNoneBlank(sort)) { Set<SortCriterion> sortCriteria = RestUtils.parseSortQueryParameter(sort); for (SortCriterion criterion : sortCriteria) { switch (criterion.getFieldName()) { case "identifier": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getId()); String s2 = defaultString(wd2.getId()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "title": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getTitle()); String s2 = defaultString(wd2.getTitle()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "displayorder": comparator.addComparator((wd1, wd2) -> { if (criterion.getOrder() == Descending) return Integer.compare(wd2.getDisplayOrder(), wd1.getDisplayOrder()); return Integer.compare(wd1.getDisplayOrder(), wd2.getDisplayOrder()); }); break; default: return RestUtil.R.badRequest( String.format("Unknown search criterion in request: %s", criterion.getFieldName())); } } } if (comparator.size() > 0) { workflowDefinitions = workflowDefinitions.sorted(comparator); } if (offset != null && offset > 0) { workflowDefinitions = workflowDefinitions.skip(offset); } if (limit != null && limit > 0) { workflowDefinitions = workflowDefinitions.limit(limit); } List<JValue> json = workflowDefinitions.map( wd -> workflowDefinitionToJSON(wd, withOperations, withConfigurationPanel)).collect(Collectors.toList()); return ApiResponses.Json.ok(acceptHeader, arr(json)); }  WorkflowService getWorkflowService(); void setWorkflowService(WorkflowService workflowService); @GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader,
          @QueryParam("withoperations") boolean withOperations,
          @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter,
          @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit); @GET @Path("{workflowDefinitionId}") @RestQuery(name = "getworkflowdefinition", description = "Returns a single workflow definition.", returnDescription = "", pathParameters = { @RestParameter(name = "workflowDefinitionId", description = "The workflow definition id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN) }, responses = { @RestResponse(description = "The workflow definition is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified workflow definition does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getWorkflowDefinition(@HeaderParam("Accept") String acceptHeader,
          @PathParam("workflowDefinitionId") String id, @QueryParam("withoperations") boolean withOperations,
          @QueryParam("withconfigurationpanel") boolean withConfigurationPanel); }
WorkflowDefinitionsEndpoint { @GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) public Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader, @QueryParam("withoperations") boolean withOperations, @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter, @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit) { Stream<WorkflowDefinition> workflowDefinitions; try { workflowDefinitions = workflowService.listAvailableWorkflowDefinitions().stream(); } catch (WorkflowDatabaseException e) { logger.error("The workflow service was not able to get the workflow definitions:", e); return ApiResponses.serverError("Could not retrieve workflow definitions, reason: '%s'", getMessage(e)); } if (StringUtils.isNotBlank(filter)) { for (String f : filter.split(",")) { int sepIdx = f.indexOf(':'); if (sepIdx < 0 || sepIdx == f.length() - 1) { logger.info("No value for filter {} in filters list: {}", f, filter); continue; } String name = f.substring(0, sepIdx); String value = f.substring(sepIdx + 1); if ("tag".equals(name)) workflowDefinitions = workflowDefinitions.filter(wd -> ArrayUtils.contains(wd.getTags(), value)); } } ComparatorChain<WorkflowDefinition> comparator = new ComparatorChain<>(); if (StringUtils.isNoneBlank(sort)) { Set<SortCriterion> sortCriteria = RestUtils.parseSortQueryParameter(sort); for (SortCriterion criterion : sortCriteria) { switch (criterion.getFieldName()) { case "identifier": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getId()); String s2 = defaultString(wd2.getId()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "title": comparator.addComparator((wd1, wd2) -> { String s1 = defaultString(wd1.getTitle()); String s2 = defaultString(wd2.getTitle()); if (criterion.getOrder() == Descending) return s2.compareTo(s1); return s1.compareTo(s2); }); break; case "displayorder": comparator.addComparator((wd1, wd2) -> { if (criterion.getOrder() == Descending) return Integer.compare(wd2.getDisplayOrder(), wd1.getDisplayOrder()); return Integer.compare(wd1.getDisplayOrder(), wd2.getDisplayOrder()); }); break; default: return RestUtil.R.badRequest( String.format("Unknown search criterion in request: %s", criterion.getFieldName())); } } } if (comparator.size() > 0) { workflowDefinitions = workflowDefinitions.sorted(comparator); } if (offset != null && offset > 0) { workflowDefinitions = workflowDefinitions.skip(offset); } if (limit != null && limit > 0) { workflowDefinitions = workflowDefinitions.limit(limit); } List<JValue> json = workflowDefinitions.map( wd -> workflowDefinitionToJSON(wd, withOperations, withConfigurationPanel)).collect(Collectors.toList()); return ApiResponses.Json.ok(acceptHeader, arr(json)); }  WorkflowService getWorkflowService(); void setWorkflowService(WorkflowService workflowService); @GET @Path("/") @RestQuery(name = "getworkflowdefinitions", description = "Returns a list of workflow definition.", returnDescription = "", restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "filter", description = "A comma seperated list of filters to limit the results with. A filter is the filter's name followed by a colon \":\" and then the value to filter with so it is the form <Filter Name>:<Value to Filter With>.", isRequired = false, type = STRING), @RestParameter(name = "sort", description = "Sort the results based upon a list of comma seperated sorting criteria. In the comma seperated list each type of sorting is specified as a pair such as: <Sort Name>:ASC or <Sort Name>:DESC. Adding the suffix ASC or DESC sets the order as ascending or descending order and is mandatory.", isRequired = false, type = STRING), @RestParameter(name = "limit", description = "The maximum number of results to return for a single request.", isRequired = false, type = INTEGER), @RestParameter(name = "offset", description = "The index of the first result to return.", isRequired = false, type = INTEGER) }, responses = { @RestResponse(description = "A (potentially empty) list of workflow definitions is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The request is invalid or inconsistent.", responseCode = HttpServletResponse.SC_BAD_REQUEST) }) Response getWorkflowDefinitions(@HeaderParam("Accept") String acceptHeader,
          @QueryParam("withoperations") boolean withOperations,
          @QueryParam("withconfigurationpanel") boolean withConfigurationPanel, @QueryParam("filter") String filter,
          @QueryParam("sort") String sort, @QueryParam("offset") Integer offset, @QueryParam("limit") Integer limit); @GET @Path("{workflowDefinitionId}") @RestQuery(name = "getworkflowdefinition", description = "Returns a single workflow definition.", returnDescription = "", pathParameters = { @RestParameter(name = "workflowDefinitionId", description = "The workflow definition id", isRequired = true, type = STRING) }, restParameters = { @RestParameter(name = "withoperations", description = "Whether the workflow operations should be included in the response", isRequired = false, type = BOOLEAN), @RestParameter(name = "withconfigurationpanel", description = "Whether the workflow configuration panel should be included in the response", isRequired = false, type = BOOLEAN) }, responses = { @RestResponse(description = "The workflow definition is returned.", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The specified workflow definition does not exist.", responseCode = HttpServletResponse.SC_NOT_FOUND) }) Response getWorkflowDefinition(@HeaderParam("Accept") String acceptHeader,
          @PathParam("workflowDefinitionId") String id, @QueryParam("withoperations") boolean withOperations,
          @QueryParam("withconfigurationpanel") boolean withConfigurationPanel);  }