{
    "schema": "1.0",
    "key": "export-job-executions-from-the-last-7-days",
    "title": "Export Job Executions from the last 7 days to an Excel Spreadsheet",
    "tasks": [
        {
            "name": "code-execute-javascript",
            "taskReferenceName": "get_start_date",
            "description": "Get Start Date",
            "inputParameters": {
                "expression": "function f() { return new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000).toISOString(); }f();"
            },
            "type": "SUB_WORKFLOW",
            "startDelay": 0,
            "optional": false
        },
        {
            "name": "data-job-execution-find",
            "taskReferenceName": "find_job_executions",
            "description": "Find Job Executions",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "REQUEST",
                "request": {
                    "method": "INLINE",
                    "contentType": "application/json",
                    "json": {
                        "criteria": {
                            "type": "greater",
                            "field": "createdAt",
                            "value": "${get_start_date.output.result}"
                        }
                    }
                }
            }
        },
        {
            "name": "data-job-find",
            "taskReferenceName": "find_jobs",
            "description": "Find Jobs",
            "type": "SUB_WORKFLOW",
            "optional": false,
            "inputParameters": {
                "findMode": "ALL"
            }
        },
        {
            "name": "file-conversion-json-to-xml",
            "taskReferenceName": "file_conversion_json_to_xml_job_instances",
            "description": "Convert job executions JSON to XML",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "JSON",
                "json": "${find_job_executions.output.result.json}"
            }
        },
        {
            "name": "file-conversion-json-to-xml",
            "taskReferenceName": "file_conversion_json_to_xml_jobs",
            "description": "Convert Jobs JSON to XML",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "JSON",
                "json": "${find_jobs.output.result.json}"
            }
        },
        {
            "name": "file-transformation-xslt",
            "taskReferenceName": "file_transformation_xslt",
            "description": "Generate input for excel task",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "mode": "FILE",
                "file": "${file_conversion_json_to_xml_job_instances.output.file}",
                "xslt": "file://assets/generate-excel-sheet.xslt",
                "fileName": "result.xml",
                "params": [
                    {
                        "name": "jobFile",
                        "select": "${file_conversion_json_to_xml_jobs.output.file}"
                    }
                ]
            }
        },
        {
            "name": "file-generation-xlsx",
            "taskReferenceName": "file_generation_xlsx",
            "description": "Generate Excel Sheet",
            "optional": false,
            "type": "SUB_WORKFLOW",
            "inputParameters": {
                "request": "${file_transformation_xslt.output.file}",
                "templates": [
                    {
                        "key": "report",
                        "file": "file://assets/report.xlsx"
                    }
                ]
            }
        }
    ],
    "outputParameters": {
        "report": "${file_generation_xlsx.output.file}"
    }
}
