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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/link-view.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}">
  <EditFields>
    <Hidden id="FUNCTION_ID"/>
    <Hidden id="LINK_FUNCTION_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" required="false" allowEmpty="true" preferredFormat="hex"/>
    <TextInput id="GROUPS" label="Tags" required="true" emptyValue="Ex: quicklinks, mss, absence"/>
    <Combolist id="TYPE_OF_LINK" label="Type of link" listProvider="VALUE_SET_NAME:XXAS_LINK_TYPES"/>
    <Combolist id="PAGE_ID" label="Page Id" hideIf="model.TYPE_OF_LINK.value.id != &apos;Applaud page&apos;" longlist="true" listProvider="REST:pages?q={searchText}"/>
    <TextInput id="OBJECT_ID" label="Object Id" required="false" hideIf="!model.PAGE_ID.value"/>
    <Combolist id="RESP_KEY" label="Responsibility" 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="false" 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" description="This is a SSHR function that supports Personal or Manager actions" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" value="N" positiveBooleanValue="Y"/>
    <TextInput id="ACTIONS_MENU" label="Actions menu" enabled="false"/>
    <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"/>
    <Poplist id="SECURITY_GROUP" label="Security group" listProvider="VALUE_SET_NAME:Applaud Links Security groups"/>
  </EditFields>
</View>
' ); 
END;
/
COMMIT;
EXIT;
