project BLF > class BControlProperty > method DataLoadByWindowActivity
Description
Load all data for one form
Parameters
icWindow | input | character | |
icBusinessComponentCode | input | character | |
icActivityCode | input | character | |
icRoleName | input | character | |
icUserLogin | input | character | |
iiLayerType | input | integer | |
ilIncludeLowerLevels | input | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program1/bcontrolproperty.p)
/* KriLae 20/06/2005: Do not pass a value for icWindow (change condition as this is a valid situation) */
if icBusinessComponentCode = ""
or icBusinessComponentCode = ?
or ((icWindow = "" or icWindow = ?) and
(icActivityCode = "" or icActivityCode = ?))
then do:
<M-1 run SetMessage
(input 'Invalid parameter values.':U (icMessage),
input '' (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-54':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
assign oiReturnStatus = -3.
return.
end.
assign oiReturnStatus = -98.
/* convert code to ID */
<Q-13 run BusActivityByCompActCode (all) (Read) (NoCache) (input icActivityCode, (BusActitvityCode)
input icBusinessComponentCode, (BusComponentCode)
output dataset tqBusActivityByCompActCode) in BBusinessComponent >
find first tqBusActivityByCompActCode no-error.
if available tqBusActivityByCompActCode
then assign viCurrentActivity = tqBusActivityByCompActCode.tiBusActivity_ID.
else do:
<M-3 run SetMessage
(input #T-11'Invalid Activity Code.':40(466)t-11# (icMessage),
input icBusinessComponentCode + '/':U + icActivityCode (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-55':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
assign oiReturnStatus = -3.
return.
end.
/* ================================================================= */
/* Load data from the database */
/* ================================================================= */
empty temp-table tqBusActivityByCompActCode.
empty temp-table tFcDynRel.
<M-4 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
if iiLayerType < 2
then do:
/* convert code to ID */
if icUserLogin = ""
or icUserLogin = ?
or icUserLogin = vcUserLogin
then do:
if viUsrId <> ?
then assign viLoadUserId = viUsrId.
end.
else do:
<Q-5 run UserByUsrLogin (all) (Read) (NoCache)
(input icUserLogin, (UsrLogin)
output dataset tqUserByUsrLogin) in BUser >
find first tqUserByUsrLogin no-error.
if available tqUserByUsrLogin
then assign viLoadUserId = tqUserByUsrLogin.tiUsr_ID.
else do:
<M-6 run SetMessage
(input #T-12'Unknown User':40(467)t-12# (icMessage),
input icUserLogin (icArguments),
input '' (icFieldName),
input '' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '' (icRowid),
input 'BLF-56':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
assign oiReturnStatus = -3.
return.
end.
empty temp-table tqUserByUsrLogin.
end.
create tFcDynRel.
assign tFcDynRel.tcFcFrom = "":U
tFcDynRel.tcFcTo = "ControlProperty":U
tFcDynRel.tcFcRel = "for each ControlProperty where ":U
+ "ControlProperty.BusActivity_ID = ":U + string(viCurrentActivity) + " and ":U
/* KriLae 20/06/2005: Do not pass a value for icWindow (change condition as this is a valid situation) */
+ (if icWindow = "":U or icWindow = ?
then "":U
else "ControlProperty.ControlPropertyWindow = '":U + icWindow + "' and ":U)
+ "ControlProperty.ControlPropertyLayerType = 1 and ":U
+ "ControlProperty.ControlPropertyLayerValue = ":U + string(viLoadUserId)
tFcDynRel.thFcBuffer = buffer t_oControlProperty:handle
tFcDynRel.thFcIBuffer = buffer t_iControlProperty:handle.
end.
if (ilIncludeLowerLevels = no and iiLayerType = 2)
or (ilIncludeLowerLevels = yes and iiLayerType < 3)
then do:
/* convert code to ID */
if icRoleName = ""
or icRoleName = ?
then empty temp-table tqRolePrim.
else do:
<Q-7 run RolePrim (all) (Read) (NoCache)
(input 0, (RoleID)
input icRoleName, (RoleName)
output dataset tqRolePrim) in BRole >
find first tqRolePrim no-error.
end.
if available tqRolePrim
then assign viLoadRoleId = tqRolePrim.tiRole_ID.
else assign viLoadRoleId = 0.
empty temp-table tqRolePrim.
create tFcDynRel.
assign tFcDynRel.tcFcFrom = "":U
tFcDynRel.tcFcTo = "ControlProperty":U
tFcDynRel.tcFcRel = "for each ControlProperty where ":U
+ "ControlProperty.BusActivity_ID = ":U + string(viCurrentActivity) + " and ":U
/* KriLae 20/06/2005: Do not pass a value for icWindow (change condition as this is a valid situation) */
+ (if icWindow = "":U or icWindow = ?
then "":U
else "ControlProperty.ControlPropertyWindow = '":U + icWindow + "' and ":U)
+ "ControlProperty.ControlPropertyLayerType = 2 and ":U
+ "ControlProperty.ControlPropertyLayerValue = ":U + string(viLoadRoleId)
tFcDynRel.thFcBuffer = buffer t_oControlProperty:handle
tFcDynRel.thFcIBuffer = buffer t_iControlProperty:handle.
end.
if ilIncludeLowerLevels = yes
or iiLayerType = 3
then do:
create tFcDynRel.
assign tFcDynRel.tcFcFrom = "":U
tFcDynRel.tcFcTo = "ControlProperty":U
tFcDynRel.tcFcRel = "for each ControlProperty where ":U
+ "ControlProperty.BusActivity_ID = ":U + string(viCurrentActivity) + " and ":U
/* KriLae 20/06/2005: Do not pass a value for icWindow (change condition as this is a valid situation) */
+ (if icWindow = "":U or icWindow = ?
then "":U
else "ControlProperty.ControlPropertyWindow = '":U + icWindow + "' and ":U)
+ "ControlProperty.ControlPropertyLayerType = 3 and ":U
+ "ControlProperty.ControlPropertyLayerValue = 0":U
tFcDynRel.thFcBuffer = buffer t_oControlProperty:handle
tFcDynRel.thFcIBuffer = buffer t_iControlProperty:handle.
end.
create tFcDynRel.
assign tFcDynRel.tcFcFrom = "ControlProperty":U
tFcDynRel.tcFcTo = "ControlPropertySegment":U
tFcDynRel.tcFcRel = "for each ControlPropertySegment where ":U
+ "ControlPropertySegment.ControlProperty_ID = ControlProperty.ControlProperty_ID":U
tFcDynRel.thFcBuffer = buffer t_oControlPropertySegment:handle
tFcDynRel.thFcIBuffer = buffer t_iControlPropertySegment:handle
tFcDynRel.thFcSBuffer = buffer t_sControlPropertySegment:handle.
<M-9 run StartPersistence (output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BControlProperty>
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
<M-10 run ReadData
(input tFcDynRel (tDynRel),
input {&TARGETPROCEDURE} (ihClass),
output viFcReturnSuper (oiReturnStatus)) in persistence>
/* no error if nothing found */
if viFcReturnSuper = -4
then viFcReturnSuper = 0.
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.
/* KriLae 20/06/2005: If no value for icWindow was passed then assign it here */
if icWindow = "":U or
icWindow = ?
then do :
find first tControlProperty no-lock no-error.
if available tControlProperty
then assign icWindow = tControlProperty.ControlPropertyWindow.
end.
assign vcCurrentWindow = icWindow
viCurrentLayerType = iiLayerType
viCurrentLayerValue = (if iiLayerType = 1
then viLoadUserId
else if iiLayerType = 2
then viLoadRoleId
else 0).
if oiReturnStatus = -98
then assign oiReturnStatus = 0.