@Test public void testGetProcessing() throws ParseException, IOException { InputStream stream = TasksEndpointTest.class.getResourceAsStream("/taskProcessing.json"); InputStreamReader reader = new InputStreamReader(stream); JSONArray expected = (JSONArray) new JSONParser().parse(reader); JSONArray actual = (JSONArray) parser .parse(given().queryParam("tags", "archive").expect().statusCode(HttpStatus.SC_OK) .contentType(ContentType.JSON).when().get(rt.host("/processing.json")).asString()); assertEquals(expected, actual); }
@GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) public Response getProcessing(@QueryParam("tags") String tagsString) { List<String> tags = RestUtil.splitCommaSeparatedParam(Option.option(tagsString)).value(); List<JValue> actions = new ArrayList<>(); try { List<WorkflowDefinition> workflowsDefinitions = workflowService.listAvailableWorkflowDefinitions(); for (WorkflowDefinition wflDef : workflowsDefinitions) { if (wflDef.containsTag(tags)) { actions.add(obj(f("id", v(wflDef.getId())), f("title", v(nul(wflDef.getTitle()).getOr(""))), f("description", v(nul(wflDef.getDescription()).getOr(""))), f("configuration_panel", v(nul(wflDef.getConfigurationPanel()).getOr(""))))); } } } catch (WorkflowDatabaseException e) { logger.error("Unable to get available workflow definitions", e); return RestUtil.R.serverError(); } return okJson(arr(actions)); }
TasksEndpoint { @GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) public Response getProcessing(@QueryParam("tags") String tagsString) { List<String> tags = RestUtil.splitCommaSeparatedParam(Option.option(tagsString)).value(); List<JValue> actions = new ArrayList<>(); try { List<WorkflowDefinition> workflowsDefinitions = workflowService.listAvailableWorkflowDefinitions(); for (WorkflowDefinition wflDef : workflowsDefinitions) { if (wflDef.containsTag(tags)) { actions.add(obj(f("id", v(wflDef.getId())), f("title", v(nul(wflDef.getTitle()).getOr(""))), f("description", v(nul(wflDef.getDescription()).getOr(""))), f("configuration_panel", v(nul(wflDef.getConfigurationPanel()).getOr(""))))); } } } catch (WorkflowDatabaseException e) { logger.error("Unable to get available workflow definitions", e); return RestUtil.R.serverError(); } return okJson(arr(actions)); } }
TasksEndpoint { @GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) public Response getProcessing(@QueryParam("tags") String tagsString) { List<String> tags = RestUtil.splitCommaSeparatedParam(Option.option(tagsString)).value(); List<JValue> actions = new ArrayList<>(); try { List<WorkflowDefinition> workflowsDefinitions = workflowService.listAvailableWorkflowDefinitions(); for (WorkflowDefinition wflDef : workflowsDefinitions) { if (wflDef.containsTag(tags)) { actions.add(obj(f("id", v(wflDef.getId())), f("title", v(nul(wflDef.getTitle()).getOr(""))), f("description", v(nul(wflDef.getDescription()).getOr(""))), f("configuration_panel", v(nul(wflDef.getConfigurationPanel()).getOr(""))))); } } } catch (WorkflowDatabaseException e) { logger.error("Unable to get available workflow definitions", e); return RestUtil.R.serverError(); } return okJson(arr(actions)); }  }
TasksEndpoint { @GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) public Response getProcessing(@QueryParam("tags") String tagsString) { List<String> tags = RestUtil.splitCommaSeparatedParam(Option.option(tagsString)).value(); List<JValue> actions = new ArrayList<>(); try { List<WorkflowDefinition> workflowsDefinitions = workflowService.listAvailableWorkflowDefinitions(); for (WorkflowDefinition wflDef : workflowsDefinitions) { if (wflDef.containsTag(tags)) { actions.add(obj(f("id", v(wflDef.getId())), f("title", v(nul(wflDef.getTitle()).getOr(""))), f("description", v(nul(wflDef.getDescription()).getOr(""))), f("configuration_panel", v(nul(wflDef.getConfigurationPanel()).getOr(""))))); } } } catch (WorkflowDatabaseException e) { logger.error("Unable to get available workflow definitions", e); return RestUtil.R.serverError(); } return okJson(arr(actions)); }  @Reference void setWorkflowService(WorkflowService workflowService); @Reference void setAssetManager(AssetManager assetManager); @GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) Response getProcessing(@QueryParam("tags") String tagsString); @POST @Path("/new") @RestQuery(name = "createNewTask", description = "Creates a new task by the given metadata as JSON", returnDescription = "The task identifiers", restParameters = { @RestParameter(name = "metadata", isRequired = true, description = "The metadata as JSON", type = RestParameter.Type.TEXT) }, responses = { @RestResponse(responseCode = HttpServletResponse.SC_CREATED, description = "Task sucessfully added"), @RestResponse(responseCode = SC_NOT_FOUND, description = "If the workflow definition is not found"), @RestResponse(responseCode = SC_BAD_REQUEST, description = "If the metadata is not set or couldn't be parsed") }) Response createNewTask(@FormParam("metadata") String metadata); }
TasksEndpoint { @GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) public Response getProcessing(@QueryParam("tags") String tagsString) { List<String> tags = RestUtil.splitCommaSeparatedParam(Option.option(tagsString)).value(); List<JValue> actions = new ArrayList<>(); try { List<WorkflowDefinition> workflowsDefinitions = workflowService.listAvailableWorkflowDefinitions(); for (WorkflowDefinition wflDef : workflowsDefinitions) { if (wflDef.containsTag(tags)) { actions.add(obj(f("id", v(wflDef.getId())), f("title", v(nul(wflDef.getTitle()).getOr(""))), f("description", v(nul(wflDef.getDescription()).getOr(""))), f("configuration_panel", v(nul(wflDef.getConfigurationPanel()).getOr(""))))); } } } catch (WorkflowDatabaseException e) { logger.error("Unable to get available workflow definitions", e); return RestUtil.R.serverError(); } return okJson(arr(actions)); }  @Reference void setWorkflowService(WorkflowService workflowService); @Reference void setAssetManager(AssetManager assetManager); @GET @Path("processing.json") @RestQuery(name = "getProcessing", description = "Returns all the data related to the processing tab in the new tasks modal as JSON", returnDescription = "All the data related to the tasks processing tab as JSON", restParameters = { @RestParameter(name = "tags", isRequired = false, description = "A comma separated list of tags to filter the workflow definitions", type = RestParameter.Type.STRING) }, responses = { @RestResponse(responseCode = SC_OK, description = "Returns all the data related to the tasks processing tab as JSON") }) Response getProcessing(@QueryParam("tags") String tagsString); @POST @Path("/new") @RestQuery(name = "createNewTask", description = "Creates a new task by the given metadata as JSON", returnDescription = "The task identifiers", restParameters = { @RestParameter(name = "metadata", isRequired = true, description = "The metadata as JSON", type = RestParameter.Type.TEXT) }, responses = { @RestResponse(responseCode = HttpServletResponse.SC_CREATED, description = "Task sucessfully added"), @RestResponse(responseCode = SC_NOT_FOUND, description = "If the workflow definition is not found"), @RestResponse(responseCode = SC_BAD_REQUEST, description = "If the metadata is not set or couldn't be parsed") }) Response createNewTask(@FormParam("metadata") String metadata);  }