--------------------------------------------------------
--  DDL for Package PKG_DEPLOY_COORDINATOR
--------------------------------------------------------

  CREATE OR REPLACE EDITIONABLE PACKAGE "ENVX_OPER"."PKG_DEPLOY_COORDINATOR" AS

------------- FUNCTIONS ------------------

/*--------------- FNC01-------------------*/
    FUNCTION request_hgroup_name (
        pi_id_request          IN  NUMBER,
        pi_id_enviroment_type  IN  NUMBER,
        pi_creation_date       IN  DATE
    ) RETURN VARCHAR2;

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

    FUNCTION next_step_status (
        pi_id_pattern       IN  NUMBER,
        pi_id_pattern_step  IN  NUMBER,
        pi_id_status        IN  NUMBER,
        pi_result           IN  NUMBER
    ) RETURN NUMBER;

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

    FUNCTION step_status_result (
        pi_pattern          IN  NUMBER,
        pi_id_pattern_step  IN  NUMBER,
        pi_id_status        IN  NUMBER
    ) RETURN VARCHAR2;

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

    FUNCTION step_status_category (
        pi_id_pattern       IN  NUMBER,
        pi_id_pattern_step  IN  NUMBER,
        pi_id_status        IN  NUMBER
    ) RETURN NUMBER;

/*--------------- FNC05-------------------*/

    FUNCTION step_status_retry (
        pi_id_pattern       IN  NUMBER,
        pi_id_pattern_step  IN  NUMBER,
        pi_id_status        IN  NUMBER
    ) RETURN NUMBER;

/*--------------- FNC06-------------------*/

    FUNCTION step_exec_category (
        pi_id_pattern       IN  NUMBER,
        pi_id_pattern_step  IN  NUMBER,
        pi_result           IN  NUMBER
    ) RETURN NUMBER;

/*--------------- FNC07-------------------*/

    FUNCTION sch_job_name (
        pi_id_schedule         IN  NUMBER,
        pi_id_schedule_detail  IN  NUMBER,
        pi_schedule_fequency   IN  NUMBER
    ) RETURN VARCHAR2;


/*--------------- FNC08-------------------*/

    FUNCTION schedule_fequency_name (
        pi_schedule_fequency   IN  NUMBER,
        pi_schedule_init_date  IN  DATE
    ) RETURN VARCHAR2;

/*--------------- FNC09-------------------*/

    FUNCTION schedule_fequency_job (
        pi_schedule_fequency   IN  NUMBER,
        pi_schedule_init_date  IN  DATE
    ) RETURN VARCHAR2;    

/*--------------- FNC10-------------------*/
    FUNCTION fnc_request_icon_deploy (
        pi_id_status number
    ) return varchar2;


/*--------------- FNC11-------------------*/

    FUNCTION fnc_request_status (
        pi_id_control_deploy   NUMBER
    ) RETURN VARCHAR2;

/*--------------- FNC12-------------------*/

    FUNCTION fnc_request_progress (
    pi_id_request number
    ) return varchar2;

/*--------------- FNC13-------------------*/

    FUNCTION fnc_icon_flag (
        pi_id_request number,
        pi_env_hgroup varchar2
    ) return varchar2;

------------ PROCEDURES ------------------
/*--------------- DPCP1-------------------*/

    PROCEDURE manage_enviroment_pattern (
        pi_id_pattern     IN  NUMBER,
        pi_id_enviroment  IN  NUMBER,
        po_warning        OUT NOCOPY VARCHAR2
    );
/*--------------- DPCP2-------------------*/

    PROCEDURE manage_enviroment_request (
        pi_id_request         IN  NUMBER,
        pi_id_req_hgroup      IN  VARCHAR2,
        pi_id_deploying_tech  IN  NUMBER,
        pi_id_enviroment      IN  NUMBER,
        po_warning            OUT NOCOPY VARCHAR2
    );
/*--------------- DPCP3-------------------*/

    PROCEDURE manage_object_request (
        pi_id_request      IN  NUMBER,
        pi_id_req_hgroup   IN  VARCHAR2,
        pi_id_pattern      IN  NUMBER,
        pi_object_path     IN  VARCHAR2,
        pi_object_name     IN  VARCHAR2,
        pi_object_version  IN  VARCHAR2,
        pi_id_object_repo  IN  VARCHAR2,
        po_warning         OUT NOCOPY VARCHAR2
    );   
/*--------------- DPCP4-------------------*/

    PROCEDURE automatic_dep_control (
        pi_id_request         IN  INTEGER,
        pi_id_control_deploy  IN  INTEGER,
        pi_id_status          IN  INTEGER,
        pi_exec_message       IN  VARCHAR2,
        pi_exec_date          IN  VARCHAR2,
        po_warning            OUT NOCOPY VARCHAR2
    );

/*--------------- DPCP5-------------------*/

    PROCEDURE first_dep_control (
        pi_id_request   IN  NUMBER,
        pi_id_user      IN  NUMBER,
        pi_queue_alias  IN  VARCHAR2,
        n_red           OUT NOCOPY request_exec_deploy%rowtype
    );        

/*--------------- DPCP6-------------------*/

    PROCEDURE next_dep_control (
        n_red IN OUT NOCOPY request_exec_deploy%rowtype
    ); 

/*--------------- DPCP7-------------------*/

    PROCEDURE update_dep_control (
        pi_id_request         IN   NUMBER,
        pi_id_control_deploy  IN   NUMBER,
        pi_id_prc_exec        IN   VARCHAR2,
        pi_status             IN   NUMBER,
        pi_exec_message       IN   VARCHAR2,
        po_result             OUT  INTEGER -- 0: Sin actualizaciones , 1: Con actualizaciones 
    ); 

/*--------------- DPCP8-------------------*/

    PROCEDURE execution_status (
        pi_id_request         IN  NUMBER,
        pi_environment_alias  IN  VARCHAR2,
        pi_id_det_req         IN  NUMBER,
        pi_id_prc_exec        IN  VARCHAR2,
        pi_status             IN  NUMBER,
        pi_exec_message       IN  VARCHAR2,
        pi_exec_date          IN  VARCHAR2
    );

/*--------------- DPCP9-------------------*/

    PROCEDURE delete_references (
        pi_id_request    IN  NUMBER,
        pi_id_reference  IN  VARCHAR2,
        po_warning       OUT NOCOPY VARCHAR2
    ); 

/*--------------- DPCP10-------------------*/

    PROCEDURE manage_references (
        pi_id_request        IN  NUMBER,
        pi_id_reference      IN  VARCHAR2,
        pi_id_reference_des  IN  VARCHAR2,
        po_warning           OUT NOCOPY VARCHAR2
    );

/*--------------- DPCP11-------------------*/

    PROCEDURE manage_dep_queue (
        pi_id_request IN NUMBER
    );

/*--------------- DPCP12-------------------*/

    PROCEDURE first_dep_queue (
        pi_job_name IN VARCHAR2
    );

/*--------------- DPCP13-------------------*/

    PROCEDURE next_dep_queue (
        pi_id_request   IN  NUMBER DEFAULT 0,
        pi_queue_alias  IN  VARCHAR2
    );

/*--------------- DPCP14-------------------*/

    PROCEDURE manage_dep_job (
            pi_job_n_name  IN  VARCHAR2,
            pi_job_o_name  IN  VARCHAR2,
            pi_job_status  IN  NUMBER,
            pi_freq        IN  NUMBER,
            pi_start_date  IN  DATE
        );

/*---------------DPCP15--------------------*/
    PROCEDURE manage_req_object_order (
        pi_id_dep_req_object  IN  NUMBER,
        pi_id_req_hgroup      IN  VARCHAR2
    );

/*---------------DPCP16--------------------*/
    PROCEDURE manage_req_hgroup_order (
        pi_id_request           IN  NUMBER,
        pi_id_req_hgroup_level  IN  VARCHAR2,
		pi_id_parent_req_hgroup IN  VARCHAR2
    );

/*---------------DPCP17--------------------*/
    PROCEDURE p_genera_job(

          pi_job_nombre IN VARCHAR2,
          pi_job_accion IN VARCHAR2,
          pi_job_tipo_frecuencia IN NUMBER,
          pi_job_fecha_inicio IN TIMESTAMP,
          po_estado     OUT    NUMBER
       );

/*---------------DPCP18--------------------*/
    PROCEDURE p_elimina_job(
          pi_nombre_job IN OUT CLOB
       );

END pkg_deploy_coordinator;

/
