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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/vacancyteam.xml',
'<View title="Vacancy team members" defaultFormHandler="xxas_vacancy_pkg.commit_form_data" objectType="XXAS_IRC_REC_TEAM_MEMBER" deleteAllowed="true" deleteLabel="Delete">

  <CreateFields>
  
    <Hidden id="REC_TEAM_MEMBER_ID"/>
    <Combolist id="PERSON_ID" label="Name" longlist="true" listProvider="REST:peoplesearch" required="true"/>
    <Hidden id="PARTY_ID"/>
    <Hidden id="VACANCY_ID"/>
    <Hidden id="JOB_ID"/>
    <Date id="START_DATE" label="Effective From" required="true"/>
    <Date id="END_DATE" label="Effective To" required="false"/>
    <Poplist id="UPDATE_ALLOWED" label="Update Allowed" listProvider="LOOKUP_TYPE:YES_NO" required="true"/>
    <Poplist id="DELETE_ALLOWED" label="Delete Allowed" listProvider="LOOKUP_TYPE:YES_NO"/>
    <Hidden id="OBJECT_VERSION_NUMBER"/>
    <Hidden id="LAST_UPDATE_DATE"/>
    <Hidden id="LAST_UPDATED_BY"/>
    <Hidden id="LAST_UPDATE_LOGIN"/>
    <Hidden id="CREATED_BY"/>
    <Hidden id="CREATION_DATE"/>
    
  </CreateFields>

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