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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  result := DBMS_XDB.createresource('/public/xxas/emp/view/wldelegateaccess.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="{message.XXAS_NOTIF_CREATE_USER_ACCESS}" defaultFormHandler="=xxas_com_worklist_pkg.update_wl_user_access">
  <EditFields>
    <Hidden id="GRANT_GUID"/>
    <Hidden id="PERSON_ID"/>
    <Combolist id="GRANTEE" label="{message.XXAS_NOTIF_GRANTEE}" listProvider="VALUE_SET_NAME:XXAS_WF_ROLES" longlist="true"/>
    <DateRange id="DATE_RANGE" label="{message.XXAS_NOTIF_EFFECTIVE}" startDateLabel="{message.XXAS_NOTIF_FROM}" endDateLabel="{message.XXAS_NOTIF_TO}" visible="true" enabled="true" required="true" startDateRequired="true"/>
    <TextInput id="TITLE" label="{message.XXAS_NOTIF_TITLE}" description="{message.XXAS_NOTIF_TITLE_DESC}" emptyValue="{message.XXAS_NOTIF_TITLE_VALUE}"/>
    <Poplist id="ALL_NOTIF" label="{message.XXAS_NOTIF_ALL_NOTIFICATIONS}" value="Y" description="{message.XXAS_NOTIF_ALL_NOTIF_DESC}" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>
    <Combolist id="ITEM_TYPE" label="{message.XXAS_NOTIF_TYPE_NOTIF}" enabled="true" multipleSelection="true" listProvider="REST:wfitemtypes" required="true" hideIf="model.ALL_NOTIF.value != &apos;N&apos;"/>
  </EditFields>
</View>
' ); 


xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/wldelegateaccess.xml');
END;
/
COMMIT;
EXIT;
