Search in sources :

Example 6 with TaskList

use of com.google.api.services.tasks.model.TaskList in project jbpm-work-items by kiegroup.

the class AddTaskWorkitemHandler method executeWorkItem.

public void executeWorkItem(WorkItem workItem, WorkItemManager workItemManager) {
    String taskName = (String) workItem.getParameter("TaskName");
    String taskKind = (String) workItem.getParameter("TaskKind");
    if (taskName == null) {
        logger.error("Missing task name input.");
        throw new IllegalArgumentException("Missing task name input.");
    }
    try {
        Tasks service = auth.getTasksService(appName, clientSecret);
        TaskList taskList = new TaskList();
        taskList.setTitle(taskName);
        taskList.setId(taskName);
        taskList.setKind(taskKind);
        taskList.setUpdated(new DateTime(new Date()));
        service.tasklists().insert(taskList).execute();
        workItemManager.completeWorkItem(workItem.getId(), null);
    } catch (Exception e) {
        handleException(e);
    }
}
Also used : Tasks(com.google.api.services.tasks.Tasks) TaskList(com.google.api.services.tasks.model.TaskList) DateTime(com.google.api.client.util.DateTime) Date(java.util.Date)

Example 7 with TaskList

use of com.google.api.services.tasks.model.TaskList in project jbpm-work-items by kiegroup.

the class GoogleTasksWorkitemHandlerTest method setUp.

@Before
public void setUp() {
    try {
        List<TaskList> testTaskList = new java.util.ArrayList<>();
        TaskList listOne = new TaskList();
        listOne.setTitle("buy groceries");
        listOne.setKind("home task");
        TaskList listTwo = new TaskList();
        listTwo.setTitle("pickup kid from school");
        listTwo.setKind("home task");
        testTaskList.add(listOne);
        testTaskList.add(listTwo);
        TaskLists taskListsModel = new TaskLists();
        taskListsModel.setItems(testTaskList);
        when(auth.getTasksService(anyString(), anyString())).thenReturn(tasksService);
        when(tasksService.tasklists()).thenReturn(taskLists);
        when(taskLists.list()).thenReturn(taskListsList);
        when(taskLists.insert(any(TaskList.class))).thenReturn(taskListsInsert);
        when(taskListsList.setMaxResults(anyLong())).thenReturn(taskListsList);
        when(taskListsList.execute()).thenReturn(taskListsModel);
        when(taskListsInsert.execute()).thenReturn(listOne);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : TaskList(com.google.api.services.tasks.model.TaskList) TaskLists(com.google.api.services.tasks.model.TaskLists) Before(org.junit.Before)

Aggregations

TaskList (com.google.api.services.tasks.model.TaskList)7 TaskLists (com.google.api.services.tasks.model.TaskLists)4 Tasks (com.google.api.services.tasks.Tasks)3 Task (com.google.api.services.tasks.model.Task)2 ArrayList (java.util.ArrayList)2 TaskListModel (org.dataportabilityproject.dataModels.tasks.TaskListModel)2 TaskListModel (org.dataportabilityproject.types.transfer.models.tasks.TaskListModel)2 DateTime (com.google.api.client.util.DateTime)1 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ContinuationInformation (org.dataportabilityproject.dataModels.ContinuationInformation)1 PaginationInformation (org.dataportabilityproject.dataModels.PaginationInformation)1 Resource (org.dataportabilityproject.dataModels.Resource)1 TaskModel (org.dataportabilityproject.dataModels.tasks.TaskModel)1 TaskModelWrapper (org.dataportabilityproject.dataModels.tasks.TaskModelWrapper)1 IdOnlyResource (org.dataportabilityproject.shared.IdOnlyResource)1 StringPaginationToken (org.dataportabilityproject.shared.StringPaginationToken)1 ExportResult (org.dataportabilityproject.spi.transfer.provider.ExportResult)1