project BLF > class BSODReport > method SODViolations

report procedure


Parameters


icLanguageCodeinputcharacter
tFilterinputtemp-table
dcrSODViolationsoutputdataset
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program1/bsodreport.p)

empty temp-table tSODViolationsRule1.
empty temp-table tSODViolationsRule2.
empty temp-table tSODViolationsResources.

<M-19 run GetReportLabels
   (input  'SODViolations' (icReportName),
    input  icLanguageCode (icLanguageCode),
    input  tFilter (tFilter),
    output tqHeader (tqHeader),
    output tqFilter (tqFilter),
    output tqText (tqText),
    output viFcReturnSuper (oiReturnStatus)) in BSODReport>
if viFcReturnSuper <> 0
then oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

if vlRule1
then do:
    <Q-41 run SelectRole (all) (Read) (NoCache)  (output dataset tqSelectRole) in BRole >

    for each tqSelectRole by tqSelectRole.tcRoleName:

        if vcSearchRoleName <> ""
        and vcSearchRoleName <> ?
        and not tqSelectRole.tcRoleName = vcSearchRoleName
        then next.

        if vcSearchRoleNameBegins <> ""
        and vcSearchRoleNameBegins <> ?
        and not tqSelectRole.tcRoleName begins vcSearchRoleNameBegins
        then next.

        if vcSearchRoleNameFrom <> ""
        and vcSearchRoleNameFrom <> ?
        and tqSelectRole.tcRoleName < vcSearchRoleNameFrom
        then next.

        if vcSearchRoleNameTo <> ""
        and vcSearchRoleNameTo <> ?
        and tqSelectRole.tcRoleName > vcSearchRoleNameTo
        then next.

        if vcSearchRoleNameMatches <> ""
        and vcSearchRoleNameMatches <> ?
        and not tqSelectRole.tcRoleName matches vcSearchRoleNameMatches
        then next.

        if vlResources
        then do:
            /* ================================================================= */
            /* Load rule 1 violations, including resource detail.                */
            /* ================================================================= */
            <Q-53 run ViolationsResourcesByRole (all) (Read) (NoCache)
               (input tqSelectRole.tiRole_ID, (RoleID)
                output dataset tqViolationsResourcesByRole) in BSODViolationRule1 >

            for each tqViolationsResourcesByRole by tqViolationsResourcesByRole.tcSODCategoryCode1 by tqViolationsResourcesByRole.tcSODCategoryCode2:

                if vcSearchExclusionLevel <> "" and vcSearchExclusionLevel <> ?
                and not tqViolationsResourcesByRole.tcSODExclusionLevel = vcSearchExclusionLevel
                then next.

                find first tSODViolationsRule1 where
                           tSODViolationsRule1.tcRoleName                = tqSelectRole.tcRoleName and
                           tSODViolationsRule1.tcSODCategoryCode1        = tqViolationsResourcesByRole.tcSODCategoryCode1 and
                           tSODViolationsRule1.tcSODCategoryCode2        = tqViolationsResourcesByRole.tcSODCategoryCode2 no-error.
                if not available tSODViolationsRule1
                then do:
                    viRuleCount = viRuleCount + 1.
                    create tSODViolationsRule1.
                    assign tSODViolationsRule1.tc_Rowid                  = "x" + string(viRuleCount)
                           tSODViolationsRule1.ti_Sequence               = viRuleCount
                           tSODViolationsRule1.tcRoleDescription         = tqSelectRole.tcRoleDescription
                           tSODViolationsRule1.tcRoleName                = tqSelectRole.tcRoleName
                           tSODViolationsRule1.tcSODCategoryCode1        = tqViolationsResourcesByRole.tcSODCategoryCode1
                           tSODViolationsRule1.tcSODCategoryCode2        = tqViolationsResourcesByRole.tcSODCategoryCode2
                           tSODViolationsRule1.tcSODCategoryDescription1 = tqViolationsResourcesByRole.tcSODCategoryDescription1
                           tSODViolationsRule1.tcSODCategoryDescription2 = tqViolationsResourcesByRole.tcSODCategoryDescription2
                           tSODViolationsRule1.tcSODExclusionLevel       = tqViolationsResourcesByRole.tcSODExclusionLevel.

                end.

                create tSODViolationsResources.
                assign tSODViolationsResources.tc_Rowid        = tSODViolationsRule1.tc_Rowid
                       tSODViolationsResources.ti_Sequence     = tSODViolationsRule1.ti_Sequence
                       tSODViolationsResources.tiRule          = tqViolationsResourcesByRole.tiSODViolation1RCategory
                    /* tSODViolationsResources.tcResourceNbr   =  */
                       tSODViolationsResources.tcResourceURI   = tqViolationsResourcesByRole.tcResourceURI
                       tSODViolationsResources.tcResourceLabel = tqViolationsResourcesByRole.tcResourceLabel.
            end.
        end.
        else do:
            /* ================================================================= */
            /* Load rule 1 violations, excluding resource detail.                */
            /* ================================================================= */
            <Q-45 run ViolationsByRole (all) (Read) (NoCache)
               (input tqSelectRole.tiRole_ID, (RoleID)
                output dataset tqViolationsByRole) in BSODViolationRule1 >

            for each tqViolationsByRole by tqViolationsByRole.tcSODCategoryCode1 by tqViolationsByRole.tcSODCategoryCode2:
            
                if vcSearchExclusionLevel <> "" and vcSearchExclusionLevel <> ?
                and not tqViolationsByRole.tcSODExclusionLevel = vcSearchExclusionLevel
                then next.

                viRuleCount = viRuleCount + 1.
                create tSODViolationsRule1.
                assign tSODViolationsRule1.tc_Rowid                  = "x" + string(viRuleCount)
                       tSODViolationsRule1.ti_Sequence               = viRuleCount
                       tSODViolationsRule1.tcRoleDescription         = tqSelectRole.tcRoleDescription
                       tSODViolationsRule1.tcRoleName                = tqSelectRole.tcRoleName
                       tSODViolationsRule1.tcSODCategoryCode1        = tqViolationsByRole.tcSODCategoryCode1
                       tSODViolationsRule1.tcSODCategoryCode2        = tqViolationsByRole.tcSODCategoryCode2
                       tSODViolationsRule1.tcSODCategoryDescription1 = tqViolationsByRole.tcSODCategoryDescription1
                       tSODViolationsRule1.tcSODCategoryDescription2 = tqViolationsByRole.tcSODCategoryDescription2
                       tSODViolationsRule1.tcSODExclusionLevel       = tqViolationsByRole.tcSODExclusionLevel.

            end.
        end.
    end.    /* each role */
end.    /* vlrule1 */

if vlRule2
then do:
    if vcSearchDomainCode <> ""
    and vcSearchDomainCode <> ?
    then do:
        <Q-67 run DomainsPrim (all) (Read) (NoCache)
           (input 0, (DomainID)
            input vcSearchDomainCode, (DomainCode)
            output dataset tqDomainsPrim) in BDomain >
        find first tqDomainsPrim where tqDomainsPrim.tcDomainCode = vcSearchDomainCode no-error.
        if available tqDomainsPrim
        then viSearchDomainId = tqDomainsPrim.tiDomain_ID.
    end.

    if vcSearchCompanyCode <> ""
    and vcSearchCompanyCode <> ?
    then do:
        <Q-37 run CompanyPrim (all) (Read) (NoCache)
           (input 0, (LookupCompanyId)
            input vcSearchCompanyCode, (CompanyCode)
            output dataset tqCompanyPrim) in BCompany >
        find first tqCompanyPrim where tqCompanyPrim.tcCompanyCode = vcSearchCompanyCode no-error.
        if available tqCompanyPrim
        then viSearchCompanyId = tqCompanyPrim.tiCompany_ID.
    end.

    <Q-8 run UserByUsrLogin (all) (Read) (NoCache)
       (input '', (UsrLogin)
        output dataset tqUserByUsrLogin) in BUser >

    for each tqUserByUsrLogin by tqUserByUsrLogin.tcUsrName:

        if vlResources
        then do:
            /* ================================================================= */
            /* Load rule 2 violations, including resource detail.                */
            /* ================================================================= */
            <Q-83 run ViolationsResourcesByUser (all) (Read) (NoCache)
               (input viSearchCompanyId, (CompanyId)
                input viSearchDomainId, (DomainId)
                input tqUserByUsrLogin.tiUsr_ID, (UserId)
                output dataset tqViolationsResourcesByUser) in BSODViolationRule2 >

            for each tqViolationsResourcesByUser by tqViolationsResourcesByUser.tcRole1Name
                                                 by tqViolationsResourcesByUser.tcSODCategoryCode1
                                                 by tqViolationsResourcesByUser.tcRole2Name
                                                 by tqViolationsResourcesByUser.tcSODCategoryCode2:

                if vcSearchRoleName <> ""
                and vcSearchRoleName <> ?
                and not (tqViolationsResourcesByUser.tcRole1Name = vcSearchRoleName or
                         tqViolationsResourcesByUser.tcRole2Name = vcSearchRoleName)
                then next.

                if vcSearchRoleNameBegins <> ""
                and vcSearchRoleNameBegins <> ?
                and not (tqViolationsResourcesByUser.tcRole1Name begins vcSearchRoleNameBegins or
                         tqViolationsResourcesByUser.tcRole2Name begins vcSearchRoleNameBegins)
                then next.

                if vcSearchRoleNameFrom <> ""
                and vcSearchRoleNameFrom <> ?
                and (tqViolationsResourcesByUser.tcRole1Name < vcSearchRoleNameFrom or
                     tqViolationsResourcesByUser.tcRole2Name < vcSearchRoleNameFrom)
                then next.

                if vcSearchRoleNameTo <> ""
                and vcSearchRoleNameTo <> ?
                and (tqViolationsResourcesByUser.tcRole1Name > vcSearchRoleNameTo or
                     tqViolationsResourcesByUser.tcRole2Name > vcSearchRoleNameTo)
                then next.

                if vcSearchRoleNameMatches <> ""
                and vcSearchRoleNameMatches <> ?
                and not (tqViolationsResourcesByUser.tcRole1Name matches vcSearchRoleNameMatches or
                         tqViolationsResourcesByUser.tcRole2Name matches vcSearchRoleNameMatches)
                then next.

                if vcSearchExclusionLevel <> "" 
                and vcSearchExclusionLevel <> ?
                and not tqViolationsResourcesByUser.tcSODExclusionLevel = vcSearchExclusionLevel
                then next.

                find first tSODViolationsRule2 where
                           tSODViolationsRule2.tcUsrName                 = tqUserByUsrLogin.tcUsrName and
                           tSODViolationsRule2.tcRoleName1               = tqViolationsResourcesByUser.tcRole1Name and
                           tSODViolationsRule2.tcRoleName2               = tqViolationsResourcesByUser.tcRole2Name and
                           tSODViolationsRule2.tcScope                   = (if tqViolationsResourcesByUser.tcCompanyCode = "" then tqViolationsResourcesByUser.tcDomainCode else tqViolationsResourcesByUser.tcCompanyCode) and
                           tSODViolationsRule2.tcSODCategoryCode1        = tqViolationsResourcesByUser.tcSODCategoryCode1 and
                           tSODViolationsRule2.tcSODCategoryCode2        = tqViolationsResourcesByUser.tcSODCategoryCode2 no-error.
                if not available tSODViolationsRule2
                then do:
                    viRuleCount = viRuleCount + 1.
                    create tSODViolationsRule2.
                    assign tSODViolationsRule2.tc_Rowid                  = "x" + string(viRuleCount)
                           tSODViolationsRule2.ti_Sequence               = viRuleCount
                           tSODViolationsRule2.tcUsrName                 = tqUserByUsrLogin.tcUsrName
                           tSODViolationsRule2.tcRoleName1               = tqViolationsResourcesByUser.tcRole1Name
                           tSODViolationsRule2.tcRoleName2               = tqViolationsResourcesByUser.tcRole2Name
                           tSODViolationsRule2.tcScope                   = (if tqViolationsResourcesByUser.tcCompanyCode = "" then tqViolationsResourcesByUser.tcDomainCode else tqViolationsResourcesByUser.tcCompanyCode)
                           tSODViolationsRule2.tcSODCategoryCode1        = tqViolationsResourcesByUser.tcSODCategoryCode1
                           tSODViolationsRule2.tcSODCategoryCode2        = tqViolationsResourcesByUser.tcSODCategoryCode2
                           tSODViolationsRule2.tcSODCategoryDescription1 = tqViolationsResourcesByUser.tcSODCategoryDescription1
                           tSODViolationsRule2.tcSODCategoryDescription2 = tqViolationsResourcesByUser.tcSODCategoryDescription2
                           tSODViolationsRule2.tcSODExclusionLevel       = tqViolationsResourcesByUser.tcSODExclusionLevel.
                end.

                create tSODViolationsResources.
                assign tSODViolationsResources.tc_Rowid        = tSODViolationsRule2.tc_Rowid
                       tSODViolationsResources.ti_Sequence     = tSODViolationsRule2.ti_Sequence
                       tSODViolationsResources.tiRule          = tqViolationsResourcesByUser.tiSODViolation2RCategory
                    /* tSODViolationsResources.tcResourceNbr   =  */
                       tSODViolationsResources.tcResourceURI   = tqViolationsResourcesByUser.tcResourceURI
                       tSODViolationsResources.tcResourceLabel = tqViolationsResourcesByUser.tcResourceLabel.
            end.
        end.
        else do:
            /* ================================================================= */
            /* Load rule 2 violations, excluding resource detail.                */
            /* ================================================================= */
            <Q-60 run ViolationsByUser (all) (Read) (NoCache)
               (input viSearchCompanyId, (CompanyId)
                input viSearchDomainId, (DomainId)
                input tqUserByUsrLogin.tiUsr_ID, (UserId)
                output dataset tqViolationsByUser) in BSODViolationRule2 >

            for each tqViolationsByUser by tqViolationsByUser.tcRole1Name
                                        by tqViolationsByUser.tcSODCategoryCode1
                                        by tqViolationsByUser.tcRole2Name
                                        by tqViolationsByUser.tcSODCategoryCode2:

                if vcSearchRoleName <> ""
                and vcSearchRoleName <> ?
                and not (tqViolationsByUser.tcRole1Name = vcSearchRoleName or
                         tqViolationsByUser.tcRole2Name = vcSearchRoleName)
                then next.

                if vcSearchRoleNameBegins <> ""
                and vcSearchRoleNameBegins <> ?
                and not (tqViolationsByUser.tcRole1Name begins vcSearchRoleNameBegins or
                         tqViolationsByUser.tcRole2Name begins vcSearchRoleNameBegins)
                then next.

                if vcSearchRoleNameFrom <> ""
                and vcSearchRoleNameFrom <> ?
                and (tqViolationsByUser.tcRole1Name < vcSearchRoleNameFrom or
                     tqViolationsByUser.tcRole2Name < vcSearchRoleNameFrom)
                then next.

                if vcSearchRoleNameTo <> ""
                and vcSearchRoleNameTo <> ?
                and (tqViolationsByUser.tcRole1Name > vcSearchRoleNameTo or
                     tqViolationsByUser.tcRole2Name > vcSearchRoleNameTo)
                then next.

                if vcSearchRoleNameMatches <> ""
                and vcSearchRoleNameMatches <> ?
                and not (tqViolationsByUser.tcRole1Name matches vcSearchRoleNameMatches or
                         tqViolationsByUser.tcRole2Name matches vcSearchRoleNameMatches)
                then next.

                if vcSearchExclusionLevel <> "" 
                and vcSearchExclusionLevel <> ?
                and not tqViolationsByUser.tcSODExclusionLevel = vcSearchExclusionLevel
                then next.

                viRuleCount = viRuleCount + 1.
                create tSODViolationsRule2.
                assign tSODViolationsRule2.tc_Rowid                  = "x" + string(viRuleCount)
                       tSODViolationsRule2.ti_Sequence               = viRuleCount
                       tSODViolationsRule2.tcUsrName                 = tqUserByUsrLogin.tcUsrName
                       tSODViolationsRule2.tcRoleName1               = tqViolationsByUser.tcRole1Name
                       tSODViolationsRule2.tcRoleName2               = tqViolationsByUser.tcRole2Name
                       tSODViolationsRule2.tcScope                   = (if tqViolationsByUser.tcCompanyCode = "" then tqViolationsByUser.tcDomainCode else tqViolationsByUser.tcCompanyCode)
                       tSODViolationsRule2.tcSODCategoryCode1        = tqViolationsByUser.tcSODCategoryCode1
                       tSODViolationsRule2.tcSODCategoryCode2        = tqViolationsByUser.tcSODCategoryCode2
                       tSODViolationsRule2.tcSODCategoryDescription1 = tqViolationsByUser.tcSODCategoryDescription1
                       tSODViolationsRule2.tcSODCategoryDescription2 = tqViolationsByUser.tcSODCategoryDescription2
                       tSODViolationsRule2.tcSODExclusionLevel       = tqViolationsByUser.tcSODExclusionLevel.
            end.
        end.
    end.    /* each user */
end.    /* vlrule2 */