--------------------------------------------------------
--  DDL for View HIERARCHICAL_REPOSITORY_TECHS
--------------------------------------------------------

  CREATE OR REPLACE FORCE EDITIONABLE VIEW "ENVX_OPER"."HIERARCHICAL_REPOSITORY_TECHS" ("LEVEL_ALIAS", "ID", "PARENT_ID", "GROUP_ID", "LEVEL_PATH_ID", "LEVEL_ORDER", "LEVEL_NAME", "LEVEL_STATUS", "DESCRIPTION", "LEVEL_REAL_ID") AS 
  SELECT UNIQUE 'T'                            AS level_alias,
                 'T' || t.id_deploying_tech     AS id,
                 NULL                           AS parent_id,
                 r.id_repository                AS group_id,
                 to_char(
                    t.id_deploying_tech
                 ) AS level_path_id,
                 0                              AS level_order,
                 t.deploy_tech_name             AS level_name,
                 1                              AS level_status,
                 t.deploy_tech_description      AS description,
                 t.id_deploying_tech            AS level_real_id
             -------------------- FUNCTIONAL INFO -----------------------------                                  
             -----------------------------------------------------------------
     FROM deploying_tech      t,
          version_rep_tech    r
    WHERE t.id_deploying_tech = r.id_deploying_tech
   UNION ALL
   SELECT UNIQUE 'E'                              AS level_alias,
                 'E' || e.id_enviroment_type      AS id,
                 'T' || r.id_deploying_tech       AS parent_id,
                 r.id_repository                  AS group_id,
                 r.id_deploying_tech
                 || ','
                 || r.id_enviroment_type AS level_path_id,
                 0                                AS level_order,
                 e.enviroment_type_name           AS level_name,
                 1                                AS level_status,
                 e.enviroment_type_description    AS description,
                 e.id_enviroment_type             AS level_real_id
             -------------------- FUNCTIONAL INFO -----------------------------                                  
             -----------------------------------------------------------------
     FROM enviroment_type     e,
          version_rep_tech    r
    WHERE r.id_enviroment_type = e.id_enviroment_type
   UNION ALL
   SELECT UNIQUE 'P'                             AS level_alias,
                 'P' || r.id_rep_tech            AS id,
                 'E' || r.id_enviroment_type     AS parent_id,
                 r.id_repository                 AS group_id,
                 r.id_deploying_tech
                 || ','
                 || r.id_enviroment_type
                 || ','
                 || r.id_rep_tech AS level_path_id,
                 0                               AS level_order,
                 r.repository_path               AS level_name,
                 1                               AS level_status,
                 NULL                            AS description,
                 r.id_rep_tech                   AS level_real_id
             -------------------- FUNCTIONAL INFO -----------------------------                                  
             -----------------------------------------------------------------
     FROM version_rep_tech r
    WHERE r.id_enviroment_type IS NOT NULL
      AND r.repository_path is not null
;
