/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2016 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

create or replace view xxas_rest_services_v as
select r.service_name service_name,
       m.description,
       nvl(xxas_com_rest_util_pkg.remove_fwd_trailing_slash
           (extractvalue
            (r.seeded_descriptor, '/ServiceDescriptor/@path')),'/') path,
		m.consumes  consumes,
        m.produces  produces,
        r.enabled_flag
FROM      xxas_com_service_repository r
           ,XMLTable
             ('//ServiceDescriptor' PASSING r.seeded_descriptor
                         COLUMNS name varchar2(400) PATH '@name'
                                ,description        varchar2(4000) PATH '@description'
                                ,path               varchar2(400) PATH  '@path'
								                ,consumes           varchar2(4000) PATH '@consumes'
                                ,produces           varchar2(4000) PATH '@produces'
                               ) m
  where extractvalue(r.seeded_descriptor, '/ServiceDescriptor/@name') is not null
  and r.service_name =  m.name
  ORDER BY r.service_name;
BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'xxas_rest_services_v'
   ,p_description            => 'Applaud Rest Services');
END;
/
COMMIT;
EXIT;
