project BLF > class Session > method GetNavigationInformation

Description

Get all project-dependent elements to build the navigation model.


Parameters


tBusinessComponentsoutputtemp-table.
tBusinessActivitiesoutputtemp-table
tGotoInfooutputtemp-tableGoto Menu information
tGotoInfoConditionoutputtemp-tableGoto Menu information
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program4/session.p)

if vlLoginFailed
then do:
    <M-30 run SetMessage
       (input  trim(#T-31'You are not logged in.':100(28)T-31#) (icMessage), 
        input  '' (icArguments), 
        input  '' (icFieldName), 
        input  '' (icFieldValue), 
        input  'D':U (icType), 
        input  2 (iiSeverity), 
        input  '' (icRowid), 
        input  'BLF-213':U (icFcMsgNumber), 
        input  '' (icFcExplanation), 
        input  '' (icFcIdentification), 
        input  '' (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in Session>

    assign oiReturnStatus = -5.
    return.
end.

/* ====================================================== */
/* Get the Navigation information by running db retrieval */
/* Security will be appplied in this procedure            */
/* ====================================================== */
empty temp-table tBusinessComponents.
empty temp-table tBusinessActivities.
empty temp-table tGotoInfo.
empty temp-table tGotoInfoCondition.

/* Convert code to ID */
if current-language <> ?
then do:
    <Q-10 run LanguagePrim (all) (Read) (NoCache)
       (input current-language, (LngCode)
        input ?, (LngID)
        output dataset tqLanguagePrim) in BLanguage >

    find first tqLanguagePrim where
               tqLanguagePrim.tcLngCode = current-language
               no-error.

    if available tqLanguagePrim
    then assign viLngID = tqLanguagePrim.tiLng_ID.

    empty temp-table tqLanguagePrim.
end.

/* Load data */
if viLngID = 0
then do:
    <Q-21 run NavigInfoNTNew (all) (Read) (NoCache)  (output dataset tqNavigInfoNTNew) in BBusinessComponent >
    empty temp-table tqNavigInfoNew.

    for each tqNavigInfoNTNew on error undo, throw:
        create tqNavigInfoNew.
        buffer-copy tqNavigInfoNTNew to tqNavigInfoNew.
    end.

    empty temp-table tqNavigInfoNTNew.
end.
else do:
    <Q-11 run NavigInfoNew (all) (Read) (NoCache)
       (input viLngID, (LngID)
        output dataset tqNavigInfoNew) in BBusinessComponent >
end.

/* Copy to output tables */
for each tqNavigInfoNew
         by tqNavigInfoNew.tcBusComponentCode
         by tqNavigInfoNew.tcBusActivityCode
         on error undo, throw:

    /* Skip ReturnToSender activity */
    if tqNavigInfoNew.tcBusActivityCode = "ReturnToSender"
    then next.

    /* BLF-3781 Removing disabled activities based on system settings does not work
    if not vlCBFActive and
       tqNavigInfoNew.tcBusComponentCode = "BCustomField"
    then next.

    if not vlDraftsActive and
      (tqNavigInfoNew.tcBusActivityCode  = "BrowseDrafts" or
       tqNavigInfoNew.tcBusComponentCode = "BDraftInstance")
    then next.

    if not vlEventPublishingActive and
      (tqNavigInfoNew.tcBusComponentCode = "BEventConfig" or
       tqNavigInfoNew.tcBusComponentCode = "BEventDaemon" or
       tqNavigInfoNew.tcBusComponentCode = "BEventDestination")
    then next.

    if not vlUICustomizationActive and
       tqNavigInfoNew.tcBusComponentCode = "BControlProperty"
    then next.

    if not vlWorkFlowActive and
       tqNavigInfoNew.tcBusComponentCode = "BWorkObject"
    then next.

    if not vlFieldSecurityActive and
       tqNavigInfoNew.tcBusComponentCode = "BFieldSecurity"
    then next.
    */

    /* OK we can create the output table - tBusinessComponents */
    if not can-find (first tBusinessComponents where
                           tBusinessComponents.tiBusComponentID = tqNavigInfoNew.tiBusComponent_ID)
    then do:
        create tBusinessComponents.

        assign tBusinessComponents.tiBusComponentID  = tqNavigInfoNew.tiBusComponent_ID
               tBusinessComponents.tcLabel           = if tqNavigInfoNew.tcBusComponentLabelTranslated = ? or
                                                          tqNavigInfoNew.tcBusComponentLabelTranslated = ""
                                                       then tqNavigInfoNew.tcBusComponentLabel
                                                       else tqNavigInfoNew.tcBusComponentLabelTranslated
               tBusinessComponents.tcName            = tqNavigInfoNew.tcBusComponentCode
               tBusinessComponents.tlHasCustomFields = tqNavigInfoNew.tlBusComponentHasCustomFlds
               tBusinessComponents.tlIsUserDefined   = tqNavigInfoNew.tlBusComponentIsUserDefined.

        /* Check if GoTo need to be created */
        if search("appinfo/":U + lc(tBusinessComponents.tcName) + "_go.r":U) <> ? or
           search("appinfo/":U + lc(tBusinessComponents.tcName) + "_go.p":U) <> ?
        then run value("appinfo/":U + lc(tBusinessComponents.tcName) + "_go.p":U)
                (input table tGotoInfo by-reference,
                 input table tGotoInfoCondition by-reference,
                 input vhFcSuper)
                 no-error.

        if search ("appinfo/" + lc(tBusinessComponents.tcName) + "_key.r") <> ?
        or search ("appinfo/" + lc(tBusinessComponents.tcName) + "_key.p") <> ?
        then do:
            vcDummy1 = "".
            run value ("appinfo/" + lc(tBusinessComponents.tcName) + "_key.p")
               (input-output vcDummy1,
                output vcDummy2,
                output tBusinessComponents.tcAlternateKey,
                output vcDummy3,
                output vcDummy4,
                output tBusinessComponents.tcBusComponentDependency).
            if tBusinessComponents.tcAlternateKey = ""
            then tBusinessComponents.tcAlternateKey = vcDummy2.
            do viFcCount1 = 1 to num-entries(tBusinessComponents.tcAlternateKey):
                entry(viFcCount1,tBusinessComponents.tcAlternateKey) = "t" + vcDummy1 + "." + entry(viFcCount1,tBusinessComponents.tcAlternateKey).
            end.
            tBusinessComponents.tcAlternateKey = replace (tBusinessComponents.tcAlternateKey,",","|").
        end.
    end.

    /* OK we can create the output table - tBusinessActivities */
    if not can-find (first tBusinessActivities where
                           tBusinessActivities.tcClassName = tqNavigInfoNew.tcBusComponentCode and
                           tBusinessActivities.tcName      = tqNavigInfoNew.tcBusActivityCode)
    then do:
        create tBusinessActivities.

        assign tBusinessActivities.tcButtonLabel      = tqNavigInfoNew.tcBusActivityButtonLabel
               tBusinessActivities.tcClassName        = tqNavigInfoNew.tcBusComponentCode
               tBusinessActivities.tcDocumentActivity = tqNavigInfoNew.tcBusActivityDocActivity
               tBusinessActivities.tcFormName         = tqNavigInfoNew.tcBusActivityFormName
               tBusinessActivities.tcLabel            = if tqNavigInfoNew.tcBusActivityLabelTranslated = ? or
                                                           tqNavigInfoNew.tcBusActivityLabelTranslated = ""
                                                        then tqNavigInfoNew.tcBusActivityLabel
                                                        else tqNavigInfoNew.tcBusActivityLabelTranslated
               tBusinessActivities.tcMethodName       = tqNavigInfoNew.tcBusActivityMethodName
               tBusinessActivities.tcName             = tqNavigInfoNew.tcBusActivityCode
               tBusinessActivities.tiSequence         = tqNavigInfoNew.tiBusActivitySequence
               tBusinessActivities.tiShortcut         = tqNavigInfoNew.tiBusActivityAccelerator
               tBusinessActivities.tlDefault          = tqNavigInfoNew.tlBusActivityIsDefault
               tBusinessActivities.tlEnabled          = tqNavigInfoNew.tlBusActivityIsActive
               tBusinessActivities.tlInstanceNeeded   = tqNavigInfoNew.tlBusActivityIsInstDep
               tBusinessActivities.tlOpenForm         = tqNavigInfoNew.tlBusActivityOpenForm.
    end.
end.

/* ==================================================================================================================== */
/* Make sure also business components without activities are included in the list of components returned by this method */
/* ==================================================================================================================== */
<Q-29 run BusComponentInfo (all) (Read) (NoCache)
   (input ?, (BusComponentId)
    input ?, (BusComponentCode)
    input viLngID, (LngId)
    output dataset tqBusComponentInfo) in BBusinessComponent >

for each tqBusComponentInfo where
         not can-find(tBusinessComponents where
                      tBusinessComponents.tiBusComponentID = tqBusComponentInfo.tiBusComponent_ID)
         on error undo, throw:
    create tBusinessComponents.

    assign tBusinessComponents.tiBusComponentID  = tqBusComponentInfo.tiBusComponent_ID
           tBusinessComponents.tcLabel           = if tqBusComponentInfo.tcBusComponentLabelTranslated = ? or
                                                      tqBusComponentInfo.tcBusComponentLabelTranslated = ""
                                                   then tqBusComponentInfo.tcBusComponentLabel
                                                   else tqBusComponentInfo.tcBusComponentLabelTranslated
           tBusinessComponents.tcName            = tqBusComponentInfo.tcBusComponentCode
           tBusinessComponents.tlHasCustomFields = tqBusComponentInfo.tlBusComponentHasCustomFlds
           tBusinessComponents.tlIsUserDefined   = tqBusComponentInfo.tlBusComponentIsUserDefined.

    /* Check if GoTo need to be created */
    if search("appinfo/":U + lc(tBusinessComponents.tcName) + "_go.r":U) <> ? or
       search("appinfo/":U + lc(tBusinessComponents.tcName) + "_go.p":U) <> ?
    then run value("appinfo/":U + lc(tBusinessComponents.tcName) + "_go.p":U)
            (input table tGotoInfo by-reference,
             input table tGotoInfoCondition by-reference,
             input vhFcSuper)
             no-error.

    if search ("appinfo/" + lc(tBusinessComponents.tcName) + "_key.r") <> ?
    or search ("appinfo/" + lc(tBusinessComponents.tcName) + "_key.p") <> ?
    then do:
        vcDummy1 = "".
        run value ("appinfo/" + lc(tBusinessComponents.tcName) + "_key.p")
           (input-output vcDummy1,
            output vcDummy2,
            output tBusinessComponents.tcAlternateKey,
            output vcDummy3,
            output vcDummy4,
            output tBusinessComponents.tcBusComponentDependency).
            if tBusinessComponents.tcAlternateKey = ""
            then tBusinessComponents.tcAlternateKey = vcDummy2.
        do viFcCount1 = 1 to num-entries(tBusinessComponents.tcAlternateKey):
            entry(viFcCount1,tBusinessComponents.tcAlternateKey) = "t" + vcDummy1 + "." + entry(viFcCount1,tBusinessComponents.tcAlternateKey).
        end.
        tBusinessComponents.tcAlternateKey = replace (tBusinessComponents.tcAlternateKey,",","|").
    end.
end.

/* ================================================================= */
/* Load extra related reports.                                       */
/* ================================================================= */
<M-87 run GetRelatedReports  (output viFcReturnSuper (oiReturnStatus)) in Session>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.


Sample code: how to call this method through RPCRequestService (QXtend Inbound)

define temp-table ttContext no-undo
    field propertyQualifier as character
    field propertyName as character
    field propertyValue as character
    index entityContext is primary unique
        propertyQualifier
        propertyName
    index propertyQualifier
        propertyQualifier.

define dataset dsContext for ttContext.

define variable vhContextDS as handle no-undo.
define variable vhExceptionDS as handle no-undo.
define variable vhServer as handle no-undo.
define variable vhInputDS as handle no-undo.
define variable vhInputOutputDS as handle no-undo.
define variable vhOutputDS as handle no-undo.
define variable vhParameter as handle no-undo.

/* Create context */
create ttContext.
assign ttContext.propertyName = "programName"
       ttContext.propertyValue = "Session".
create ttContext.
assign ttContext.propertyName = "methodName"
       ttContext.propertyValue = "GetNavigationInformation".
create ttContext.
assign ttContext.propertyName = "applicationId"
       ttContext.propertyValue = "fin".
create ttContext.
assign ttContext.propertyName = "entity"
       ttContext.propertyValue = "1000".
create ttContext.
assign ttContext.propertyName = "userName"
       ttContext.propertyValue = "mfg".
create ttContext.
assign ttContext.propertyName = "password"
       ttContext.propertyValue = "".

/* Connect the AppServer */
create server vhServer.
vhServer:connect("-URL <appserver-url>").

if not vhServer:connected()
then do:
    message "Could not connect AppServer" view-as alert-box error title "Error".
    return.
end.

/* Run */
assign vhContextDS = dataset dsContext:handle.

run program/rpcrequestservice.p on vhServer
    (input-output dataset-handle vhContextDS by-reference,
           output dataset-handle vhExceptionDS,
     input        dataset-handle vhInputDS by-reference,
     input-output dataset-handle vhInputOutputDS by-reference,
           output dataset-handle vhOutputDS).

/* Handle output however you want, in this example, we dump it to xml */
if valid-handle(vhExceptionDS)
then vhExceptionDS:write-xml("file", "Exceptions.xml", true).

if valid-handle(vhOutputDS)
then vhOutputDS:write-xml("file", "Output.xml", true).

/* Cleanup */
vhServer:disconnect().
assign vhServer = ?.

if valid-handle(vhInputDS)
then delete object vhInputDS.

if valid-handle(vhOutputDS)
then delete object vhOutputDS.

if valid-handle(vhExceptionDS)
then delete object vhExceptionDS.