&ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
&ANALYZE-RESUME
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Check Version Notes Wizard" Procedure _INLINE
/* Actions: af/cod/aftemwizcw.w ? ? ? ? */
/* MIP Update Version Notes Wizard
Check object version notes.
af/cod/aftemwizpw.w
*/
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Update-Object-Version" Procedure _INLINE
/* Actions: ? ? ? ? af/sup/afverxftrp.p */
/* This has to go above the definitions sections, as that is what it modifies.
   If its not, then the definitions section will have been saved before the
   XFTR code kicks in and changes it */
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Definition Comments Wizard" Procedure _INLINE
/* Actions: ? af/cod/aftemwizcw.w ? ? ? */
/* Program Definition Comment Block Wizard
Welcome to the Program Definition Comment Block Wizard. Press Next to proceed.
af/cod/aftemwizpw.w
*/
/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Procedure 
/*********************************************************************
* Copyright (C) 2000 by Progress Software Corporation ("PSC"),       *
* 14 Oak Park, Bedford, MA 01730, and other contributors as listed   *
* below.  All Rights Reserved.                                       *
*                                                                    *
* The Initial Developer of the Original Code is PSC.  The Original   *
* Code is Progress IDE code released to open source December 1, 2000.*
*                                                                    *
* The contents of this file are subject to the Possenet Public       *
* License Version 1.0 (the "License"); you may not use this file     *
* except in compliance with the License.  A copy of the License is   *
* available as of the date of this notice at                         *
* http://www.possenet.org/license.html                               *
*                                                                    *
* Software distributed under the License is distributed on an "AS IS"*
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. You*
* should refer to the License for the specific language governing    *
* rights and limitations under the License.                          *
*                                                                    *
* Contributors:                                                      *
*                                                                    *
*********************************************************************/
/*---------------------------------------------------------------------------------
  File: afomsloadp.p

  Description:  Object Menu Structure Load Procedure

  Purpose:      This procedure takes a flat file name as an input parameter and loads all
                the object menu structures in the flat file back into the object menu
                structure table.
                The flat file must have been generated by af/sup/afomsdumpp.p
                The data is converted to actual object numbers in the connected database.
                If objects or menu structures do not exist, they will be ignored.
                Any rejections are reported back to the caller via an output
                parameter.

  Parameters:   ip_dump_file_name
                op_rejection_list

  History:
  --------
  (v:010000)    Task:        1277   UserRef:    
                Date:   28/04/1999  Author:     Anthony Swindells

  Update Notes: Created from Template aftemprocp.p

  (v:010001)    Task:        3429   UserRef:    
                Date:   05/11/1999  Author:     Anthony Swindells

  Update Notes: Fix system owned data / imports from RTB. Modify system owned data in
                take-on tables and associated load programs to reflect new database changes
                for system owned data enhancements.

--------------------------------------------------------------------------------*/
/*                   This .W file was created with the Progress UIB.             */
/*-------------------------------------------------------------------------------*/

/* ***************************  Definitions  ************************** */
/* MIP-GET-OBJECT-VERSION pre-processors
   The following pre-processors are maintained automatically when the object is
   saved. They pull the object and version from Roundtable if possible so that it
   can be displayed in the about window of the container */

&scop object-name       afomsloadp.p
DEFINE VARIABLE lv_this_object_name AS CHARACTER INITIAL "{&object-name}":U NO-UNDO.
&scop object-version    000000


/* MIP object identifying preprocessor */
&glob   mip-structured-procedure    yes

DEFINE INPUT PARAMETER  ip_dump_file_name                AS CHARACTER    NO-UNDO.
DEFINE OUTPUT PARAMETER op_rejection_list                AS CHARACTER    NO-UNDO.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 

/* ********************  Preprocessor Definitions  ******************** */

&Scoped-define PROCEDURE-TYPE Procedure
&Scoped-define DB-AWARE no



/* _UIB-PREPROCESSOR-BLOCK-END */
&ANALYZE-RESUME



/* *********************** Procedure Settings ************************ */

&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
/* Settings for THIS-PROCEDURE
   Type: Procedure
   Allow: 
   Frames: 0
   Add Fields to: Neither
   Other Settings: CODE-ONLY COMPILE
 */
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS

/* *************************  Create Window  ************************** */

&ANALYZE-SUSPEND _CREATE-WINDOW
/* DESIGN Window definition (used by the UIB) 
  CREATE WINDOW Procedure ASSIGN
         HEIGHT             = 11.67
         WIDTH              = 42.8.
/* END WINDOW DEFINITION */
                                                                        */
&ANALYZE-RESUME

 


&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Procedure 


/* ***************************  Main Block  *************************** */

/* Need to re-assign object numbers, so must use a recursive procedure for load */

INPUT FROM VALUE(ip_dump_file_name).

RUN object-menu-structure-load.

INPUT CLOSE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME


/* **********************  Internal Procedures  *********************** */

&IF DEFINED(EXCLUDE-object-menu-structure-load) = 0 &THEN

&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE object-menu-structure-load Procedure 
PROCEDURE object-menu-structure-load :
/*------------------------------------------------------------------------------
  Purpose:     Load object menu structures from flat file
  Parameters:  <none>
  Notes:       
------------------------------------------------------------------------------*/

    DEFINE VARIABLE lv_object_filename                  AS CHARACTER    NO-UNDO.
    DEFINE VARIABLE lv_menu_structure_code              AS CHARACTER    NO-UNDO.
    DEFINE VARIABLE lv_attribute_code                   AS CHARACTER    NO-UNDO.

    REPEAT:
        /* Get a line */
        IMPORT
            lv_object_filename
            lv_menu_structure_code
            lv_attribute_code
            .
        /* Get related data */
        FIND FIRST gsm_menu_structure NO-LOCK
             WHERE gsm_menu_structure.menu_structure_code = lv_menu_structure_code
             NO-ERROR.                  
        IF NOT AVAILABLE gsm_menu_structure THEN
          DO:
            ASSIGN
                op_rejection_list = op_rejection_list +
                                    (IF op_rejection_list <> "":U THEN ",":U ELSE "":U) +
                                    "Unable to find/create menu structure code: " + lv_menu_structure_code
                                    .
            NEXT.
          END.

        FIND FIRST ryc_smartobject NO-LOCK
             WHERE ryc_smartobject.object_filename          = lv_object_filename
               AND ryc_smartobject.customization_result_obj = 0
             NO-ERROR.

        IF NOT AVAILABLE ryc_smartobject THEN
          DO:
            ASSIGN
                op_rejection_list = op_rejection_list +
                                    (IF op_rejection_list <> "":U THEN ",":U ELSE "":U) +
                                    "Unable to find object: " + lv_object_filename
                                    .
            NEXT.
          END.

        IF lv_attribute_code <> "":U THEN
          DO:
            FIND FIRST gsc_instance_attribute NO-LOCK
                 WHERE gsc_instance_attribute.attribute_code = lv_attribute_code
                 NO-ERROR.
            IF NOT AVAILABLE gsc_instance_attribute THEN
              DO:
                ASSIGN
                    op_rejection_list = op_rejection_list +
                                        (IF op_rejection_list <> "":U THEN ",":U ELSE "":U) +
                                        "Unable to find instance attribute: " + lv_attribute_code
                                        .
                NEXT.
              END.
          END.

        IF lv_attribute_code <> "":U THEN
          DO:
            IF CAN-FIND(FIRST gsm_object_menu_structure 
                        WHERE gsm_object_menu_structure.object_obj = ryc_smartobject.smartobject_obj
                          AND gsm_object_menu_structure.menu_structure_obj = gsm_menu_structure.menu_structure_obj
                          AND gsm_object_menu_structure.instance_attribute_obj = gsc_instance_attribute.instance_attribute_obj)
                THEN NEXT.
          END.
        ELSE
          DO:
            IF CAN-FIND(FIRST gsm_object_menu_structure 
                        WHERE gsm_object_menu_structure.object_obj = ryc_smartobject.smartobject_obj
                          AND gsm_object_menu_structure.menu_structure_obj = gsm_menu_structure.menu_structure_obj)
                THEN NEXT.
          END.

        /* Create new record */
        DO TRANSACTION ON ERROR UNDO, NEXT:
            CREATE gsm_object_menu_structure.
            ASSIGN
                gsm_object_menu_structure.object_obj = ryc_smartobject.smartobject_obj
                gsm_object_menu_structure.menu_structure_obj = gsm_menu_structure.menu_structure_obj
                gsm_object_menu_structure.instance_attribute_obj = (IF lv_attribute_code <> "":U THEN gsc_instance_attribute.instance_attribute_obj ELSE 0)
                NO-ERROR.            
            IF ERROR-STATUS:ERROR THEN UNDO, NEXT.
        END.
    END.    

END PROCEDURE.

/* _UIB-CODE-BLOCK-END */
&ANALYZE-RESUME

&ENDIF

