--------------------------------------------------------
--  DDL for Package PKG_STANDARD_EXECUTORS
--------------------------------------------------------

  CREATE OR REPLACE EDITIONABLE PACKAGE "ENVX_OPER"."PKG_STANDARD_EXECUTORS" IS

------------- FUNCTIONS ------------------
/*--------------- FNC01-------------------*/
    FUNCTION fnc_var_value (
        pi_var_name            VARCHAR2,
        pi_request             NUMBER,
        pi_id_control_deploy   NUMBER
    ) RETURN VARCHAR2;

/*--------------- FNC02-------------------*/

    FUNCTION fnc_soap_call (
        pi_body                IN    CLOB,
        pi_soap_header         IN    VARCHAR2,
        pi_soap_action         IN    VARCHAR2,
        pi_target_url          IN    VARCHAR2,
        pi_http_version        IN    VARCHAR2,
        pi_http_content_type   IN    VARCHAR2,
        po_response_code       OUT   VARCHAR2,
        po_error_message       OUT   VARCHAR2
    ) RETURN XMLTYPE;

/*--------------- FNC03-------------------*/

    FUNCTION fnc_send_profile_email (
        pi_id_sys_profile NUMBER
    ) RETURN VARCHAR2; 

/*--------------- FNC04-------------------*/

    FUNCTION fnc_get_status_request (
        pi_id_request NUMBER
    ) RETURN BOOLEAN;  

/*--------------- FNC05-------------------*/
    FUNCTION fnc_get_jenkins_node (
        pi_environment_class NUMBER
    ) RETURN VARCHAR2;


------------ PROCEDURES ------------------
/*--------------- SEP1-------------------*/
    PROCEDURE prc_dynamic_param (
        pi_id_request          IN      NUMBER,
        pi_id_control_deploy   IN      NUMBER,
        pi_id_executor         IN      NUMBER,
        po_exec_program        OUT     CLOB,
        po_parameters_rep      IN OUT  CLOB
    );

/*--------------- SEP2-------------------*/

    PROCEDURE prc_jenkins_check_queue_status (
        pi_id_request     INTEGER,
        pi_id_req_det     INTEGER,
        pi_id_prc_queue   VARCHAR2,
        pi_category_action   VARCHAR2,
        pi_environment_alias VARCHAR2,
        pi_enviroment_class  NUMBER
    );

/*--------------- SEP3-------------------*/

    PROCEDURE prc_dynamic_exec (
        pi_id_request          IN   INTEGER,
        pi_id_control_deploy   IN   INTEGER,
        pi_id_executor         IN   NUMBER
    );

/*--------------- SEP4-------------------*/

    PROCEDURE prc_jkins_job_oracle_db (
        pi_category_action        VARCHAR2,   -- BACKUP | CHECKOUT | DEPLOY
        pi_id_request             NUMBER,
        pi_id_req_det             NUMBER,
        pi_database_alias         VARCHAR2,
        pi_environment_alias      VARCHAR2,
        pi_scm_alias              VARCHAR2,
        pi_repository_path        VARCHAR2,
        pi_object_repository_id   VARCHAR2,
        pi_object_path            VARCHAR2,
        pi_object                 VARCHAR2,
        pi_enviroment_class      NUMBER,       -- 0: NO PRODUCTIVO | 1: PRODUCTIVO
        pi_build_timeout          NUMBER
    );

/*--------------- SEP5-------------------*/

    PROCEDURE prc_jenkins_process_job_out (
        pi_id_request     NUMBER,
        pi_id_req_det     NUMBER,
        pi_category_action    VARCHAR2,
        pi_environment_alias  VARCHAR2,
        pi_enviroment_class   NUMBER,
        pi_http_status      VARCHAR2,
        pi_http_headers   http_headers_tab,
        pi_body           CLOB
    );

/*--------------- SEP6-------------------*/

    PROCEDURE prc_jenkins_get_build_id (
        --pi_id_request          NUMBER,
        --pi_id_req_det          NUMBER,
        pi_environment_class  NUMBER,
        pi_id_queue           NUMBER,
        pi_category_action    VARCHAR2,-- BACKUP | CHECKOUT | DEPLOY
        po_id_build           OUT NUMBER
    );

/*--------------- SEP7-------------------*/

    PROCEDURE prc_jenkins_get_build_status (
        --pi_id_request          NUMBER,
        --pi_id_req_det          NUMBER,
        pi_environment_class   NUMBER,
        --pi_id_prc_exec         VARCHAR2,
        pi_id_build            NUMBER,
        pi_category_action     VARCHAR2, -- BACKUP | CHECKOUT | DEPLOY
        po_v_result            OUT VARCHAR2,
        po_pipeline_accion     OUT VARCHAR2
    );

/*--------------- SEP8-------------------*/

/*--------------- SEP9-------------------*/

    PROCEDURE prc_send_mail (
        pi_notification     IN    CLOB,
        pi_id_sys_profile   IN    NUMBER,
        pi_id_user          IN    NUMBER,
        pi_subject          IN    VARCHAR2,
        po_response_code    OUT   VARCHAR2,
        po_error_message    OUT   VARCHAR2
    );

/*--------------- SEP10-------------------*/

    PROCEDURE prc_jenkins_get_queue_status (
        pi_id_request          NUMBER,
        pi_id_req_det          NUMBER,
        pi_environment_class   NUMBER,
        pi_id_queue            NUMBER,
        pi_category_action     VARCHAR2,-- BACKUP | CHECKOUT | DEPLOY
        po_v_result        OUT VARCHAR2,
        po_v_building      OUT VARCHAR2
    );

 /*----------------SEPT11----------------*/
    PROCEDURE prc_jenkins_check_build_status (
        pi_id_request     INTEGER,
        pi_id_req_det     INTEGER,
        pi_id_prc_queue   VARCHAR2,
        pi_environment_class NUMBER,
        pi_category_action VARCHAR2,
        --pi_exec_message   VARCHAR2,
        --pi_exec_date      VARCHAR2,
        --pi_id_prc_exec    VARCHAR2,
        pi_environment_alias VARCHAR2

    );

/*----------------SEPT12----------------*/
    PROCEDURE prc_configure_message (
    pi_id_action       IN   NUMBER,
    pi_id_request      IN   NUMBER,
    pi_observation     IN   VARCHAR2,
    pi_request_status  IN   VARCHAR2,
    pi_request_flow_message   IN   VARCHAR2,
    pi_enviroment_type  IN  VARCHAR2,  ---Ambiente testing / Ambiente productivo
    pi_deployment_type IN   VARCHAR2,  -- Estandar 
    pi_enviroment_alias      IN  VARCHAR2,
    po_subject         OUT  VARCHAR2,
    po_message         OUT  CLOB,
    po_message_type    OUT  NUMBER

    );

/*----------------SEPT13----------------*/
    PROCEDURE prc_send_deploy_status_message (
    pi_id_request            IN  NUMBER,
    pi_id_control_deploy     IN  NUMBER,
    pi_observation           IN  VARCHAR2,
    pi_request_flow_message  IN  VARCHAR2,  --'REQUEST_WORKFLOW' /  REQUEST_DEPLOYMENT
    pi_id_prc_exec           IN  VARCHAR2

    );

/*----------------SEPT14----------------*/    
    PROCEDURE prc_send_action_message(
    pi_id_action              IN   NUMBER,
    pi_id_request             IN   NUMBER,
    pi_observation            IN   VARCHAR2,
    pi_request_status         IN   VARCHAR2,
    pi_request_flow_message   IN   VARCHAR2,  --'REQUEST_WORKFLOW' /  REQUEST_DEPLOYMENT
    pi_id_sys_profile         IN   NUMBER,
    pi_id_next_user           IN   NUMBER

    );

/*----------------SEPT15----------------*/  
    PROCEDURE prc_jkins_job_ipolaris_java_wb (
        pi_category_action        VARCHAR2,   -- BACKUP | CHECKOUT | DEPLOY
        pi_id_request             NUMBER,
        pi_id_req_det             NUMBER,
        --pi_database_alias         VARCHAR2,
        pi_environment_alias      VARCHAR2,
        pi_scm_alias              VARCHAR2,
        pi_repository_path        VARCHAR2,
       -- pi_object_repository_id   VARCHAR2,
       -- pi_object_path            VARCHAR2,
       -- pi_object               VARCHAR2,
	    pi_componentes			  CLOB,
        pi_enviroment_class       NUMBER,       -- 0: NO PRODUCTIVO | 1: PRODUCTIVO
        pi_build_timeout          NUMBER,
        pi_version               VARCHAR2
    );

----------------------------------------------
END pkg_standard_executors;


/
