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

  EXCEPTION  
    WHEN e_does_not_exists THEN
      NULL;
  END;
  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/edit-competenceelements.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" showSubmit="true" title="Competency" defaultFormHandler="xxas_competence_elements_pkg.update_row_form_handler">
 <EditFields>
 <Container>      
      <Hidden id="PERF_REVIEW_FORM_ID"/>   
      <Hidden id="PERF_REVIEW_STEP_ID"/>      
      <Hidden id="PERSON_ID"/>      
      <Hidden id="PERF_PLAN_ENROLLMENT_ID"/>      
      <Hidden id="COMPETENCE_ELEMENT_ID"/>
      <Hidden id="COMPETENCE_ID"/>			
			<Hidden id="SOURCE"/>		
      <TextInput id="COMPETENCE_NAME" label="{message.XXAS_COMPE_COMPETENCY}" enabled="false" longlist="true" required="true"/>
      <Poplist id="PROFICIENCY_LEVEL_ID" label="{message.XXAS_COMPE_PROFI_LEVEL}" listProvider="REST:competency/${field.COMPETENCE_ID}/proficiencies" hideIf="!model.COMPETENCE_ID.value"/>      
      <Number id="WEIGHTING_PERCENT" label="{message.XXAS_PERF_GOAL_WEIGHT}"  visible="false"/>   
      <Date id="COMPE_START_DATE" label="{message.XXAS_COMPE_START_DATE}" required="true"/>
      <Date id="COMPE_END_DATE" label="{message.XXAS_COMPE_END_DATE}"/>      
      <Container id="ATTACH_GRP" label="{message.XXAS_RB_EMP_ATTACHMENTS}" visible="false">
        <MultiRow id="ATTACHMENTS" createAllowed="true" toBeInSingleRow="true" visible="true" xdbUri="/public/xxas/emp/view/attach_goal.xml"/>
      </Container>
      <Poplist id="EXTRA_FIELDS" label="" showAsBoolean="true" listProvider="LOOKUP_TYPE:YES_NO" positiveBooleanValue="Y" value="N" description="Show more"/>      
      <Poplist id="ACQUIRED_BY" label="{message.XXAS_COMPE_ACQ_BY}" listProvider="VALUE_SET_NAME:Applaud Competency Proficiency Source" hideIf="model.EXTRA_FIELDS.value == &apos;N&apos;"/>      
      <Poplist id="MEASURED_BY" label="{message.XXAS_COMPE_MEA_BY}" listProvider="VALUE_SET_NAME:Applaud Competency Certification Methods" visible="true" hideIf="model.EXTRA_FIELDS.value == &apos;N&apos;"/>
      <Date id="CERTIFICATION_DATE" label="{message.XXAS_COMPE_CERT_DATE}" visible="true" hideIf="model.EXTRA_FIELDS.value == &apos;N&apos;"/>    
      <Date id="NEXT_REVIEW_DATE" label="{message.XXAS_COMPE_REV_DATE}" visible="true" hideIf="model.EXTRA_FIELDS.value == &apos;N&apos;"/>     
      <TextInput id="JUSTIFICATION" label="{message.XXAS_COMPE_JUSTIFY}" visible="true" hideIf="model.EXTRA_FIELDS.value == &apos;N&apos;"/>
      <Flexfield applicationShortCode="PER" descriptiveFlexfieldName="PER_COMPETENCE_ELEMENTS" hideIf="model.EXTRA_FIELDS.value == &apos;N&apos;"/>       
 </Container>      
 </EditFields>
</View>
' ); 
END;
/
COMMIT;
EXIT;