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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/vacancyapplicant.xml',
'<View title="Vacancy applicant" defaultFormHandler="xxas_vacancy_pkg.commit_form_data">

  <CreateFields>
    <Container id="BASIC" label="Basic Details" layout="FORM">
      <TextInput id="XXX_CONCAT_ADDRESS" label="Address" visible="false"/>
      <Flexfield applicationId ="800" descriptiveFlexfieldName="Address Structure"/>
      <Flexfield applicationId ="800" descriptiveFlexfieldName="PER_PEOPLE"/>
      <TextInput id="LAST_QUAL" label="Last Qualification"/>
      <TextInput id="CORRESPONDENCE_LANGUAGE" label="Preferred Language"/>
      <TextInput id="ACTIVE_APPLICATIONS_COUNT" label="Active Job Applications"/>		
    </Container>

    <Container id="PHONE_NUMBERS_GRP" label="Phone Numbers" layout="TABULAR">
      <MultiRow id="PHONE_NUMBERS" label="Phone Numbers" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/appl_phone_numbers.xml"/>
    </Container>	

    <Container id="ASSESSMENTS_GRP" label="Assessments" layout="TABULAR">
      <MultiRow id="ASSESSMENTS" label="Assessments" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/assessments.xml"/>
    </Container>		
		
    <Container id="EEO" label="EEO Information" layout="FORM">
      <TextInput id="SEX" label="Sex"/>
      <Flexfield applicationId="800" descriptiveFlexfieldName="Person Developer DF"/>	  
    </Container>	
    
    <Container id="WORK_PREFERENCES" label="Work Preferences" layout="FORM">
      <TextInput id="KEYWORDS" label="Keywords"/>
      <TextInput id="DISTANCE_TO_LOCATION_INT" label="Distance From Location(Miles)"/>
      <TextInput id="AMOUNT_OF_TRAVEL" label="Amount of Travel"/>
      <TextInput id="WORK_FROM_HOME" label="Work From Home"/>
      <TextInput id="EMPLOYEE_DISPLAY" label="Employee"/>
      <TextInput id="CONTRACTOR_DISPLAY" label="Contractor"/>
      <TextInput id="PROFESSIONAL_AREA_STR" label="Professional Area"/>	
      <TextInput id="LOCATION" label="Location"/>
      <TextInput id="EMP_CATEGORY" label="Employment Category"/>
      <TextInput id="CURRENCY" label="Currency"/>
      <TextInput id="MATCH_COMPETENCIES" label="Match Competencies"/>	
      <TextInput id="MATCH_QUALIFICATIONS" label="Match Qualifications"/>
      <Flexfield applicationId ="800" descriptiveFlexfieldName="IRC_SEARCH_CRITERIA" columnNamePrefix="ISC_"/>	  
    </Container>	
	
    <Container id="PREVIOUS_EMPLOYERS_GRP" label="Previous Employers" layout="TABULAR">
      <MultiRow id="PREVIOUS_EMPLOYERS" label="Previous Employers" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/previous_employers.xml"/>
    </Container>
    
    <Container id="QUALIFICATIONS_GRP" label="Qualifications" layout="TABULAR">
      <MultiRow id="QUALIFICATIONS" label="Qualifications" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/applicantqualification.xml"/>
    </Container>

    <Container id="ADDL_QUALIFICATIONS_GRP" label="Additional Qualifications" layout="TABULAR">
      <MultiRow id="ADDL_QUALIFICATIONS" label="Additional Qualifications" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/applicantadditionalqualification.xml"/>
    </Container>
		
    <Container id="COMPETENCIES_GRP" label="Competencies" layout="TABULAR">
      <MultiRow id="COMPETENCIES" label="Competencies" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/applicantcompetencies.xml"/>
    </Container>
    
    <Container id="JOBS_CONSIDERED_FOR_GRP" label="Jobs Considered For" layout="TABULAR">
      <MultiRow id="JOBS_CONSIDERED_FOR" label="Jobs Considered For" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/apljobsconsideredfor.xml"/>
    </Container>

    <Container id="OTHER_JOB_APPLICATIONS_GRP" label="Other Job Applications" layout="TABULAR">
      <MultiRow id="OTHER_JOB_APPLICATIONS" label="Other Job Applications" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/otherjobapplications.xml"/>
    </Container>

    <Container id="ASSIGNMENT_HISTORY_GRP" label="Application History" layout="TABULAR">
      <MultiRow id="ASSIGNMENT_HISTORY" label="Application History" toBeInSingleRow="true" xdbUri="/public/xxas/emp/view/assignmenthistory.xml"/>
    </Container>
	
  </CreateFields>

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