180 lines
8.5 KiB
Plaintext
180 lines
8.5 KiB
Plaintext
Compile function React_Run_Services(@Service, @Params)
|
|
/***********************************************************************************************************************
|
|
|
|
Name : React_Run_Services
|
|
|
|
Description : Handler program for all REACT_RUN services.
|
|
|
|
Notes : Application errors should be logged using the Error Services module. There are a few methodological
|
|
assumptions built into way errors are managed which are important to understand in order to properly
|
|
work with Error Services:
|
|
|
|
- The term 'top' refers to the originating procedure of a call stack and the term 'bottom' refers to
|
|
the last routine (or the current routine) within a call stack. Within the OpenInsight Debugger
|
|
this will appear backwards since the originating procedure always appears at the bottom of the
|
|
list and the current routine appears at the top of the list. We are using this orientation because
|
|
it is common to refer to the process of calling other procedures as 'drilling down'.
|
|
|
|
- The reason for defining the orientation of the call stack is because Error_Services allows for
|
|
multiple error conditions to be appended to an original error. In most cases this will happen when
|
|
a procedure at the bottom of the stack generates an error condition and then returns to its
|
|
calling procedure. This higher level procedure can optionally add more information relevant to
|
|
itself. This continues as the call stack 'bubbles' its way back to the top to where the
|
|
originating procedure is waiting.
|
|
|
|
- Native OpenInsight commands that handle errors (e.g., Set_Status, Set_FSError, Set_EventStatus)
|
|
preserve their error state until explicitly cleared. This can hinder the normal execution of code
|
|
since subsequent procedures (usually SSPs) will fail if a pre-existing error condition exists.
|
|
Our philosophy is that error conditions should automatically be cleared before a new procedure
|
|
is executed to avoid this problem. However, the nature of Basic+ does not make this easy to
|
|
automate for any given stored procedure. Therefore, if a stored procedure wants to conform to our
|
|
philosophy then it should include a call into the 'Clear' service request at the top of the
|
|
program. Alternatively this can be done through a common insert (see SERVICE_SETUP for example.)
|
|
|
|
- Service modules will use the SERVICE_SETUP insert and therefore automatically clear out any
|
|
error conditions that were set before.
|
|
|
|
Parameters :
|
|
Service [in] -- Name of the service being requested
|
|
Param1-10 [in/out] -- Additional request parameter holders
|
|
Response [out] -- Response to be sent back to the Controller (MCP) or requesting procedure
|
|
|
|
Metadata :
|
|
|
|
History : (Date, Initials, Notes)
|
|
12/14/22 djs Original programmer.
|
|
04/12/23 djs This service got added it Azure DevOps repo, but never pulled into PROD OI instance.
|
|
Adding a comment to get the file tracked as a change and picked up by SRP Git Utility.
|
|
|
|
***********************************************************************************************************************/
|
|
#pragma precomp SRP_PreCompiler
|
|
|
|
$Insert LOGICAL
|
|
$Insert SERVICE_SETUP
|
|
$Insert REACT_RUN_EQUATES
|
|
|
|
Declare function Database_Services, SRP_JSON, Error_Services, React_Run_Services
|
|
Declare subroutine Database_Services, SRP_JSON, Error_Services, React_Run_Services
|
|
|
|
GoToService
|
|
|
|
Return Response or ""
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// SERVICES
|
|
//-----------------------------------------------------------------------------
|
|
|
|
Service ConvertRecordToJSON(KeyID, Record, ItemURL)
|
|
|
|
jsonRecord = ''
|
|
|
|
If KeyID NE '' then
|
|
|
|
If Record EQ '' then Record = Database_Services('ReadDataRow', 'REACT_RUN', KeyID)
|
|
If Error_Services('NoError') then
|
|
@DICT = Database_Services('GetTableHandle', 'DICT.REACT_RUN')
|
|
@ID = KeyID
|
|
@RECORD = Record
|
|
If SRP_JSON(objJSON, 'New', 'Object') then
|
|
|
|
If SRP_JSON(objReactRun, 'New', 'Object') then
|
|
SRP_JSON(objReactRun, 'SetValue', 'keyId', @ID)
|
|
SRP_JSON(objJSON, 'Set', 'reactRun', objReactRun)
|
|
SRP_JSON(objReactRun, 'Release')
|
|
end
|
|
|
|
If itemURL NE '' then
|
|
// The itemURL was passed in so add HAL+JSON properties.
|
|
|
|
// Create the _links property and then all link objects needed for this resource.
|
|
If SRP_JSON(objLinks, 'New', 'Object') then
|
|
// Create a self link.
|
|
If SRP_JSON(objLink, 'New', 'Object') then
|
|
SRP_JSON(objLink, 'SetValue', 'href', ItemURL, 'String')
|
|
SRP_JSON(objLink, 'SetValue', 'title', 'Self', 'String')
|
|
SRP_JSON(objLinks, 'Set', 'self', objLink)
|
|
SRP_JSON(objLink, 'Release')
|
|
end
|
|
SRP_JSON(objJSON, 'Set', '_links', objLinks)
|
|
SRP_JSON(objLinks, 'Release')
|
|
end
|
|
|
|
// Create the _class property for this resource.
|
|
SRP_JSON(objJSON, 'SetValue', '_class', 'resource')
|
|
end
|
|
jsonRecord = SRP_JSON(objJSON, 'Stringify', 'Styled')
|
|
SRP_JSON(objJSON, 'Release')
|
|
end else
|
|
Error_Services('Add', 'Unable to create JSON representation in the ' : Service : ' service.')
|
|
end
|
|
end
|
|
end else
|
|
Error_Services('Add', 'KeyID argument was missing in the ' : Service : ' service.')
|
|
end
|
|
|
|
Response = jsonRecord
|
|
|
|
End Service
|
|
|
|
|
|
Service AddCleanInsp(RDSNo, CleanInspKey, Stage)
|
|
|
|
If ( (RDSNo NE '') and (CleanInspKey NE '') and (Stage NE '') ) then
|
|
RunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
|
|
If Error_Services('NoError') then
|
|
RunRec = INSERT(RunRec,REACT_RUN_CI_NO$,1,0,CleanInspKey)
|
|
RunRec = INSERT(RunRec,REACT_RUN_CI_STAGE$,1,0,Stage)
|
|
Database_Services('WriteDataRow', 'REACT_RUN', RDSNo, RunRec)
|
|
end
|
|
end else
|
|
ErrorMsg = 'Error in ':Service:' service. Null RDSNo, CleanInspKey, or Stage passed in.'
|
|
Error_Services('Add', ErrorMsg)
|
|
end
|
|
|
|
If Error_Services('NoError') then
|
|
Response = True$
|
|
end else
|
|
Response = False$
|
|
end
|
|
|
|
end service
|
|
|
|
|
|
Service RemCleanInsp(RDSNo, CleanInspKey, Stage)
|
|
|
|
If ( (RDSNo NE '') and (CleanInspKey NE '') and (Stage NE '') ) then
|
|
RunRec = Database_Services('ReadDataRow', 'REACT_RUN', RDSNo)
|
|
If Error_Services('NoError') then
|
|
CINos = RunRec<REACT_RUN_CI_NO$>
|
|
CIStages = RunRec<REACT_RUN_CI_STAGE$>
|
|
Locate Stage in CIStages using @VM setting vPos then
|
|
CINos = Delete(CINos, 0, vPos, 0)
|
|
CIStages = Delete(CIStages, 0, vPos, 0)
|
|
RunRec<REACT_RUN_CI_NO$> = CINos
|
|
RunRec<REACT_RUN_CI_STAGE$> = CIStages
|
|
Database_Services('WriteDataRow', 'REACT_RUN', RDSNo, RunRec)
|
|
end else
|
|
ErrorMsg = 'Error in ':Service:' service. ':Stage:' stage not found in REACT_RUN record.'
|
|
Error_Services('Add', ErrorMsg)
|
|
end
|
|
end
|
|
end else
|
|
ErrorMsg = 'Error in ':Service:' service. Null RDSNo, CleanInspKey, or Stage passed in.'
|
|
Error_Services('Add', ErrorMsg)
|
|
end
|
|
|
|
If Error_Services('NoError') then
|
|
Response = True$
|
|
end else
|
|
Response = False$
|
|
end
|
|
|
|
end service
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Internal GoSubs
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|