Skip to main content
Version: 10.2.9

Workspace

ODF 2 provides WorkspaceClientService to retrieve a page with assignment information, such as the link and status.

To use WorkspaceClientService in your Java-based Bot Task, inject com.workfusion.workspace.client.shared.service.WorkspaceClientService into the constructor and set it as the Bot Task's private property.

You might also need to add the out-of-the-box ControlTowerServicesModule module that provides WorkspaceClientService if you haven't already done it. To do that, add the @Requires(ControlTowerServicesModule.class) annotation to a Bot Task class.

@BotTask
@Requires(ControlTowerServicesModule.class)
public class MyBotTask implements AdHocTask {

private final WorkspaceClientService workspaceClientService;

@Inject
public MyBotTask(WorkspaceClientService workspaceClientService) {
this.workspaceClientService = workspaceClientService;
}

@Override
public TaskRunnerOutput run(TaskInput taskInput) {
final Map<String, List<String>> params = ImmutableMap.of("country", Arrays.asList("US", "CA"));
final PageDtoInternalAssignmentDirectLinkResponse response = workspaceClientService.getAssignments(params, 1, 10);

return response.getItems()
.stream()
.filter(assignment -> READY_TO_PROCESS.equals(assignment.getStatus()))
.map(InternalAssignmentDirectLinkResponse::getLink)
.map(assignmentLink -> new SingletonMap("assignment_link", assignmentLink))
.map(SingleResult::new)
.collect(MultipleResults.toMultipleResults());
}

}

WorkspaceClientService provides only one method:

  • PageDtoInternalAssignmentDirectLinkResponse getAssignments(Map<String, List<String>> params, int page, int size) retrieves a paginated list of assignments for the given parameters. If tenantId is not found in the context, an IllegalStateException is thrown, and if the service cannot find the data based on the provided parameters, a WorkspaceClientServiceException is thrown.