INSERT INTO `ohrm_external_integration_process` (`name`, `configuration`, `isConsumer`, `enabled`) VALUES
('PushNavigationDataToELK', '{
  "replacementParameters": {
    "authenticationHeader": "64bit encoded value of username:password for the elasticsearch account.",
    "elasticsearchUrl": "url for the remote elasticsearch server. eg: https://elk-api.orangehrm.com",
    "client_id": "Oauth client id",
    "client_secret": "Oauth client secret"
  },
  "subscribedEvents": [
    "user_navigation"
  ],
  "processCoordinator": "BasicIntegrationProcessCoordinator",
  "dataFlow": [
    {
      "name": "ProductConfigExtractionMediator",
      "properties": {
        "extractData": true,
        "updateLastExecutedTime": false,
        "client_id": "##client_id##",
        "client_secret": "##client_secret##"
      }
    },
    {
      "name": "NavigationDataExtractionMediator",
      "properties": {
        "extraction": true,
        "markTheRecordsPublish": false
      }
    },
    {
      "name": "APIDataDispatchMediator",
      "properties": {
        "oauthConfig": false,
        "oauthConfigData": {
          "grantType": "password",
          "client_id": "",
          "client_secret": "",
          "scope": "",
          "url": "",
          "redirect_uri": "",
          "state": "",
          "username": "",
          "password": "",
          "refresh_token": ""
        },
        "method": "post",
        "dataType": "Json",
        "parameters": [
          {
            "parameterName": "",
            "fieldName": "",
            "fieldPath": []
          }
        ],
        "parametersDataPath": [],
        "dataPath": ["jsonBody"],
        "expectedResponseCode": "200",
        "additionalHeaders": [
          "Authorization:Basic ##authenticationHeader##"
        ],
        "dataURl": "##elasticsearchUrl##/_bulk?pipeline=ohrmIngestNode",
        "aggregatedFieldName": "navigationData",
        "dataConvertConfig": {
          "from": "json",
          "to": "json"
        },
        "aggregatedDataSet": "variable"
        }
    },
    {
      "name": "NavigationDataExtractionMediator",
      "properties": {
        "extraction": false,
        "markTheRecordsPublish": true
      }
    },
    {
      "name": "ProductConfigExtractionMediator",
      "properties": {
        "extractData": false,
        "updateLastExecutedTime": true,
        "client_id": "##client_id##",
        "client_secret": "##client_secret##"
      }
    }
  ]
}', 0, 1);

INSERT INTO `ohrm_symfony_task` (`name`, `short_description`, `long_description`, `command`, `schedule`, `observer_class`, `prevent_overlap`,`user_interface`,`status`) VALUES
('Run Data Warehouse Integration', 'This task will push the navigation data to the external data warehouse.', 'This task will push the navigation data to the external data warehouse.', 'php symfony orangehrm:execute-integration-process --process_name="PushNavigationDataToELK"', '0 */6 * * *', '', 0, 'executableTask', 1);

UPDATE `ohrm_external_usage_log` SET published_to_warehouse = 1
