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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/link-add.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="Add link" defaultFormHandler="xxas_block_pkg.post_link_create">
  <EditFields>
    <Hidden id="FUNCTION_ID"/>
	<Hidden id="MENU_ID"/>
    <TextInput id="PROMPT" label="Title" required="true"/>
    <TextInput id="DESCRIPTION" label="Description" required="false" maxChars="240"/>
    <Number id="ENTRY_SEQUENCE" label="Order sequence" required="true"/>
    <Icon id="FUNCTION_ICON" label="Icon" required="true" maxChars="30"/>
    <ColorPicker id="COLOR" label="Color" description="Leave blank to use your theme&apos;s positive color" required="false" allowEmpty="true" preferredFormat="hex"/>
    <Hidden id="GROUPS" label="Tags" emptyValue="Ex: quicklinks, mss, absence" enabled="false"/>
    <Combolist id="TYPE_OF_LINK" label="Type of link" listProvider="VALUE_SET_NAME:XXAS_LINK_TYPES" value="Oracle Function"/>
    <Combolist id="PAGE_ID" label="Page Id" hideIf="model.TYPE_OF_LINK.value.id != &apos;Applaud page&apos;" longlist="true" required="true" listProvider="REST:pages?q={searchText}"/>
    <TextInput id="OBJECT_ID" label="Object Id" description="Hard-coded value or any of {INSTANCE_PK1_VALUE}.. {INSTANCE_PK5_VALUE}" required="false" hideIf="model.TYPE_OF_LINK.value.id != &apos;Applaud page&apos;"/>
    <Combolist id="RESP_KEY" description="The user will be swapped to this responsibility when using this link" label="Responsibility" refreshOnChange="true" listProvider="VALUE_SET_NAME:XXAS_APPLAUD_RESP" longlist="true" hideIf="model.TYPE_OF_LINK.value.id != &apos;Oracle Function&apos;"/>
    <Combolist id="FUNC_NAME" label="Function" listProvider="REST:link-tags/get_function/${field.RESP_KEY}" longlist="true" required="true" hideIf="model.TYPE_OF_LINK.value.id != &apos;Oracle Function&apos;"/>
    <TextInput id="URL" label="URL" required="true" hideIf="model.TYPE_OF_LINK.value.id != &apos;URL&apos;"/>
    <Poplist id="ACTION" label="SSHR action" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" enabled="false" value="N" positiveBooleanValue="Y"/>
    <Poplist id="NEW_BROWSER" label="Open in new browser tab" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" value="N" positiveBooleanValue="Y"/>
    <Hidden id="SECURITY_PROFILE" label="Security profile" listProvider="REST:link-tags/security_group"/>
    <Combolist id="SECURITY_GROUP" label="Security group" listProvider="VALUE_SET_NAME:Applaud Links Security groups" hideIf="!model.SECURITY_PROFILE.value || model.SECURITY_PROFILE.id == &apos;N&apos;"/>
  </EditFields>
</View>
' ); 
END;
/
COMMIT;
EXIT;