project BLF > class BControlProperty > method DeleteControlProperty


Parameters


tControlPropertyToDeleteinputtemp-table
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bcontrolproperty.p)

    
    /* =========================== */
    /* Start with a clear instance */
    /* =========================== */
    <M-43 run ClearData  (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.
    empty temp-table tFcDynRel.
    
    /* =============================== */
    /* Go through the input temp-table */
    /* =============================== */
    for each tControlPropertyToDelete on error undo, throw:
        
        /* ===================================================================================================== */
        /* If tControlPropertyToDelete.tiBusActivityID in the input temp-table is not filled then fill it here   */
        /* based upon tControlPropertyToDelete.tcBusComponentCode and tControlPropertyToDelete.tcBusActivityCode */
        /* ===================================================================================================== */
        if tControlPropertyToDelete.tiBusActivityID = 0 or 
           tControlPropertyToDelete.tiBusActivityID = ? 
        then do :
            <Q-1 run BusActivityByCompActCode (all) (Read) (Cache)
               (input tControlPropertyToDelete.tcBusActivityCode, (BusActitvityCode)
                input tControlPropertyToDelete.tcBusComponentCode, (BusComponentCode)
                output dataset tqBusActivityByCompActCode) in BBusinessComponent>
            find first tqBusActivityByCompActCode where
                       tqBusActivityByCompActCode.tcBusComponentCode = tControlPropertyToDelete.tcBusComponentCode and
                       tqBusActivityByCompActCode.tcBusActivityCode  = tControlPropertyToDelete.tcBusActivityCode
                       no-error.
            if not available tqBusActivityByCompActCode
            then do:
                assign vcMessage      = trim(substitute(#T-10'Business activity could not be found based on the code of the business class (&1) and the code of the business activity (&2).':255(486)T-10#, tControlPropertyToDelete.tcBusComponentCode, tControlPropertyToDelete.tcBusActivityCode))
                       oiReturnStatus = -1.
                <M-80 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  '':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  '':U (icRowid), 
                    input  'blf-643690':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
                next.                
            end. /* if not available tqBusActivityByCompActCode */
            else assign tControlPropertyToDelete.tiBusActivityID = tqBusActivityByCompActCode.tiBusActivity_ID.
        end. /* if tControlPropertyToDelete.tiBusActivityID = 0 or  */
        
        /* ================================================================================================================ */
        /* If tControlPropertyToDelete.tiControlPropertyLayerValue in the input temp-table is not filled then fill it here  */
        /* based upon tControlPropertyToDelete.tiControlPropertyLayerType and tControlPropertyToDelete.tcLayerValueResolved */
        /* ================================================================================================================ */
        if tControlPropertyToDelete.tiControlPropertyLayerValue = 0 or 
           tControlPropertyToDelete.tiControlPropertyLayerValue = ?
        then do :
            case tControlPropertyToDelete.tiControlPropertyLayerType:
                when 1 /* User */
                then do :
                    if tControlPropertyToDelete.tcLayerValueResolved = "":U or 
                       tControlPropertyToDelete.tcLayerValueResolved = ?
                    then do :
                        assign vcMessage      = trim(#T-20'Internal error: Unable to convert the UserLogin to its ID as it is not filled.':255(349448052)T-20#)
                               oiReturnStatus = -1.
                        <M-84 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '' (icArguments), 
                            input  '' (icFieldName), 
                            input  '' (icFieldValue), 
                            input  'E' (icType), 
                            input  3 (iiSeverity), 
                            input  '' (icRowid), 
                            input  'blf-512676':U (icFcMsgNumber), 
                            input  '' (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
                        next.
                    end. /* if tControlPropertyToDelete.tcLayerValueResolved = "":U or  */
                    <Q-5 run UserPrim (all) (Read) (Cache)
                       (input ?, (UsrId)
                        input tControlPropertyToDelete.tcLayerValueResolved, (UsrLogin)
                        output dataset tqUserPrim) in BUser >
                    find tqUserPrim where
                         tqUserPrim.tcUsrLogin = tControlPropertyToDelete.tcLayerValueResolved
                         no-error.
                    if not available tqUserPrim
                    then do:
                        assign vcMessage      = trim(substitute(#T-60'User with login &1 does not exist.':255(48387180)T-60#),tControlPropertyToDelete.tcLayerValueResolved)
                               oiReturnStatus = -1.
                        <M-13 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  '' (icFieldName), 
                            input  '' (icFieldValue), 
                            input  'E' (icType), 
                            input  3 (iiSeverity), 
                            input  '' (icRowid), 
                            input  'BLF-58' (icFcMsgNumber), 
                            input  '' (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
                        assign oiReturnStatus = -1.
                        next.
                    end. /* if not available tqUserPrim */
                    assign tControlPropertyToDelete.tiControlPropertyLayerValue = tqUserPrim.tiUsr_ID.
                end. /* when 1 */
                when 2 /* Role */
                then do :
                    if tControlPropertyToDelete.tcLayerValueResolved = "":U or 
                       tControlPropertyToDelete.tcLayerValueResolved = ?
                    then do :
                        assign vcMessage      = trim(#T-29'Internal error: Unable to convert the Role to its ID as it is not filled.':255(982905669)T-29#)
                               oiReturnStatus = -1.
                        <M-75 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '' (icArguments), 
                            input  '' (icFieldName), 
                            input  '' (icFieldValue), 
                            input  'E' (icType), 
                            input  3 (iiSeverity), 
                            input  '' (icRowid), 
                            input  'blf-52047':U (icFcMsgNumber), 
                            input  '' (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
                        next.
                    end. /* if tControlPropertyToDelete.tcLayerValueResolved = "":U or  */
                    <Q-7 run RolePrim (all) (Read) (Cache)
                       (input ?, (RoleID)
                        input tControlPropertyToDelete.tcLayerValueResolved, (RoleName)
                        output dataset tqRolePrim) in BRole >
                    find tqRolePrim where
                         tqRolePrim.tcRoleName = tControlPropertyToDelete.tcLayerValueResolved
                         no-error.
                    if not available tqRolePrim
                    then do :
                        assign vcMessage      = trim(substitute(#T-72'Role with name &1 does not exist.':255(177050611)T-72#),tControlPropertyToDelete.tcLayerValueResolved)
                               oiReturnStatus = -1.
                        <M-14 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  '' (icFieldName), 
                            input  '' (icFieldValue), 
                            input  'E' (icType), 
                            input  3 (iiSeverity), 
                            input  '' (icRowid), 
                            input  'BLF-59' (icFcMsgNumber), 
                            input  '' (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
                        assign oiReturnStatus = -1.
                        next.
                    end. /* if not available tqRolePrim */
                    assign tControlPropertyToDelete.tiControlPropertyLayerValue = tqRolePrim.tiRole_ID.
                end. /* when 2 */
                when 3 /* System */
                then assign tControlPropertyToDelete.tiControlPropertyLayerValue = 0.
            end case.
        end. /* if tControlPropertyToDelete.tiControlPropertyLayerValue = 0 or  */
        
        /* ================================================================================== */
        /* Compose a tFcDynRel that will be used later for reading the data into the instance */
        /* ================================================================================== */
        create tFcDynRel.
        assign tFcDynRel.tcFcFrom    = ""
               tFcDynRel.tcFcTo      = "ControlProperty"
               tFcDynRel.tcFcRel     = "for each ControlProperty where " +
                                                "ControlProperty.BusActivity_ID = " + string(tControlPropertyToDelete.tiBusActivityID) + " and " +
                                                "ControlProperty.ControlPropertyWindow = '" + tControlPropertyToDelete.tcForm + "' and " +
                                                "ControlProperty.ControlPropertyLayerType = " + string(tControlPropertyToDelete.tiControlPropertyLayerType) + " and " +
                                                "ControlProperty.ControlPropertyLayerValue = " + string(tControlPropertyToDelete.tiControlPropertyLayerValue) +
                                               (if tControlPropertyToDelete.tcGrid = "" or 
                                                   tControlPropertyToDelete.tcGrid = ?
                                                then " and ControlProperty.ControlPropertyName <> '" + {&CONTROLPROPERTY-VIEWSDEFINITIONS} + "'"
                                                else " and ControlProperty.ControlPropertyName = '" + {&CONTROLPROPERTY-VIEWSDEFINITIONS}
                                                  + "' and ControlProperty.ControlPropertyControl = '" + tControlPropertyToDelete.tcGrid + "'")
               tFcDynRel.thFcBuffer  = buffer t_oControlProperty:handle
               tFcDynRel.thFcIBuffer = buffer t_iControlProperty:handle.
        if tControlPropertyToDelete.tcWhatToDelete = "U"
        then assign tFcDynRel.tcFcRel = tFcDynRel.tcFcRel + " and ControlProperty.ControlPropertyName begins 'EVENT:'".
        if tControlPropertyToDelete.tcWhatToDelete = "L"
        then assign tFcDynRel.tcFcRel = tFcDynRel.tcFcRel + " and not ControlProperty.ControlPropertyName begins 'EVENT:'".
        
    end. /* for each tControlPropertyToDelete on error undo, throw: */
    
    /* ================================================================================= */
    /* If we have an error by now or if there is nothing to handle then just Return here */
    /* ================================================================================= */
    if oiReturnStatus < 0 or
       not can-find(first tFcDynRel)
    then return.
    
    /* ========================================================================================== */
    /* Compose a tFcDynRel that will handle the primary relation between the tables of this class */
    /* ========================================================================================== */
    create tFcDynRel.    
    assign tFcDynRel.tcFcFrom    = "ControlProperty"
           tFcDynRel.tcFcTo      = "ControlPropertySegment"
           tFcDynRel.tcFcRel     = "for each ControlPropertySegment where ControlPropertySegment.ControlProperty_ID = ControlProperty.ControlProperty_ID"
           tFcDynRel.thFcBuffer  = buffer t_oControlPropertySegment:handle
           tFcDynRel.thFcIBuffer = buffer t_iControlPropertySegment:handle
           tFcDynRel.thFcSBuffer = buffer t_sControlPropertySegment:handle.
    
    /* ========================================================= */
    /* Use the persistence-layer to load the data into the class */
    /* ========================================================= */
    <M-15 run StartPersistence
       (output vhFcComponent (ohPersistence), 
        output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.
    <M-16 run ReadData
       (input  tFcDynRel (tDynRel), 
        input  {&TARGETPROCEDURE} (ihClass), 
        output viFcReturnSuper (oiReturnStatus)) in persistence>
    if viFcReturnSuper = -4
    then assign viFcReturnSuper = 0.
    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.
    
    /* ========================================================= */
    /* Use the persistence-layer to load the data into the class */
    /* ========================================================= */
    for each tControlProperty on error undo, throw:
        if not (tControlProperty.ControlPropertyName = {&CONTROLPROPERTY-VIEWSDEFINITIONS} and
                tControlProperty.ControlPropertyLayerType = {&CONTROLPROPERTYLAYERTYPE-SYSTEM} and
                vcUserLogin <> "facdef")   /* skip grid factory defaults */
        then tControlProperty.tc_Status = "D".
    end. /* for each tControlProperty on error undo, throw: */
    
    /* ========================================== */
    /* Call the validation and additional-updates */
    /* ========================================== */
    <M-17 run ValidateBC  (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.
    <M-18 run AdditionalUpdates  (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
    if viFcReturnSuper < 0 or
       oiReturnStatus  = 0
    then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0
    then return.