project BLF > class BWorkObject > method ValidateComponent
Description
Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.
Parameters
oiReturnStatus | output | integer | |
Internal usage
unused
program code (program/bworkobject.p)
/* ================================================= */
/* Set the ID's based on the Codes */
/* Start queries before the loop, stop then after it */
/* ================================================= */
for each t_sWorkObject where
t_sWorkObject.tc_Status = "N":U or
t_sWorkObject.tc_Status = "C":U :
find first t_iWorkObject where
t_iWorkObject.tc_Rowid = t_sWorkObject.tc_Rowid
no-lock no-error.
/* ==== */
/* Role */
/* ==== */
if t_sWorkObject.tcRoleName = "":U or t_sWorkObject.tcRoleName = ?
then assign t_sWorkObject.Role_ID = 0.
else do :
if t_sWorkObject.tc_Status = "N":U or
(available t_iWorkObject and
t_iWorkObject.tcRoleName <> t_sWorkObject.tcRoleName)
then do :
assign t_sWorkObject.Role_ID = 0.
<Q-3 run RolePrim (all) (Read) (NoCache)
(input ?, (RoleID)
input t_sWorkObject.tcRoleName, (RoleName)
output dataset tqRolePrim) in BRole >
find first tqRolePrim where
tqRolePrim.tcRoleName = t_sWorkObject.tcRoleName
no-lock no-error.
if available tqRolePrim
then assign t_sWorkObject.Role_ID = tqRolePrim.tiRole_ID.
end. /* if t_sWorkObject.tc_Status = "N":U or */
end. /* if Code = "":U */
/* ========= */
/* Component */
/* ========= */
if t_sWorkObject.tcBusComponentCode = "":U or t_sWorkObject.tcBusComponentCode = ?
then assign t_sWorkObject.BusComponent_ID = 0.
else do :
if t_sWorkObject.tc_Status = "N":U or
(available t_iWorkObject and
t_iWorkObject.tcBusComponentCode <> t_sWorkObject.tcBusComponentCode)
then do :
assign t_sWorkObject.BusComponent_ID = 0.
<Q-5 run BusComponentPrim (all) (Read) (NoCache) (input ?, (BusComponentID)
input t_sWorkObject.tcBusComponentCode, (BusComponentCode)
output dataset tqBusComponentPrim) in BBusinessComponent >
find first tqBusComponentPrim where
tqBusComponentPrim.tcBusComponentCode = t_sWorkObject.tcBusComponentCode
no-lock no-error.
if available tqBusComponentPrim
then assign t_sWorkObject.BusComponent_ID = tqBusComponentPrim.tiBusComponent_ID.
end. /* if t_sWorkObject.tc_Status = "N":U or */
end. /* if Code = "":U */
/* ========== */
/* Activities */
/* ========== */
if t_sWorkObject.tcBusComponentCode = "":U or t_sWorkObject.tcBusComponentCode = ? or
t_sWorkObject.tcBusActivityCode = "":U or t_sWorkObject.tcBusActivityCode = ?
then assign t_sWorkObject.BusActivity_ID = 0.
else do :
if t_sWorkObject.tc_Status = "N":U or
(available t_iWorkObject and
(t_iWorkObject.tcBusComponentCode <> t_sWorkObject.tcBusComponentCode or
t_iWorkObject.tcBusActivityCode <> t_sWorkObject.tcBusActivityCode))
then do :
assign t_sWorkObject.BusActivity_ID = 0.
<Q-7 run BusActivityPrim (all) (Read) (NoCache) (input ?, (BusActivityID)
input t_sWorkObject.tcBusActivityCode, (BusActivityCode)
input t_sWorkObject.tcBusComponentCode, (BusComponentCode)
output dataset tqBusActivityPrim) in BBusinessComponent >
find first tqBusActivityPrim where
tqBusActivityPrim.tcBusComponentCode = t_sWorkObject.tcBusComponentCode and
tqBusActivityPrim.tcBusActivityCode = t_sWorkObject.tcBusActivityCode
no-lock no-error.
if available tqBusActivityPrim
then assign t_sWorkObject.BusActivity_ID = tqBusActivityPrim.tiBusActivity_ID.
end. /* if t_sWorkObject.tc_Status = "N":U or */
end. /* if Code = "":U */
/* ============== */
/* ObjectFlexStat */
/* ============== */
if t_sWorkObject.tcObjectFlexStatusCode = "" or
t_sWorkObject.tcObjectFlexStatusCode = ?
then assign t_sWorkObject.ObjectFlexStatus_ID = 0.
else do:
<Q-11 run BusComponentByLabelCodeID (all) (Read) (NoCache)
(input t_sWorkObject.BusComponent_ID, (BusComponentID)
input ?, (BusComponentCode)
input ?, (BusComponentLabel)
output dataset tqBusComponentByLabelCodeID) in BBusinessComponent >
find first tqBusComponentByLabelCodeID where
tqBusComponentByLabelCodeID.tiBusComponent_ID = t_sWorkObject.BusComponent_ID
no-lock no-error.
if available tqBusComponentByLabelCodeID
then assign vcBusComponentCode = tqBusComponentByLabelCodeID.tcBusComponentCode.
else assign vcBusComponentCode = "":U.
<Q-12 run SelectObjectFlexStat (all) (Read) (NoCache)
(input t_sWorkObject.tcObjectFlexStatusCode, (ObjectFlexStatusCode)
input '':U, (ObjectFlexStatusDescription)
input vcBusComponentCode, (BusinessComponent)
output dataset tqSelectObjectFlexStat) in BObjectFlexStatus >
find first tqSelectObjectFlexStat no-error.
if available tqSelectObjectFlexStat
then assign t_sWorkObject.ObjectFlexStatus_ID = tqSelectObjectFlexStat.tiObjectFlexStatus_ID.
else do:
<M-13 run SetMessage
(input #T-14'Invalid flex status.':100(479)t-14# (icMessage),
input '' (icArguments),
input 't_sWorkObject.tcObjectFlexStatusCode':U (icFieldName),
input t_sWorkObject.tcObjectFlexStatusCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sWorkObject.tc_Rowid (icRowid),
input 'BLF-280':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
assign oiReturnStatus = -1.
end. /* if available tqSelectObjectFlexStat */
end.
end. /* for each t_sWorkObject where */
if oiReturnStatus < 0
then return.
<ANCESTOR-CODE>
For Each t_sWorkObject Where
t_sWorkObject.tc_Status = 'C':U Or
t_sWorkObject.tc_Status = 'N':U:
/* Check if the role hase permission to use the activity */
If t_sWorkObject.Role_ID <> 0 And
t_sWorkObject.Role_ID <> ? And
t_sWorkObject.BusActivity_ID <> 0 And
t_sWorkObject.BusActivity_ID <> ?
Then Do:
<Q-15 assign vlFcQueryRecordsAvailable = RoleBusActivityByActivityRole (NoCache) (input t_sWorkObject.BusActivity_ID, (BusActivityID)
input t_sWorkObject.Role_ID, (RoleID)
input ?, (RoleName)) in BRole >
If vlFcQueryRecordsAvailable = False
Then Do:
Assign oiReturnStatus = -1.
<M-16 run SetMessage
(input #T-15'The role you selected has no permission to use the activity you selected.':100(6536)t-15# (icMessage),
input '':U (icArguments),
input 't_sWorkObject.tcRoleName':U (icFieldName),
input t_sWorkObject.tcRoleName (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sWorkObject.tc_Rowid (icRowid),
input 'BLF-281':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BWorkObject>
End.
End.
End. /* For Each t_sWorkObject */