/* $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/vacationrulecreate.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  result := DBMS_XDB.createresource('/public/xxas/emp/view/vacationrulecreate.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="Create vacation rule" defaultFormHandler="=xxas_com_worklist_pkg.create_vacation_rule">
  <EditFields>
    <Hidden id="PERSON_ID"/>
    <Poplist id="RESPONSE_TYPE" label="{message.XXAS_NOTIF_RULE}" listProvider="LOOKUP_TYPE:XXAS_COM_NOT_VAC_RULES" required="true" triggerName="WL_NOTIF_VAC_RESPONSE_TYPE" triggerMethod="POST"/>
    <Combolist id="ACTION" label="{message.XXAS_NOTIF_OWNERSHIP}" listProvider="LOOKUP_TYPE:XXAS_COM_NOT_REASSG_TYPES" hideIf="model.RESPONSE_TYPE.value==null || model.RESPONSE_TYPE.value.id!=&apos;REASSIGN&apos;" triggerName="WL_NOTIF_VAC_ACTION_DEC" triggerMethod="POST"/>
    <Combolist id="ACTION_ARGUMENT" label="{message.XXAS_NOTIF_ASSIGNEE}" listProvider="REST:wfroles/vac-rule-roles?q={searchText}" required="true" longlist="true" hideIf="model.RESPONSE_TYPE.value==null || model.RESPONSE_TYPE.value.id!=&apos;REASSIGN&apos;"/>
    <DateTimeRange id="DATE_TIME_RANGE" label="{message.XXAS_NOTIF_EFFECTIVE}" startDateLabel="{message.XXAS_NOTIF_FROM}" endDateLabel="{message.XXAS_NOTIF_TO}" 
     startTimeLabel="{message.XXAS_NOTIF_START_TIME}" startTimeDescription="{message.XXAS_NOTIF_DTR_ST_DESCR}" endTimeLabel="{message.XXAS_NOTIF_END_TIME}" endTimeDescription="{message.XXAS_NOTIF_DTR_ET_DESCR}"
     visible="true" enabled="true" required="true" startDateRequired="true"/>
    <Poplist id="ALL_NOTIF" label="{message.XXAS_NOTIF_ALL_NOTIFICATIONS}" value="N" description="This rule applies to all notifications" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y" hideIf="model.RESPONSE_TYPE.value==null"/>
    <Poplist id="MESSAGE_TYPE" label="{message.XXAS_NOTIF_TYPE_NOTIF}" enabled="true" listProvider="REST:wfitemtypes" required="true" hideIf="model.ALL_NOTIF.value != &apos;N&apos;" triggerName="WL_NOTIF_VAC_RULES" triggerMethod="POST"/>
    <Poplist id="MESSAGE_NAME" label="{message.XXAS_NOTIF_NOTIF}" enabled="true" required="true" hideIf="model.ALL_NOTIF.value != &apos;N&apos;|| model.MESSAGE_TYPE.value == null" triggerName="WL_NOTIF_VAC_RESPONSE_LOV" triggerMethod="POST"/>
    <Poplist id="RESPONSE_LOV" label="{message.XXAS_NOTIF_RESPONSE}" hideIf="model.RESPONSE_TYPE.value.id != &apos;CLOSE&apos;"/>
    <TextArea id="RESPONSE_TEXT" label="{message.XXAS_NOTIF_RESP_MSG}" hideIf="model.RESPONSE_TYPE.value.id != &apos;CLOSE&apos;"/>
    <TextArea id="RULE_COMMENT" label="{message.XXAS_NOTIF_MSG}" description="Optional message to show in each routed notification" emptyValue="Enter routing message"/>
  </EditFields>
</View>
' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/vacationrulecreate.xml');
END;
/
COMMIT;
EXIT;
