project BLF > class BRole > method CreateRolResource
Description
Add Method CreateRoleBusActivity
Parameters
ipResourceIds | input | longchar | Comma-seperated list of ResourceID's |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program6/brole.p)
/* ====================== */
/* No input means bye-bye */
/* ====================== */
if ipResourceIds = ? or
ipResourceIds = '':U
then return.
/* ======================= */
/* Get Role 'General Role' */
/* ======================= */
<Q-3 run RolePrim (all) (Read) (NoCache)
(input ?, (RoleID)
input 'SUPERUSER':U, (RoleName)
output dataset tqRolePrim) in BRole >
find tqRolePrim where
tqRolePrim.tcRoleName = 'SUPERUSER':U
no-lock no-error.
if not available tqRolePrim
then return.
/* ================ */
/* dataload of Role */
/* ================ */
/*
* FIN-19193 :
* KeepPrevious must be true, not because of previous DataLoad but because tAlreadyCalculatedRecords must be created for synchronize (method AddGenCodeGroupToRoles)
*/
<M-8 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input string (tqRolePrim.tiRole_ID) (icObjectIds),
input '' (icFreeform),
input true (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BRole>
find tRole where
tRole.Role_ID = tqRolePrim.tiRole_ID
no-lock no-error.
if not available tRole
then do:
assign vcMessage = trim(#T-10'The role with name 'SUPERUSER' could not be loaded.':255(531)T-10#)
oiReturnStatus = -3.
<M-9 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input ? (icRowid),
input 'BLF-181':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BRole>
end.
/* ============================================== */
/* Add RoleResource-record for each ID in list */
/* ============================================== */
do viResourceIdsCount = num-entries(ipResourceIds) to 1 by -1 :
assign viResourceId = integer(entry(viResourceIdsCount, ipResourceIds)).
find first tRoleResource where
tRoleResource.Resource_ID = viResourceId and
tRoleResource.Role_ID = tRole.Role_ID
no-lock no-error.
if not available tRoleResource
then do:
<M-2 run AddDetailLine (input 'RoleResource':U (icTable),
input tRole.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BRole>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
assign tRoleResource.Resource_ID = viResourceId.
End.
end. /* do viBusActivityIDCount = 1 to num-entries(icBusActivityID) */
/* ================== */
/* Validate Component */
/* ================== */
<M-5 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BRole>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
/* ================== */
/* Additional UPdates */
/* ================== */
<M-6 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BRole>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.
/* ======== */
/* DataSave */
/* ======== */
<M-7 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BRole>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0
then return.