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

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

DECLARE

  --
  -- Local constants and variables
  --
  l_SERVICE CONSTANT xxas_com_service_repository.service_name%TYPE
                       := 'Search';

BEGIN

  xxas_com_sr_pkg.set_rest_service
    (p_service_name       => l_SERVICE
    ,p_description        => 'Search-related resources and pages'
    ,p_consumes           => 'application/xml'
    ,p_produces           => 'application/xml');

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'Search'
    ,p_description        => 'Runs a Search'
    ,p_methods            => 'GET'
    ,p_path               => 'search'
    ,p_remove_root_ele    => true
    ,p_sql                =>
      q'[
        SELECT xxas_search_pkg.search_xml
                 ({requestParam.searchText} /* p_keywords */
                 ,{requestParam.objectType} /* p_object_types */
                 ,NULL
                 ,NULL
                 ,{requestParam.pageNum}
                 ,{requestParam.pageSize}
                 ,'N'    /* p_use_wildcards */
                 ,'N'    /* p_stem */
                 ,'N'    /* p_fuzzy */
                 ,'N'    /* p_soundex */
                 ,'N'    /* p_synonym */
                 ,'N'    /* p_or_if_no_results */
                 ,{requestParams}
                 ) "data"
        FROM   dual
        ]'
    );

  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'SearchItems'
    ,p_description        => 'Runs a Search'
    ,p_methods            => 'GET'
    ,p_path               => 'search-items'
    ,p_remove_root_ele    => true
    ,p_sql                =>
      q'[
				
        SELECT xxas_search_pkg.search_xml
                 ({requestParam.searchText} /* p_keywords */
                 ,{requestParam.objectType} /* p_object_types */
                 ,NULL
                 ,NULL
                 ,{requestParam.pageNum}
                 ,{requestParam.pageSize}
                 ,'N'    /* p_use_wildcards */
                 ,'N'    /* p_stem */
                 ,'N'    /* p_fuzzy */
                 ,'N'    /* p_soundex */
                 ,'N'    /* p_synonym */
                 ,'N'    /* p_or_if_no_results */
                 ,{requestParams}) "data"
        FROM   dual
        ]'
    );
    
  xxas_com_sr_pkg.set_rest_method
    (p_service_name       => l_SERVICE
    ,p_method_name        => 'GetSearchPage'
    ,p_description        => 'Gets the Search Page'
    ,p_methods            => 'GET'
    ,p_path               => 'search-page'
    ,p_remove_root_ele    => true
    ,p_sql                =>
      q'[
        SELECT xxas_emp_menu_pkg.get_page_xml('search') "data"
        FROM dual
        ]'
    );


END;
/
COMMIT;
EXIT;
