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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/vacancycompetencies.xml',
'<View title="Vacancy competencies" defaultFormHandler="xxas_vacancy_pkg.commit_form_data" objectType="XXAS_PER_COMPETENCE_ELE" deleteAllowed="true" deleteLabel="{message.XXAS_RB_COM_DEL}">

  <CreateFields>
  
    <Hidden id="COMPETENCE_ELEMENT_ID"/>
    <Hidden id="OBJECT_VERSION_NUMBER"/>
    <Hidden id="TYPE_CODE" value="REQUIREMENT"/>
    <Poplist id="COMPETENCE_ID" label="Skill" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Vac_Competences" required="true"/>
    <Poplist id="PROFICIENCY_LEVEL_ID" label="Level Required" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Vac_Competence_Rating"/>
    <Poplist id="HIGH_PROFICIENCY_LEVEL_ID" label="Maximum Level" listProvider="VALUE_SET_NAME:XXAS_Recruiting_Vac_Competence_Rating"/>
    <Poplist id="MANDATORY_CODE" label="Desirability" listProvider="LOOKUP_TYPE:IRC_SKILL_DESIRABILITY" required="true"/>
    <Flexfield applicationId ="800" descriptiveFlexfieldName="PER_COMPETENCE_ELEMENTS"/>

    <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/vacancycompetencies.xml'); 
END;
/
COMMIT;
EXIT;
