project BLF > class RPCRequestService > method ProcessDS

Description

This method processes the input dataset.


Parameters


icActivityinputcharacter
ilIsPartialUpdateinputlogical
icActioninputcharacter
ilReturnObjectDatasetinputlogical
icPartialUpdateExceptionListinputcharacter
ilReturnInternalIdsinputlogical
izInputDSinputdataset-handle
ohReturnDatasetoutputhandle
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method RPCRequestService.ImportXML


program code (program1/rpcrequestservice.p)

&scoped-define INS-PROCEDURE-DATABASE "ins/ins__" + lc(vcComponentNameRPCRS) + ".p"

<M-95 run ValidateSession
   (output vlSessionStarted (olSessionStarted), 
    output viFcReturnSuper (oiReturnStatus)) in RPCRequestService>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* Generic run of business method */
SOblock:
do:
    <I-43 {tFcStartAndOpenInstance
         &CLASS                = "database"
         &ERROR-STATEMENT      = "assign vlStartError = yes. leave SOblock."
         &SESSIONID            = "viSession3ID"}>
end.

if vlStartError
then do:
    create tErrors.

    assign tErrors.tcFcMessage   = subst(trim(#T-40'Unable to start component &1.':255(5151)T-40#), vcComponentNameRPCRS)
           tErrors.tcFcMsgNumber = "BLF-RPCRS-9"
           tErrors.tiFcSeverity  = 3
           tErrors.tcFcType      = "E"
           tErrors.tcFcContext   = trim(#T-41'This message comes from program/RPCRequestService.p.':255(5142)T-41#)
           tErrors.tcFcRowid     = string(rowid(tErrors))
           oiReturnStatus        = -1.

    if vlSessionStarted
    then do:
        <I-39 {tFcStopInstance
             &CLASS                = "Session"
             &SESSIONID            = "0"}>
    end.
    
    return.
end.

run gipr_ClearSTables in vhdatabase2Inst no-error.

if icActivity <> "" and
   icActivity <> ?
then do:
    <M-45 run SetPublicData
       (input  'vcActivityCode' (icDataList), 
        input  icActivity (icValueList), 
        output viFcReturnSuper (oiReturnStatus)) in database>
end.

<M-47 run PartialSetSTables
   (input  izInputDS by-reference (izDatasetHandle), 
    input  ilIsPartialUpdate (ilIsPartialUpdate), 
    output viLocalReturn (oiReturnStatus)) in database>
        
if viLocalReturn >= 0
then do:
    if icAction = "" or
       icActivity = ?
    then assign icActivity = {&DAEMONACTION-SAVE}.

    create dataset ohReturnDataset in widget-pool "non-persistent".
    
    <M-46 run MaintainByDatasetWithOutput
       (input  icAction (icAction), 
        input  ilReturnObjectDataset (ilReturnDataset), 
        input  ilIsPartialUpdate (ilPartialUpdate), 
        input  icPartialUpdateExceptionList (icPartialUpdateExceptionList), 
        output vpReturnPrime (opPrimaryKey), 
        output vpReturnRowId (opRowid), 
        output viReturnDraftInstance (oiDraftInstance), 
        output vcPrimKeyName (ocPrimaryKeyName), 
        output ohReturnDataset by-reference (ozObjectRepresentation), 
        output viLocalReturn (oiReturnStatus)) in database>

    /*  Assign all _ID values with ? value, except for the main table ID. */
    if ilReturnObjectDataset
    then do:
        if not ilReturnInternalIds
        then do:
            create query vhQuery in widget-pool "non-persistent".

            do viFcCount1 = 1 to ohReturnDataset:num-buffers:
                assign vhDSBuffer = ohReturnDataset:get-buffer-handle(viFcCount1).

                if vhDSBuffer:table <> "tContextInfo"
                then do:
                    vhQuery:set-buffers(vhDSBuffer).
                    vhQuery:query-prepare("for each " + vhDSBuffer:table).
                    vhQuery:query-open().
                    vhQuery:get-first().

                    do while not vhQuery:query-off-end:
                        do viFcCount2 = 1 to vhDSBuffer:num-fields:
                            if vhDSBuffer:buffer-field(viFcCount2):name matches "*_ID" and
                               vhDSBuffer:buffer-field(viFcCount2):name <> vcPrimKeyName
                            then assign vhDSBuffer:buffer-field(viFcCount2):buffer-value = ?.
                        end.

                        vhQuery:get-next().
                    end.

                    vhQuery:query-close().
                end.
            end.

            delete object vhQuery.
            assign vhQuery = ?.
        end.
    end.
    else do:
        delete object ohReturnDataset.
        assign ohReturnDataset = ?.
    end.
end.

if viLocalReturn <> 0
then run GetPublictFcMessages in vhdatabase2Inst (output dataset tErrors, output viFcReturnSuper).

<I-44 {tFcCloseAndStopInstance
     &CLASS           = "database"}>

if vlShutdownSessionRPCRS
then do:
    /* BLF-4122
     * do not report any errors from shutting down the session
     * as the request itself has been processed successfully at this time
     */
    if  vcSessionIdRPCRS <> ''
    and vcSessionIdRPCRS <> ?
    then do:
        vlogout = yes.
        <I-37 {tFcOpenInstance
             &CLASS                = "Session"
             &ERROR-STATEMENT      = "vlogout = no."
             &SESSIONID            = "0"}>
        if vlogout
        then do:
            <M-17 run Logout  (output viFcReturnSuper (oiReturnStatus)) in Session>
        end.
        <I-94 {tFcCloseAndStopInstance
             &CLASS           = "Session"
             &ERROR-STATEMENT = "vlogout = no."}>
    end.
    else do:
        <I-92 {tFcStopInstance
             &CLASS                = "Session"
             &ERROR-STATEMENT      = "vlogout = no."
             &SESSIONID            = "0"}>
    end.
    
    assign vhSessionContext = vhSessionContextDS:get-buffer-handle(1) no-error.
    if vhSessionContext <> ?
    then do:
        create query vhSQuery in widget-pool "non-persistent".
        vhSQuery:forward-only = yes.
        vhSQuery:set-buffers(vhSessionContext).
        vlFcOk = vhSQuery:query-prepare ("for each ":U + vhSessionContext:name
                                         + " where ":U + vhSessionContext:name + ".propertyName = 'BLFSessionId'").
        if vlFcOk
        then vlFcOk = vhSQuery:query-open().
        if vlFcOk
        then do:
            vhSQuery:get-first().
            if not vhSQuery:query-off-end
            then vhSessionContext:buffer-delete().
        end.
        vhSQuery:query-close().
        delete object vhSQuery.
    end.
end.
else
if vlSessionStarted
then do:
    assign vhSessionContext = vhSessionContextDS:get-buffer-handle(1) no-error.
    if vhSessionContext <> ?
    then do:
        create query vhSQuery in widget-pool "non-persistent".
        vhSQuery:forward-only = yes.
        vhSQuery:set-buffers(vhSessionContext).
        vlFcOk = vhSQuery:query-prepare ("for each ":U + vhSessionContext:name
                                         + " where ":U + vhSessionContext:name + ".propertyName = 'BLFSessionId'").
        if vlFcOk
        then vlFcOk = vhSQuery:query-open().
        if vlFcOk
        then do:
            vhSQuery:get-first().
            if vhSQuery:query-off-end
            then vhSessionContext:buffer-create().
            assign vhSessionContext::propertyQualifier = "QAD"
                   vhSessionContext::propertyName      = "BLFSessionId"
                   vhSessionContext::propertyValue     = string(viSession3ID).
            vhSessionContext:buffer-release().
        end.
        vhSQuery:query-close().
        delete object vhSQuery.
    end.
end.

assign oiReturnStatus = viLocalReturn.