  /* $Id$ */
  /*============================================================================*
   |                 Copyright (c) 2016 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/worklist-notif-edit.xml');

    EXCEPTION
      WHEN e_does_not_exists THEN
        NULL;
    END;

    
    result := DBMS_XDB.createresource('/public/xxas/emp/view/worklist-notif-edit.xml',
  '<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="{message.XXAS_NOTIF_WF_NOTIF}" defaultFormHandler="xxas_com_worklist_pkg.form_respond">
     <EditFields>
     <Hidden id="NOTIFICATION_ID"/>
	     <Container id="BASIC_GRP">
         <Hidden id="STATUS"/>
         <Hidden id="RESPONSE_EXISTS"/>
         <Hidden id="WF_NOTE_EXISTS"/>
         <Item id="LAST_COMMENT" style="row" itemFunction="xxas_com_worklist_pkg.get_last_comment"/>
         <Item id="RETURNED_BY" style="row" itemFunction="xxas_com_worklist_pkg.rfc_comments" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id != &apos;CONT_ACT&apos;"/>
         <Combolist id="RESPONSE" style="radio" label="{message.XXAS_NOTIF_RESPONSE}" listProvider="REST:/wfresponses/by-notification/${field.NOTIFICATION_ID}" 
                    required="true" hideIf="model.BASIC_GRP.STATUS.value!=&apos;OPEN&apos;" 
                    triggerName="WL_NOTIFIC_DYNAMIC_BUTTON" triggerMethod="POST"/>
         <Hidden id="RESPONSE_L"/>
       </Container>
       
       <!--More Info Role: Show this if Transfer/Answer is selected-->
         <Combolist id="REPLY_ASSIGNEE" label="{message.XXAS_NOTIF_TRANSFER_TO}" listProvider="REST:wfroles?q={searchText}" longlist="true" required="true"
                    hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;TRANSFER&apos;"/>
         <TextArea id="REPLY_ANSWER" label="{message.XXAS_NOTIF_ANSWER}" required="true" 
                   hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;ANSWER&apos;"/>
       
       <!--Show this if Reassign is selected-->
         <Combolist id="REASSIGN_ASSIGNEE" label="{message.XXAS_NOTIF_ASSIGNEE}"  listProvider="REST:wfroles?q={searchText}" required="true" longlist="true" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;REASSIGN&apos;"/>
         <Combolist id="REASSIGN_MODE" label="{message.XXAS_NOTIF_OWNERSHIP}" listProvider="LOOKUP_TYPE:XXAS_COM_NOT_REASSG_TYPES" required="true" triggerName="WL_NOTIFIC_REASSIGN_DESC" triggerMethod="POST" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;REASSIGN&apos;"/>
         <TextArea id="REASSIGN_COMMENTS" label="{message.XXAS_NOTIF_COMMENTS}" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;REASSIGN&apos;"/>
      
      <!--Show this if Delegate is selected-->
         <Combolist id="DELEGATE_ASSIGNEE" label="{message.XXAS_NOTIF_ASSIGNEE}"  listProvider="REST:wfroles?q={searchText}" required="true" longlist="true" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;DELEGATE&apos;"/>
         <TextArea id="DELEGATE_COMMENTS" label="{message.XXAS_NOTIF_COMMENTS}" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;DELEGATE&apos;"/>
       
       <!--Show this if Request More Information is selected-->
       <Container id="RMI_GRP" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id!=&apos;RMI&apos;">
         <Poplist id="REQ_INFO_FROM" label="{message.XXASS_NOTIF_REQ_FROM}" listProvider="REST:wfparticipants/forRMI" required="true" style="radio"
                  value="PARTICIPANT"/>
         <Poplist id="WF_PARTICIPANT" label="{message.XXAS_NOTIF_PARTICIPANT}" required="true"
                  hideIf="!model.RMI_GRP.REQ_INFO_FROM.value || model.RMI_GRP.REQ_INFO_FROM.value.id == &apos;ANYONE&apos;"/>
         <Combolist id="RMI_ASSIGNEE" label="{message.XXAS_NOTIF_ANYONE}" listProvider="REST:wfroles?q={searchText}" longlist="true" required="true"
                  hideIf="!model.RMI_GRP.REQ_INFO_FROM.value || model.RMI_GRP.REQ_INFO_FROM.value.id == &apos;PARTICIPANT&apos;"/>
         <TextArea id="RMI_COMMENTS" label="{message.XXAS_NOTIF_INFO_REQ}" required="true"
                  hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id==&apos;_CLOSE&apos;"/>
       </Container>
       
       <!--Show this if Approve/Reject is selected-->
       <!--TextArea id="COMMENTS" label="{message.XXAS_NOTIF_COMMENTS}" hideIf="model.BASIC_GRP.RESPONSE.value==null || !(model.BASIC_GRP.RESPONSE.value.id==&apos;APPROVED&apos; || model.BASIC_GRP.RESPONSE.value.id==&apos;REJECTED&apos;)"/-->
       
       <!--Show this for RFC notifications-->
       <Container id="RFC_GRP" hideIf="model.BASIC_GRP.RESPONSE.value==null || model.BASIC_GRP.RESPONSE.value.id != &apos;RFC&apos;" >
         <Poplist id="RETURN_TO" required = "true" label="{message.XXAS_NOTIF_RET_TO}"/>
         <TextArea id="RFC_NOTE" label="{message.XXAS_NOTIF_NOTE}"/>
       </Container>
       
       <!--Show this for closed notifications-->
       <Container id="CLOSED_GRP" hideIf="model.BASIC_GRP.WF_NOTE_EXISTS.value==&apos;N&apos;||model.BASIC_GRP.RESPONSE.value.id==&apos;RFC&apos;">
         <TextArea id="RESPONSE_MEANING" label="{message.XXAS_NOTIF_RESPONSE}" enabled="false"/>
         <TextArea id="WF_NOTES" label="{message.XXAS_NOTIF_NOTE}" enabled="false"/>
       </Container>
       
     </EditFields>
  </View>' ); 
  xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/worklist-notif-edit.xml');
  END;
  /
  COMMIT;
  EXIT;
