/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2016 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/menu.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/menu.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="Menu" defaultFormHandler="xxas_emp_menu_pkg.post_menu_create">

  <EditFields>

      <Hidden id="MENU_ID"/>
      <Poplist id="MENU_TYPE" label="{message.XXAS_MENU_TYPE}" listProvider="LOOKUP_TYPE:XXAS_MENU_TYPES" required="true" enabled="true"/>
      <TextInput id="TITLE" label="{message.XXAS_MENU_USER_MENU_NAME}" emptyValue="Enter a title" required="true"/>
      <Hidden id="USER_MENU_NAME"/>
      <TextInput id="MENU_NAME" label="{message.XXAS_MENU_NAME}" enabled="false" hideIf="!model.MENU_ID.value"/>
      <TextInput id="DESCRIPTION" label="{message.XXAS_MENU_DESCRIPTION}" emptyValue="Enter a description" description="The menu description is for informational purposes only" 
       required="false" visible="false"/>
      <TextInput id="OBJECT_ID_FORMAT" label="{message.XXAS_MENU_OBJECT_ID_FORMAT}" emptyValue="Ex: {PERSON_ID}" 
       description="Separate multiple contexts with an undescore, eg, {PERSON_ID}_{ASSIGNMENT_ID}" 
       hideIf="!model.MENU_TYPE.value || model.MENU_TYPE.value.id != &apos;S&apos;"/>
      <TextInput id="CONTEXT_HANDLER" label="{message.XXAS_MENU_CONTEXT_HANDLER}" emptyValue="PLSQL package function"  
       hideIf="!model.MENU_TYPE.value || model.MENU_TYPE.value.id != &apos;S&apos;" required="false"/>
      <TextInput id="SUBNAV_HEADER" label="{message.XXAS_MENU_SUBNAV_HEADER}" emptyValue="PLSQL package function"  
       hideIf="!model.MENU_TYPE.value || model.MENU_TYPE.value.id != &apos;S&apos;" required="false"/>

  </EditFields>

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