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

  EXCEPTION  
    WHEN e_does_not_exists THEN
      NULL;
  END;
  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/goal.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" showSubmit="false" title="Goal" defaultFormHandler="xxas_goals_pkg.update_row_form_handler">
  <EditFields>
      <Hidden id="GOAL_ID"/>
      <Hidden id="PERF_PLAN_ID"/>
      <Hidden id="PERSON_ID"/>
      <Hidden id="ASSIGNMENT_ID"/>
      <Hidden id="PERF_PLAN_ENROLLMENT_ID"/>
      <Hidden id="CURRENT_STEP_ID"/>
      <Hidden id="PERF_REVIEW_STEP_ID"/>
      <Hidden id="PERF_REVIEW_FORM_ID"/>      
      <Hidden id="GOAL_STATE"/>
      <Poplist id="GOAL_TYPE_CODE" label="{message.XXAS_PERF_GOAL_TYPE}" required="true" listProvider="LOOKUP_TYPE:XXAS_GOAL_TYPE"/>
      <TextArea id="GOAL" label="{message.XXAS_PERF_GOAL}" maxChars="4000" required="true"/>
      <Poplist id="CATEGORY_CODE" label="{message.XXAS_EMP_ASSI_CAT}" listProvider="LOOKUP_TYPE:XXAS_GOAL_CATEGORY"/>
      <Poplist id="ACCESS_CODE" label="{message.XXAS_PERF_GOAL_ACCESS}" required="true" listProvider="LOOKUP_TYPE:XXAS_GOAL_ACCESS"/>
      <Combolist id="PARENT_GOAL_ID" label="{message.XXAS_PERF_GOAL_PARENT}" listProvider="REST:goals/by-plan/${field.PERF_PLAN_ID}/${field.PERSON_ID}"/>
      <Number id="WEIGHTING_PERCENT" label="{message.XXAS_PERF_GOAL_WEIGHT}"/>
      <Date id="START_DATE" label="{message.XXAS_EMP_START_DATE}"/>
      <Date id="DUE_DATE" label="{message.XXAS_PERF_GOAL_DUE_DATE}"/>
      <Poplist id="GOAL_STATUS_CODE" label="{message.XXAS_EMP_ASSI_STATUS}" listProvider="LOOKUP_TYPE:XXAS_GOAL_STATUS" />
      <Number id="COMPLETE_PERCENT" label="{message.XXAS_PERF_GOAL_COMPLETE}"/>
      <Flexfield applicationShortCode="XXAS" descriptiveFlexfieldName="XXAS_GOALS"/>
      <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> 
	    <Container type="submit-group">
        <Submit id="ADD" label="{message.XXAS_RB_COM_SAVE}" color="balanced" refreshOnChange="true"/>
        <Submit id="ADD_ANOTHER" label="{message.XXAS_PERF_SAVE_AND_ADD}" weight="light" refreshOnChange="true"/>
      </Container>
  </EditFields>
</View>
' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/goal.xml');
END;
/
COMMIT;
EXIT;



	
