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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/personaddress.xml',
'<View title="Person address" defaultFormHandler="xxas_per_address_pkg">

  <CreateFields>

    <Poplist id="PRIMARY_FLAG" value="N" label="{message.XXAS_EMP_PRIMARY_ADDRESS_I}" enabled="true" required="true" visible="false" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>   
    <Poplist id="ADDRESS_TYPE" label="{message.XXAS_RB_NOTE_TYPE}" enabled="true" required="true" listProvider="LOOKUP_TYPE:ADDRESS_TYPE"/>
    <Date id="DATE_FROM" label="{message.XXAS_EMP_DATE_FROM}" enabled="true" required="true" visible="false"/>
    <Date id="DATE_TO" label="{message.XXAS_EMP_DATE_TO}" enabled="true" required="false" visible="false"/>
    <Flexfield applicationId ="800" descriptiveFlexfieldName="Address Structure"/>
    <Flexfield applicationId ="800" descriptiveFlexfieldName="PER_ADDRESSES"/>
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false"/>
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT"
                pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC"/>   
  </CreateFields>
  
  <EditFields>
    <Poplist id="ACTION_TYPE" value="CORRECT" refreshOnChange="true" label="{message.XXAS_EMP_CHNG_TYPE}" enabled="true" visible="false" listProvider="VALUE_SET_NAME:Applaud PI Action Type"/>   
    <Date id="DT_EFFECTIVE_DATE" label="{message.XXAS_EMP_ADDR_CHNG_DATE}" enabled="true" visible="false"/>
    <Poplist id="PRIMARY_FLAG" value="N" label="{message.XXAS_EMP_PRIMARY_ADDRESS_I}" enabled="true" required="true" visible="false" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y"/>   
    <Poplist id="ADDRESS_TYPE" label="{message.XXAS_RB_NOTE_TYPE}" enabled="true" required="true" visible="false" listProvider="LOOKUP_TYPE:ADDRESS_TYPE"/>
    <Date id="DATE_FROM" label="{message.XXAS_EMP_DATE_FROM}" enabled="true" required="true" visible="false"/>
    <Date id="DATE_TO" label="{message.XXAS_EMP_DATE_TO}" enabled="true" required="false" visible="false"/>
    <Flexfield applicationId ="800" descriptiveFlexfieldName="Address Structure"/>
    <Flexfield applicationId ="800" descriptiveFlexfieldName="PER_ADDRESSES"/>
    <TextInput id="COMMENTS_TO_APPROVER" label="{message.XXAS_RB_TCM_APPR_CMNTS}" enabled="true" required="false"/>
    <Attachment id="ATTACHMENTS" label="{message.XXAS_RB_EMP_ATTACHMENTS}" enabled="true" required="false" entityName="PQH_SS_ATTACHMENT"
                pk1Field="INSTANCE_PK2_VALUE" categoryCode="MISC"/>    
  </EditFields>

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