openimis-be-tasks_management_py

Introduction

The OpenIMIS Backend Task Management Reference Module is a crucial component of the OpenIMIS system. This module is dedicated to managing tasks and activities within the system. It provides services, functionalities, and GraphQL queries related to task handling. The Task Management Reference Module is designed to be deployed as a module of openimis-be_py, the OpenIMIS backend application.

This documentation aims to provide a comprehensive guide on how to utilize, configure, and interact with the Task Management Reference Module effectively.

ORM Mapping

The module uses Object-Relational Mapping (ORM) to map data from the database to Python objects. The following ORM mappings are used:

  • task_management_task, task_management_historicaltask -> Task: Represents a task entity.

  • task_management_taskgroup, task_management_historicaltaskgroup -> TaskGroup: Represents a group of tasks.

  • task_management_taskexecutor, task_management_historicaltaskexecutor -> TaskExecutor: Represents a task executor.

Developers can access and manipulate task-related data using these mapped objects, which abstract away the underlying database complexities.

tasks_management_orm.png

GraphQL Queries

The module provides several GraphQL queries to retrieve task-related information:

  • task: Retrieves task data based on specified criteria.

  • taskGroup: Retrieves task group data based on specified criteria.

  • taskExecutor: Retrieves task executor data based on specified criteria.

These GraphQL queries provide a flexible and efficient way to retrieve relevant task data.

Services

The module provides the following services:

  • TaskService: Offers methods to create, update, and delete tasks, execute tasks, and mark tasks as completed or resolved.

  • TaskGroupService: Provides methods to create, update, and delete task groups.

  • TaskExecutorService: Offers methods to create, update, and delete task executors.

Developers can interact with these services to perform various operations related to task management.

Configuration Options

The behavior of the Task Management Reference Module can be customized through configuration options, which can be modified via core.ModuleConfiguration. The available configuration options are:

  • gql_task_group_search_perms: Specifies the required rights to call the taskGroup GraphQL query. (Default: 190001)

  • gql_task_group_create_perms: Specifies the required rights to call the createTaskGroup GraphQL mutation. (Default: 190002)

  • gql_task_group_update_perms: Specifies the required rights to call the updateTaskGroup GraphQL mutation. (Default: 190003)

  • gql_task_group_delete_perms: Specifies the required rights to call the deleteTaskGroup GraphQL mutation. (Default: 190004)

  • gql_task_search_perms: Specifies the required rights to call the task GraphQL query. (Default: 191001)

  • gql_task_create_perms: Specifies the required rights to call the createTask GraphQL mutation. (Default: 191002)

  • gql_task_update_perms: Specifies the required rights to call the updateTask GraphQL mutation. (Default: 191003)

  • gql_task_delete_perms: Specifies the required rights to call the deleteTask GraphQL mutation. (Default: 191004)

Developers can adjust these options to control access and permissions related to task management operations.

OpenIMIS Modules Dependencies

The Task Management Reference Module relies on the following modules:

  • core: Provides core functionality and utilities for the OpenIMIS system.

Ensure that the core module is correctly installed and configured for the Task Management Reference Module to function properly.

Creating Execution Action Handlers and Business Event Handlers

The module allows the creation of execution action handlers and business event handlers for tasks. To implement custom handling of task execution or completion, developers need to bind to specific signals.

Binding to Task Execution Signal

To create an execution action handler, bind to the task_service.resolve_task signal using the handler_hook function. The handler should check the specific executor_action_event of the task.

Example:

# In signals.py of any module def bind_service_signals(): bind_service_signal( 'task_service.resolve_task', handler_hook, bind_type=ServiceSignalBindType.AFTER ) def handler_hook(**kwargs): # Custom handling logic for task execution action pass

Binding to Task Completion Signal

To create a business event handler for task completion, bind to the task_service.complete_task signal using the handler_hook function.

Example:

# In signals.py of any module def bind_service_signals(): bind_service_signal( 'task_service.complete_task', handler_hook, bind_type=ServiceSignalBindType.AFTER ) def handler_hook(**kwargs): # Custom handling logic for task completion business event pass

 

Did you encounter a problem or do you have a suggestion?

Please contact our Service Desk



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/