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

  EXCEPTION  
    WHEN e_does_not_exists THEN
      NULL;
  END;
  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/review-template.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" showSubmit="true" title="{message.XXAS_PG_ADD_REV_TEMPL_T}" defaultFormHandler="xxas_perf_review_templates_pkg.form_post_handler" formHelp="A review template defines the behaviour and steps involved in a performance review process. You can define multiple templates, such as a mid-year review and an end-of-year review.">
  <EditFields>
      <Hidden id="PERF_REVIEW_TEMPLATE_ID"/>
      <TextInput id="TEMPLATE_TITLE" label="{message.XXAS_BK_PROMPT}" required="true" description="This title is shown to users" emptyValue="Ex: Mid-year review"/>
      <TextArea id="DESCRIPTION" label="{message.XXAS_BK_DESCRIPTION}" required="true" emptyValue="{message.XXAS_PERF_ENTER_DESC}" description="This is also shown to users; it should contain enough detail so that a user understands what will happen if they choose this template when creating ad hoc reviews."/>
      <TextInput id="TEMPLATE_USAGE" label="{message.XXAS_PERF_USED_IN_REV}" enabled="false"/>
      <Poplist id="QUESTIONNAIRE_DFF_STRUCTURE" label="{message.XXAS_PERF_QUEST_TEMPL}" required="false" emptyValue="{message.XXAS_PERF_SELEC_QUESTDFF}" listProvider="REST:performance-templates/questionnaires" description="Define structures for the &lt;strong&gt;Performance Questionnaires&lt;/strong&gt; descriptive flexfield that contain a set of questions you would like users to capture as feedback."/>
      <Poplist id="ENABLED" label="{message.XXAS_RB_TCM_STATUS}" listProvider="LOOKUP_TYPE:XXAS_PERF_TEMPLATE_STATUS" required="true" value="Y"/>
  </EditFields>
</View>
' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/review-template.xml');
END;
/
COMMIT;
EXIT;
