{
    "schema": "1.0",
    "key": "list-comment-threads-opened-and-assigned-to-my-account",
    "title": "Mail the list of open threads",
    "tasks": [
        {
            "name": "context-user-get",
            "taskReferenceName": "get_current_user",
            "description": "Get current user",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {}
        },
        {
            "name": "data-comment-thread-find",
            "taskReferenceName": "find_comment_threads",
            "description": "Find comment threads",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "ALL"
            }
        },
        {
            "name": "data-account-find",
            "taskReferenceName": "find_accounts",
            "description": "Find accounts",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "ALL"
            }
        },
        {
            "name": "json-transform-jq",
            "taskReferenceName": "filter_comment_threads_opened_and_assigned_to_my_account",
            "description": "Filter comment threads opened and assigned to my account",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "data": {
                    "accountId": "${workflow.input.context.userAccountId}",
                    "commentThreads": "${find_comment_threads.output.result.json}"
                },
                "queryExpression": ".data.accountId as $accountId | .data.commentThreads[] | select(.isClosed == false and .accountAssigneesId[] == $accountId)"
            }
        },
        {
            "name": "file-conversion-json-to-xml",
            "taskReferenceName": "convert_comment_threads",
            "description": "JSON to XML conversion of comment threads",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "JSON",
                "json": "${filter_comment_threads_opened_and_assigned_to_my_account.output.resultList}"
            }
        },
        {
            "name": "file-conversion-json-to-xml",
            "taskReferenceName": "counvert_accounts",
            "description": "JSON to XML conversion of accounts",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "JSON",
                "json": "${find_accounts.output.result.json}"
            }
        },
        {
            "name": "file-transformation-xslt",
            "taskReferenceName": "file_transformation_xslt",
            "description": "Generate Email Body",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "FILE",
                "file": "${convert_comment_threads.output.file}",
                "xslt": "file://assets/generate-email.xslt",
                "fileName": "result.xml",
                "params": [
                    {
                        "name": "domain",
                        "select": "app.dev.product-live.com"
                    },
                    {
                        "name": "userEmail",
                        "select": "${get_current_user.output.result.json.email}"
                    },
                    {
                        "name": "accountFile",
                        "select": "${counvert_accounts.output.file}"
                    },
                    {
                        "name": "userAccountId",
                        "select": "${workflow.input.context.userAccountId}"
                    }
                ]
            }
        },
        {
            "name": "notification-display-message",
            "taskReferenceName": "notification_display_message",
            "description": "Display Message",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "request": "${file_transformation_xslt.output.file}",
                "height": 300
            }
        },
        {
            "name": "notification-send-email",
            "taskReferenceName": "notification_send_email",
            "description": "Send Email",
            "optional": true,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "FILE",
                "file": "${file_transformation_xslt.output.file}"
            }
        }
    ],
    "outputParameters": {
        "email": "${file_transformation_xslt.output.file}",
        "threads": "${filter_comment_threads_opened_and_assigned_to_my_account.output.resultList}",
        "message": "${notification_display_message.output.message}"
    }
}
