project QadFinancials > class BResource > method ApiSynchronizeCustom
Description
This method is used to add logic to the synchronization of resources in other classes.
Parameters
olUpdatesDone | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
BLF
program code (program/bresource.p)
/* ============================================================================================ */
/* This method will */
/* - remove any MFGPRO resource which is not on the menu */
/* - create a MFGPRO resource for which a menu entry is found. This will be linked to SuperUser */
/* - Update the resource label with the menu label in case there is a difference */
/* - Update the link to the BusActvity in case this is needed */
/* ============================================================================================ */
define variable v1 as character case-sensitive no-undo.
define variable v2 as character case-sensitive no-undo.
<ANCESTOR-CODE>
/*load all menu resources*/
<M-1 run DataLoad
(input '' (icRowids),
input '' (icPkeys),
input '' (icObjectIds),
input '' (icFreeform),
input False (ilKeepPrevious),
output viFcReturnSuper (oiReturnStatus)) in BResource>
If viFcReturnSuper = -4
Then Assign viFcReturnSuper = 0.
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
/* Delete old resources (rename is not supported) */
for each tResources Where
tResources.ResourceType = {&RESOURCE-TYPE-MENU}:
assign tResources.tc_Status = "D":U.
end.
/*read all menus*/
<Q-3 run MenuDetailByAll (all) (Read) (NoCache)
(output dataset tqMenuDetailByAll) in BMfgMenu >
For Each tqMenuDetailByAll break by tqMenuDetailByAll.tcmnd_uri:
/* Each Resource has to be processed only once */
if not first-of (tqMenuDetailByAll.tcmnd_uri)
then next.
if tqMenuDetailByAll.tcmnd_uri = ""
then next.
Find First tResources Where
tResources.ResourceURI = tqMenuDetailByAll.tcmnd_uri No-error.
If Available tResources
Then Do:
/* ================================================================================================= */
/* In case the Resource record exists, we only check if the label is the same as the one in the menu */
/* If not, then we update theResource label */
/* ================================================================================================= */
assign v1 = tResources.ResourceLabel.
v2 = tqMenuDetailByAll.tcmnd_label.
if v1 = v2
then do:
if tResources.tc_Status = "D"
then Assign tResources.tc_Status = "".
End.
Else Do:
tResources.ResourceLabel = tqMenuDetailByAll.tcmnd_label.
if tResources.tc_Status <> "N"
then Assign tResources.tc_Status = 'C':U
olUpdatesDone = True.
End.
/* ================================================================================================= */
/* For existing CBF resources we check and correct the link to BusActivity if needed */
/* ================================================================================================= */
<I-38 {READDIRECTDBACCESS
&READTABLENAMES = "'BusComponent BusActivity'"}>
if tResources.ResourceURI begins 'urn:cbf:' and
num-entries (tResources.ResourceURI,":") = 3
then do :
assign vcTemp = entry (3,tResources.ResourceURI,':').
if num-entries (vcTemp,'.') = 2
then do:
find BusComponent where
BusComponent.BusComponentCode = entry (1,vcTemp,'.')
no-lock no-error.
if available BusComponent
then do:
find BusActivity of BusComponent where
BusActivity.BusActivityCode = entry (2,vcTemp,'.')
no-lock no-error.
if available BusActivity and
(tResources.BusActivity_ID <> BusActivity.BusActivity_ID or
tResources.tcBusComponentCode <> BusComponent.BusComponentCode or
tResources.tcBusActivityCode <> BusActivity.BusActivityCode)
then assign tResources.BusActivity_ID = BusActivity.BusActivity_ID
tResources.tcBusComponentCode = BusComponent.BusComponentCode
tResources.tcBusActivityCode = BusActivity.BusActivityCode
tResources.tc_Status = 'C':U
olUpdatesDone = True.
end. /* if available BusComponent */
end. /* if num-entries (vcTemp,'.') = 2 */
end. /* tResources.ResourceURI begins 'urn:cbf:' */
End. /* If Available tResources */
Else Do:
<M-6 run AddDetailLine
(input 'Resources':U (icTable),
input '' (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BResource>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
Assign tResources.ResourceURI = tqMenuDetailByAll.tcmnd_uri
tResources.ResourceLabel = tqMenuDetailByAll.tcmnd_label
tResources.ResourceType = (if tqMenuDetailByAll.tcmnd_uri begins "urn:cbf:"
then {&RESOURCE-TYPE-ACTIVITY}
else {&RESOURCE-TYPE-MENU})
olUpdatesDone = True.
End.
End. /*For Each tqMfgResourcesByMenu:*/
/* ================================================================= */
/* Do not synchronize if the generalized code security package */
/* is not installed (database table ctg_mstr does not exist). */
/* ================================================================= */
<M-34 run StartPersistence
(output vhFcComponent (ohPersistence),
output viFcReturnSuper (oiReturnStatus)) in BResource>
<M-90 run DBTableExists
(input 'ctg_mstr' (icDBTableName),
output vldoGCG (olExists)) in persistence>
if vldoGCG
then do:
<M-55 run CreateGenCodeGroups
(input-output olUpdatesDone (blUpdatesDone),
output viFcReturnSuper (oiReturnStatus)) in BResource>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
end.