/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2017 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 

  e_dir_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_dir_exists, -31003);

  e_does_not_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_does_not_exists , -31001);

  result boolean;
  
BEGIN

  BEGIN

    result := DBMS_XDB.createfolder('/public/xxas/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/view/');

  EXCEPTION
    WHEN e_dir_exists THEN
      NULL;
  END;

  
  BEGIN

    DBMS_XDB.DeleteResource('/public/xxas/emp/view/dor-review.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/dor-review.xml',
'<View showSubmit="true" title="Approvers" defaultFormHandler="xxas_dor_pkg.submit_dor_event">
  <EditFields>

    <Hidden id="EFFECTIVE_DATE"/>
    <Hidden id="PERSON_ID"/>
    <Hidden id="DOCUMENT_EXTRA_INFO_ID"/>
    <Hidden id="TRANSACTION_ID"/>
    <Hidden id="TRANSACTION_STEP_ID"/>
    <Hidden id="SOURCE_BLOCK"/>
    <Hidden id="SAVED_SEARCH_ID"/>
    <ListItem id="APPROVERS" style="row" listFunction="xxas_selfservice_workflow_pkg.get_workflow_details2"/>

  </EditFields>

</View>' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/dor-review.xml');
END;
/
COMMIT;
EXIT;