/* $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 

  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/flexibleview.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/flexibleview.xml',
'<View showSubmit="false" title="Flexible view" defaultFormHandler="">

  <EditFields>
    <Html id="MESSAGE"/>
    <Item id="ROW_HEADER"/>
    <ListItem id="APPROVERS" style="row" listFunction="xxas_selfservice_workflow_pkg.get_workflow_details2"/>
    <Html id="ITEM1"/>
    <Html id="ITEM2"/>
    <Html id="ITEM3"/>
    <Html id="ITEM4"/>
    <Html id="ITEM5"/>
    <Html id="ITEM6"/>
    <Html id="ITEM7"/>
    <Html id="ITEM8"/>
    <Html id="ITEM9"/>
    <Html id="ITEM10"/>
    <Html id="ITEM11"/>
    <Html id="ITEM12"/>
    <Html id="ITEM13"/>
    <Html id="ITEM14"/>
    <Html id="ITEM15"/>
    <Html id="ITEM16"/>
    <Html id="ITEM17"/>
    <Html id="ITEM18"/>
    <Html id="ITEM19"/>
    <Html id="ITEM20"/>
    <Html id="ITEM21"/>
    <Html id="ITEM22"/>
    <Html id="ITEM23"/>
    <Html id="ITEM24"/>
    <Html id="ITEM25"/>
    <Html id="ITEM26"/>
    <Html id="ITEM27"/>
    <Html id="ITEM28"/>
    <Html id="ITEM29"/>
    <Html id="ITEM30"/>
    
    <Container id="ATTACH_GRP" label="Attachments">
      <MultiRow id="ATTACHMENTS" xdbUri="/public/xxas/emp/view/flexattach.xml" />
    </Container>
    
  </EditFields>

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