project BLF > class BSODViolationRule2 > method DeleteByUserRoleCompanyCategory

Description

delete violations


Parameters


iiUsrIDinputinteger
iiRoleIDinputinteger
iiDomainIDinputinteger
iiCompanyIDinputinteger
iiSODCategory1IDinputinteger
iiSODCategory2IDinputinteger
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method BCompany.AdditionalUpdates
method BRole.AdditionalUpdates
method BSODCategoryExclusion.AdditionalUpdates
method BSODPolicyException.AdditionalUpdates
method BUser.AdditionalUpdates
method BUserRole.AdditionalUpdates


program code (program1/bsodviolationrule2.p)

if oiReturnStatus = 0
then assign oiReturnStatus = -98.

if iiCompanyID = ?
then assign iiCompanyID = 0.

if iiDomainID = ?
then assign iiDomainID = 0.

if iiRoleID = ?
then assign iiRoleID = 0.

if iiSODCategory1ID = ?
then assign iiSODCategory1ID = 0.

if iiSODCategory2ID = ?
then assign iiSODCategory2ID = 0.

if iiUsrID = ?
then assign iiUsrID = 0.

if iiCompanyID      = 0 and
   iiDomainID       = 0 and
   iiRoleID         = 0 and
   iiSODCategory1ID = 0 and
   iiSODCategory2ID = 0 and
   iiUsrID          = 0
then return.

if iiSODCategory1ID = 0
then do:
    assign vcFreeform = "for each SODViolation2 where".

    if iiUsrID <> 0
    then assign vcFreeform = vcFreeform + " SODViolation2.Usr_ID = " + string(iiUsrID) + " and".

    if iiRoleID <> 0
    then assign vcFreeform = vcFreeform + " (SODViolation2.Role1_ID = " + string(iiRoleID) + " or SODViolation2.Role2_ID = " + string(iiRoleID) + ") and".

    if iiDomainID <> 0
    then assign vcFreeform = vcFreeform + " SODViolation2.Domain_ID = " + string(iiDomainID) + " and".

    if iiCompanyID <> 0
    then assign vcFreeform = vcFreeform + " SODViolation2.Company_ID = " + string(iiCompanyID) + " and".

    assign vcFreeform = substr(vcFreeform, 1, length(vcFreeform, "CHARACTER") - 4, "CHARACTER").

    <M-1 run DataLoad
       (input  '' (icRowids), 
        input  '' (icPkeys), 
        input  '' (icObjectIds), 
        input  vcFreeform (icFreeform), 
        input  yes (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>

    if viFcReturnSuper <> 0
    then assign oiReturnStatus = viFcReturnSuper.

    if viFcReturnSuper < 0
    then return.
end.
else do:
    assign vcFreeform = "for each SODViolation2 where" +
                        "         SODViolation2.SODCategory1_ID = " + string(iiSODCategory1ID) + " and" +
                        "         SODViolation2.SODCategory2_ID = " + string(iiSODCategory2ID).

    if iiUsrID <> 0
    then assign vcFreeform = vcFreeform + " and SODViolation2.Usr_ID = " + string(iiUsrID).

    if iiRoleID <> 0
    then assign vcFreeform = vcFreeform + " and (SODViolation2.Role1_ID = " + string(iiRoleID) + " or SODViolation2.Role2_ID = " + string(iiRoleID) + ")".

    if iiDomainID <> 0
    then assign vcFreeform = vcFreeform + " and SODViolation2.Domain_ID = " + string(iiDomainID).

    if iiCompanyID <> 0
    then assign vcFreeform = vcFreeform + " and SODViolation2.Company_ID = " + string(iiCompanyID).

    <M-3 run DataLoad
       (input  '' (icRowids), 
        input  '' (icPkeys), 
        input  '' (icObjectIds), 
        input  vcFreeform (icFreeform), 
        input  yes (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>

    if viFcReturnSuper = -4
    then assign vlLoad1         = yes
                viFcReturnSuper = 0.

    if viFcReturnSuper <> 0
    then assign oiReturnStatus = viFcReturnSuper.

    if viFcReturnSuper < 0
    then return.

    assign vcFreeform = "for each SODViolation2 where" +
                        "         SODViolation2.SODCategory1_ID = " + string(iiSODCategory2ID) + " and" +
                        "         SODViolation2.SODCategory2_ID = " + string(iiSODCategory1ID).

    if iiUsrID <> 0
    then assign vcFreeform = vcFreeform + " and SODViolation2.Usr_ID = " + string(iiUsrID).

    if iiRoleID <> 0
    then assign vcFreeform = vcFreeform + " and (SODViolation2.Role1_ID = " + string(iiRoleID) + " or SODViolation2.Role2_ID = " + string(iiRoleID) + ")".

    if iiDomainID <> 0
    then assign vcFreeform = vcFreeform + " and SODViolation2.Domain_ID = " + string(iiDomainID).

    if iiCompanyID <> 0
    then assign vcFreeform = vcFreeform + " and SODViolation2.Company_ID = " + string(iiCompanyID).

    <M-4 run DataLoad
       (input  '' (icRowids), 
        input  '' (icPkeys), 
        input  '' (icObjectIds), 
        input  vcFreeform (icFreeform), 
        input  yes (ilKeepPrevious), 
        output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>

    if viFcReturnSuper = -4
    then assign vlLoad2         = yes
                viFcReturnSuper = 0.

    if viFcReturnSuper <> 0
    then assign oiReturnStatus = viFcReturnSuper.

    if viFcReturnSuper < 0
    then return.

    if vlLoad1 and
       vlLoad2
    then do:
        assign oiReturnStatus = -4.
        return.
    end.
end.

<M-2 run DeleteAndLog
   (input  iiRoleID (iiRoleID), 
    input  0 (iiResourceID), 
    input  iiDomainID (iiDomainID), 
    input  iiCompanyID (iiCompanyID), 
    input  iiUsrID (iiUsrID), 
    input  0 (iiSODCategory1ID), 
    input  0 (iiSODCategory2ID), 
    output viFcReturnSuper (oiReturnStatus)) in BSODViolationRule2>

if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.

if viFcReturnSuper < 0
then return.

if oiReturnStatus = -98
then assign oiReturnStatus = 0.