Skip to content

Instantly share code, notes, and snippets.

@jbratu
Last active December 22, 2021 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbratu/ac4bc54e46545fdbf0b91be42be00e5f to your computer and use it in GitHub Desktop.
Save jbratu/ac4bc54e46545fdbf0b91be42be00e5f to your computer and use it in GitHub Desktop.
Utility code for working with OpenInsight RDK's. Currently useful for saving an RDK as a file or copying an RDK view (list of things to make and RDK of) to another copy of OpenInsight.
Function CS_RDK_UTIL(inMethod, Param1, Param2, Param3, Param4, outValue,outStat)
/*
Function: CS_RDK_UTIL
--- BP
CS_RDK_UTIL(inMethod, Param1, Param2, Param3, Param4, outValue,outStat)
---
Utility library For working With RDKs
Parameters:
inMethod - Varies depending On action.
Param1...Param4 - Varies depending On inMethod.
outValue - Unused. Optional Return value by reference.
outStat - Unused. Optional Return status by reference.
Revisions:
2020-01-04 - Fix bug where addViewWindow Not picking up all events.
2019-12-20 - Added addFromSyseposSavedList To import entities From saved Select list
2019-07-23 - Fixed bug With addViewSection when used With events causing entries To duplicate
Added exportViewForDisplay
2019-04-05 - Added ability To copy rows into RDK deployment
2019-03-11 - Added importView method To Read an exportView back into system
2018-08-25 - Added support For EVENT Repository types In cleanView
2018-06-12 - Added updateDeploymentDefinition to update existing definition With
new view and extraction path. Updated NaturalDocs formatting.
2016-12-20 - Added ability To create new RDK view And save it. Can add window And stored procedures.
2016-12-27 - Added ability to copy RDK view directly to another copy of OpenInsight using alias table.
2016-01-23 - Added cleanView method To Remove missing view entities.
*/
If Unassigned(inMethod) Then method = '' Else method = inMethod
If Unassigned(Param1) Then Param1 = ''
If Unassigned(Param2) Then Param2 = ''
If Unassigned(Param3) Then Param3 = ''
If Unassigned(Param4) Then Param4 = ''
If Unassigned(outValue) Then outValue = ''
If Unassigned(outStat) Then outStat = ''
RetVal = ''
*
* Declare System
Declare Function Assigned, Msg, Get_Status, XLATE
Declare Subroutine Msg, Set_Status, Alias_Table, Copy_row, Detach_table, Attach_Table
*
* Declare App
Declare Subroutine CS_RDK_UTIL, Repository, V119
Declare Function CS_RDK_UTIL, CS_RLIST_UTIL, Repository, V119
err = ''
$INSERT Msg_Equates
$Insert Logical
*
*Main case branch
*
A_CommuterModuleTop:
Begin Case
Case Method _eqc 'getView' ; Gosub getView_
Case Method _eqc 'newView' ; Gosub newView_
Case Method _eqc 'saveView' ; Gosub saveView_
Case Method _eqc 'addViewProc' ; Gosub addViewProc_
Case Method _eqc 'addViewRow' ; Gosub addViewRow_
Case Method _eqc 'addViewWindow' ; Gosub addViewWindow_
Case Method _eqc 'addInsert' ; Gosub addInsert_
Case Method _eqc 'addFromSyseposSavedList' ; Gosub addFromSyseposSavedList_
Case Method _eqc 'addViewSectionEntry' ; Gosub addViewSectionEntry_
Case Method _eqc 'updateDeploymentDefinition' ; Gosub updateDeploymentDefinition_
Case Method _eqc 'exportView' ; Gosub exportView_
Case Method _eqc 'exportViewForDisplay' ; Gosub exportViewForDisplay_
Case Method _eqc 'viewDeployedRDK' ; Gosub viewDeployedRDK_
Case Method _eqc 'importView' ; Gosub importView_
Case Method _eqc 'copyViewToSystem' ; Gosub copyViewToSystem_
Case Method _eqc 'cleanView' ; Gosub cleanView_
Case Otherwise$
A_CommuterModuleOtherwise:
*
* Example creating a new view, populating it, and saving it.
*
Return
Set_Status(0)
CS_RDK_UTIL('viewDeployedRDK', '\\server\revsoft\shared\pathtordk', 'TXT', 'C:\temp\out.txt')
If Get_Status(Err) Then
Msg(@WINDOW, Err)
End
return
ViewName = 'MYUPDATE_20180612' ;* RDK View Name
DefinitionName = 'SCRATCH' ;* RDK Deployment Definition Name
DESC = 'Routine bug fixes to window XYZ'
DeployFolder = "C:\TEMP\" : ViewName : "\"
*View = CS_RDK_UTIL('getView', ViewName)
//or
*View = CS_RDK_UTIL('newView', ViewName, 'Update ' : ViewName, Desc)
*CS_RDK_UTIL('addViewWindow', 'MY_WINDOW','','','',View)
*CS_RDK_UTIL('addViewProc', 'MY_WINDOW_EVENTS','','','',View)
*CS_RDK_UTIL('addViewRow',"MY_TABLE", "MY_KEY", '','',View )
*CS_RDK_UTIL('saveView', ViewName, View)
*Also update the RDK Definition
*Call RTI_OS_Directory('CREATE', DeployFolder,True$)
*CS_RDK_UTIL('updateDeploymentDefinition',DefinitionName, ViewName,DESC,DeployFolder)
Goto End
End Case
End:
Return RetVal
*
*End of the main branch
*
/*
interface: updateDeploymentDefinition
Update the RDK deployment definition.
--- BP
CS_RDK_UTIL('updateDeploymentDefinition',Definition, RepositoryView,Description,Path)
---
Parameters:
Definition - The RDK definition To update. Must already exist.
RepositoryView - This Repository view is applied To the deployment definition.
Description - Optional human readable definition For this update.
Path - Location the RDK deployment definition should extract to
Returns:
Boolean - True If success, Else false. Use Get_Status To check For errors.
Example:
--- BP
CS_RDK_UTIL('updateDeploymentDefinition','SCRATCH', '20180612_CUSTFIX','Fixed customer screen','\\server\revsoft\rdkupdates')
---
#AUTO_GENERATE_DOCS
*/
updateDeploymentDefinition_:
DefinitionKey = @APPID<1> : '*' : PARAM1
ReposView = PARAM2
Desc = PARAM3
Path = PARAM4
Open 'SYSREPOSRELEASES' To Table Else
Set_Status(-1, 1, 'Unable to open SYSREPOSRELEASES')
Return False$
End
Read Rec From Table, DefinitionKey Else
Set_Status(-1, 1, 'Unable to read deployment definition ' : DefinitionKey)
Return False$
End
Rec<1> = ReposView ;* Title
Rec<2> = Desc
Rec<6> = ReposView
Rec<10> = Path
Write Rec To Table, DefinitionKey Else
Set_Status(-1, 1, 'Unable to write deployment definition ' : DefinitionKey)
Return False$
End
Return True$
Return
/*
Get an existing view by name.
*/
getView_:
Key = Param1
Open 'SYSREPOSVIEWS' To Table Else Debug
Key = @APPID<1> : "*" : KEY
Read Rec From Table, Key Else
Rec = ''
End
RetVal = Rec
Return
/*
Create a blank view With the specified Key, Title, And Description
*/
newView_:
Key = Param1
Title = Param2
Desc = Param3
Rec = ''
Rec<1> = Title
Rec<2> = Desc
Rec<4> = @APPID<1>
Rec<11> = ''
Open 'SYSREPOSVIEWS' To Table Else Debug
Key = @APPID<1> : "*" : KEY
Write Rec To Table, Key Else Debug
RetVal = Rec
Return
/*
Save the specified view record With the specified key
*/
saveView_:
Key = Param1
Rec = Param2
Open 'SYSREPOSVIEWS' To Table Else Debug
Key = @APPID<1> : "*" : KEY
Write Rec To Table, Key Else Debug
Return
/*
Nothing - Returned OutValue by reference. Use Get_Status To check For errors
Example:
--- Code
CS_RDK_UTIL('addViewRow','SYSENV', 'CFG_SOMETHING','','',View)
---
*/
addViewRow_:
View = outValue
Table = Param1
Row = Param2
Name = Table : ":" : Row
EntId = @APPID<1>:'*APPROW**' : Name
ReposRec = ''
Set_Status(0)
Ent = Repository('GET', EntId)
EntExists = False$
If Get_Status(err) Then
If Err<1,1> = 'REP300' Then
*This entity does not exist so add it
*Clear the REP300 error off stack
Set_Status(0)
Repository('NEW', EntId, "", 1, 1, "","","","","", Name, ReposRec)
If Get_Status(err) Then
*Let error bubble up to calling function
EntExists = False$
Return
End Else
*Now add the row to our repository view
EntExists = True$
End
End
End Else
*This entity already exists so don't add it again
EntExists = True$
End
If EntExists Then
SectionName = 'Application Rows'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',Name,'',View)
OutValue = View
End
Return
/*
interface: addViewProc
Add an entry To a RDK View
--- BP
CS_RDK_UTIL('addViewProc',Entity, Dev,'','',View)
---
Parameters:
Entity - The name of the stored procedure To add To the RDK
Dev - If TRUE$ will include the sources And debug tables
Returns:
Nothing - Returned OutValue by reference.
Example:
--- BP
CS_RDK_UTIL('addViewProc','YOUR_WIN_EVENTS','','','',View)
---
*/
addViewProc_:
View = outValue
thisEntity = Param1
Dev = Param2
If Dev EQ '' Then Dev = True$
SectionName = 'Stored Procedure Executables'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',thisEntity,'',View)
If Dev Then
SectionName = 'Stored Procedure Debug Tables'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',thisEntity,'',View)
SectionName = 'Stored Procedures'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',thisEntity,'',View)
End
OutValue = View
Return
/*
interface: addViewWindow
Add an entry To a RDK View
--- BP
CS_RDK_UTIL('addViewWindow',Entity, Dev,'','',View)
---
Parameters:
Entity - The name of the window entity To add To the RDK
Dev - If TRUE$ will include the sources
Returns:
Nothing - Returned OutValue by reference.
Example:
--- BP
CS_RDK_UTIL('addViewWindow','WINNAME','','','',View)
---
*/
addViewWindow_:
View = outValue
thisEntity = Param1
Dev = Param2
If Dev EQ '' Then Dev = True$
*Get entities in view and convert for easier access
Entries = View<11>
Swap @VM With @FM In Entries
*Add the window executable
SectionName = 'OpenInsight Form Executables'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',thisEntity,'',View)
If Dev Then
*Dev mode so include window source
SectionName = 'OpenInsight Forms'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',thisEntity,'',View)
End
*
*Get all events associated with the window
*
QUERY = "SELECT SYSREPOSEVENTS WITH ENTITYID STARTING WITH '" : thisEntity : ".' AND WITH APPID = '" : @APPID<1> : "'"
Keys = CS_RLIST_UTIL('getKeys', thisEntity : " events", Query, True$, True$)
KeysCount = DCOUNT(Keys,@FM)
RelatedEvents = ''
*Loop through all the event keys
For i = 1 To KeysCount
Key = Keys<i>
E = Field(Key,"*", 2) ;*Get the event type from the key
thisEntitySub = Field(Key,"*", 3)
CS_RDK_UTIL('addViewSectionEntry','OpenInsight Event Executables',E,thisEntitySub,'',View)
If Dev Then
*Dev mode so include EVENT sources
CS_RDK_UTIL('addViewSectionEntry','OpenInsight Events',E,thisEntitySub,'',View)
End
Next i ;* i = ''
OutValue = View
Return
/*
interface: addInsert
Add an insert To a RDK View
--- BP
CS_RDK_UTIL('addInsert',Entity, Dev,'','',View)
---
Parameters:
Entity - The name of the window entity To add To the RDK
Returns:
Nothing - Returned OutValue by reference.
Example:
--- BP
CS_RDK_UTIL('addInsert','YOUR_TABLE_EQUATES','','','',View)
---
*/
addInsert_:
View = outValue
thisEntity = Param1
Dev = Param2
If Dev EQ '' Then Dev = True$
*Get entities in view and convert for easier access
Entries = View<11>
Swap @VM With @FM In Entries
*Add the window executable
SectionName = 'Stored Procedure Inserts'
CS_RDK_UTIL('addViewSectionEntry',SectionName,'',thisEntity,'',View)
OutValue = View
Return
/*
interface: addViewSectionEntry
Add an entry To a RDK View
--- BP
CS_RDK_UTIL('addViewSectionEntry',SectionName,SubSectionName,Entity,'',View)
---
Parameters:
SectionName - The name of the section In the list of view elements, I.e. 'OpenInsight Events'
SubSectionName - Usually an event. I.e. 'WRITE', 'CLOSE'
Entity - Name of the entity
Returns:
Nothing - Returned OutValue by reference.
Example:
CS_RDK_UTIL('addViewSectionEntry','OpenInsight Events','WRITE','WINNAME.','',View)
*/
addViewSectionEntry_:
SectionName = Param1
SubSectionName = Param2
thisEntity = Param3
View = OutValue
*Get the entries from the view
Entries = View<11>
*Swap for easier manipulation
Swap @VM With @FM In Entries
EntriesCount = DCount(Entries,@FM)
*If we don't have a subsection to deal with we can save a lot of steps
If SubSectionName EQ '' Then
*There is no sub-section so we can insert this right after the section
Locate SectionName In Entries Using @FM Setting Pos Then
*Section already exist. Insert entry after section name
Entries = Insert(Entries,Pos+1,0,0,'3-3:':thisEntity)
End Else
*Section doesn't exist. Add section name and entity
Entries<-1> = SectionName
Entries<-1> = '3-3:':thisEntity
End
*Skip to end and exit
Goto addViewSectionEntry_end
End
*
* There is a sub-section so we have to add it to the correct sub-section
* We will extract the correct subsection, check and add or create a new subsection, then insert it
* Back into the original list by recombining the sections prior and after
*
*Hold the section so we can sort through it
Section = ''
*Mark where the section starts and ends
SectionPosStart = 0
SectionPosEnd = 0
*Locate where, if it exists, this section begins
Locate SectionName In Entries Using @FM Setting Pos Then
*Section already exist
*Section starts on next line after title
Pos += 1
SectionPosStart = Pos
*Loop through all the entities in this section and store them in Section
For i = Pos To EntriesCount
*Get on entry
Entry = Entries<i>
*If it doesn't begin with a number then it must be the start of a new section
If Not(Num(Entry[1,1])) Then
*Found end of section, done extracting section
SectionPosEnd = i
i = EntriesCount
End Else
*Store this entry in the section
Section<-1> = Entry
End
Next i
*Figure out where this section ends in relation to the original list of entries
SectionPosEnd = SectionPosStart + DCOUNT(Section,@FM)
*
* Now we have the Section extracted from the entire View
* This will make it easier to look for the subsection
*
Locate '2-2:':SubsectionName In Section Using @FM Setting PosSub Then
*This subsection exists
Section = Insert(Section,PosSub+1,0,0,'3-3:':thisEntity)
End Else
*This subsection does not exist
Section<-1> = '2-2:':SubsectionName
Section<-1> = '3-3:':thisEntity
End
*
* Now Section contains the new entity we wanted to add
*
*
* Recombine Section in View - Start
*
EntriesNew = ''
*Add entries in beginning of list
For i = 1 To (SectionPosStart - 1)
EntriesNew<-1> = Entries<i>
Next i
*Add entries from our updated section in middle of list
For i = 1 To DCOUNT(Section,@FM)
EntriesNew<-1> = Section<i>
Next i
*Add entries at end of list
For i = SectionPosEnd To EntriesCount
EntriesNew<-1> = Entries<i>
Next i
*
* Re-combine Section in View - End
*
*If SubsectionName EQ 'CREATE' Then debug
Entries = EntriesNew
End Else
*Section and so the subsection doesn't exist either. We can just tack it on
Entries<-1> = SectionName
Entries<-1> = '2-2:':SubsectionName
Entries<-1> = '3-3:':thisEntity
End
addViewSectionEntry_end:
Swap @FM With @VM In Entries
View<11> = Entries
OutValue = View
Return
/*
interface: exportView
Write the specified RDK view To an OS file
--- BP
CS_RDK_UTIL('exportView', View, Dest)
---
Parameters:
View - Name of the RDK view as shown In the Open dialog
Dest - Folder To Write the RDK to.
Returns:
Nothing - Posts message box If fails.
Example:
From TCL
--- Code
run CS_RDK_UTIL 'exportView', 'MYSTUFF', 'C:\temp\'
---
Writes MYSTUFF.rdk.txt To the C:\temp folder
*/
exportView_:
ViewName = Param1
ViewKey = @APPID<1> : '*' : ViewName
DestFile = Param2
ViewRec = Xlate('SYSREPOSVIEWS', ViewKey, '', 'X')
If ViewRec EQ '' Then
Msg("View was not found in this application")
Return
End
If DestFile[-1,1] NE '\' Then
DestFile := '\'
End
DestFile := ViewName : ".rdk.txt"
OSWrite ViewRec To DestFile
Return
/*
interface: importView
Import the exported view back into Openinsight.
--- BP
CS_RDK_UTIL('importView', Src)
---
Parameters:
Dest - Source file created With exportView method.
Returns:
Nothing - Posts message box If fails Or Get_Status()
Example:
From TCL
--- Code
run CS_RDK_UTIL 'importView', 'C:\temp\MYSTUFF.rdk.txt'
---
Created the view MYSTUFF view.
*/
importView_:
SrcFile = Param1
Open 'SYSREPOSVIEWS' To Table Else
Set_Status(-1,1,'Unable to open SYSREPOSVIEWS')
Return
End
Set_Status(0)
OSRead ViewRec From SrcFile Then
End Else
Set_Status(-1,1,'Unable to read source view from ' : SrcFile : ' Status:' : Status())
Return
End
*Find the file name
ViewName = SrcFile [-1,'B\']
*Remove the file extension
Swap '.rdk.txt' With '' In ViewName
ViewKey = @APPID<1> : '*' : ViewName
Write ViewRec To Table, ViewKey Then
End Else
Set_Status(-1,1,'Unable to write view ' : ViewKey)
Return
End
Return
/*
interface: cleanView
Remove missing Or non-existant entities From RDK view
--- BP
CS_RDK_UTIL('cleanView', View)
---
Parameters:
View - Name of the RDK view as shown In the Open dialog
Returns:
Nothing - Posts message box If fails.
Example:
From TCL
--- Code
run CS_RDK_UTIL 'cleanView', 'MYSTUFF'
---
*/
cleanView_:
ViewName = Param1
ViewKey = @APPID<1> : '*' : ViewName
Open "SYSREPOSVIEWS" To Table Else
Msg("Could not open SYSREPOSVIEWS")
Return
End
Read ViewRec From Table,ViewKey Else
Msg("View was not found in this application")
Return
End
ViewEntities = ViewRec<11>
ViewEntitiesCleaned = ''
ViewEntitiesRemoved = ''
Swap @VM With @FM In ViewEntities
ViewEntitiesCount = DCOUNT(ViewEntities, @FM)
Type = '' ;* Type of entity being checked
Entity = '' ;* Entity ID (not record key) being checked
Event = '' ;* If repos entity is an event this will contain the name
*Loop through all the entities in the RDK view
For i = 1 To ViewEntitiesCount
Line = ViewEntities<i>
Entity = ''
If Line[1,4] EQ '2-2:' Then
*Event entity
Event = Line[5,Len(Line)]
End
If Line[1,4] EQ '3-3:' Then
*Repos entity
Entity = Line[5,Len(Line)]
End
*This line does not start with a number (depth in the tree) so it must be the
*start of a new trunk
If Not(Num(Line[1,1])) Then
*Repos entity type
Type = Line
Event = ''
ViewEntitiesCleaned<-1> = Type
ViewEntitiesRemoved<-1> = Type
Goto skip_entity_loop
End
*If we have a type and event but no entity the next line probably has it
If Type NE '' And Event NE '' And Entity EQ '' Then
*This line still needs to be perserved
ViewEntitiesCleaned<-1> = Line
Goto skip_entity_loop
End
If Type EQ '' Or Entity EQ '' Then
*We don't have enough information, next line should be enough to determine
*How to find this event in the repos
Goto skip_entity_loop
End
Found = False$
Begin Case
Case Type = "OpenInsight Events"
CheckKey = @APPID<1> : '*' : Event : '*' : Entity
CheckTable = 'SYSREPOSEVENTS'
Case Type = "OpenInsight Event Executables"
CheckKey = @APPID<1> : '*' : Event : '*' : Entity
CheckTable = 'SYSREPOSEVENTEXES'
Case Type = "OpenInsight Form Executables"
CheckKey = @APPID<1> : '**' : Entity
CheckTable = 'SYSREPOSWINEXES'
Case Type = "OpenInsight Forms"
CheckKey = @APPID<1> : '**' : Entity
CheckTable = 'SYSREPOSWINS'
Case Type = "Stored Procedure Debug Tables"
CheckKey = '@' : Entity : '*' : @APPID<1>
CheckTable = 'SYSOBJ'
Case Type = "Stored Procedure Executables"
CheckKey = '$' : Entity : '*' : @APPID<1>
CheckTable = 'SYSOBJ'
Case Type = "Stored Procedure Inserts" Or Type = "Stored Procedures"
CheckKey = Entity : '*' : @APPID<1>
CheckTable = 'SYSPROCS'
Case OTHERWISE$
*unsupported entity type
Msg("View entity type " : Type : " is not supported. Cannot clean view.")
return
End Case
If Xlate(CheckTable, CheckKey, '', 'C') EQ CheckKey Then
Found = False$
End Else
Found = True$
End
If Found Then
ViewEntitiesCleaned<-1> = Line
End Else
ViewEntitiesRemoved<-1> = Line
End
skip_entity_loop:
Next i
Swap @FM With @VM In ViewEntitiesCleaned
ViewRec<11> = ViewEntitiesCleaned
Write ViewRec To Table, ViewKey Else Debug
Return
/*
interface: copyViewToSystem
Write the specified RDK view To an OS file
--- BP
CS_RDK_UTIL('copyViewToSystem', View, Dest)
---
Parameters:
View - Name of the RDK view as shown In the Open dialog
Dest - Path To an OpenInsight root directory.
Returns:
Nothing - Posts message box If fails.
Example:
From TCL
--- Code
run CS_RDK_UTIL 'copyViewToSystem', 'MYSTUFF', 'C:\Revsoft\OIOther'
---
Copies the RDK view MYSTUFF To the SYSREPOSVIEWS table In the system specified.
*/
copyViewToSystem_:
ViewName = Param1
ViewKey = @APPID<1> : '*' : ViewName
OtherSystemPath = Param2
AliasName = 'SYSREPOSVIEWS_DEST'
Set_Status(0)
Alias_Table(OtherSystemPath, 'GLOBAL', 'SYSREPOSVIEWS', AliasName)
If Get_Status(err) Then
Msg('Could not alias SYSREPOSVIEWS in ' : OtherSystemPath : '|' : err)
Return
End
Set_Status(0)
Copy_row('SYSREPOSVIEWS', ViewKey, AliasName, ViewKey, 2, False$, False$)
If Get_Status(err) Then
Detach_Table(AliasName)
Msg('Could not copy RDK View ' : ViewName : ' to SYSREPOSVIEWS in ' : OtherSystemPath : '|' : err)
Return
End
Detach_Table(AliasName)
Return
/*
interface: exportViewForDisplay
Format the saved view In a human readable format.
--- BP
Disp = CS_RDK_UTIL('exportViewForDisplay', View)
---
Does Not include all view entities, just Procs, Forms, And Inserts.
Parameters:
View - Name of the RDK view as shown In the Open dialog
Returns:
Entries - CRLF list of view entries sorted by section.
*/
exportViewForDisplay_:
ViewName = Param1
ViewKey = @APPID<1> : '*' : ViewName
Open "SYSREPOSVIEWS" To Table Else
Msg("Could not open SYSREPOSVIEWS")
Return
End
Read ViewRec From Table,ViewKey Else
Msg("View was not found in this application")
Return
End
*Storage for the desired entities in the view
Events = ''
Forms = ''
Procs = ''
Inserts = ''
ViewEntities = ViewRec<11>
Swap @VM With @FM In ViewEntities
ViewEntitiesCount = DCOUNT(ViewEntities, @FM)
Type = '' ;* Type of entity being checked
Entity = '' ;* Entity ID (not record key) being checked
Event = '' ;* If repos entity is an event this will contain the name
*Loop through all the entities in the RDK view
For i = 1 To ViewEntitiesCount
Line = ViewEntities<i>
Entity = ''
If Line[1,4] EQ '2-2:' Then
*Event entity
Event = Line[5,Len(Line)]
End
If Line[1,4] EQ '3-3:' Then
*Repos entity
Entity = Line[5,Len(Line)]
End
*This line does not start with a number (depth in the tree) so it must be the
*start of a new trunk
If Not(Num(Line[1,1])) Then
*Repos entity type
Type = Line
Event = ''
Goto skip_entity_view_loop
End
*If we have a type and event but no entity the next line probably has it
If Type NE '' And Event NE '' And Entity EQ '' Then
*This line still needs to be perserved
Goto skip_entity_view_loop
End
If Type EQ '' Or Entity EQ '' Then
*We don't have enough information, next line should be enough to determine
*How to find this event in the repos
Goto skip_entity_view_loop
End
*
* What items are we interested in seeing?
*
Found = False$
Begin Case
*Not yet implemented
* Case Type = "OpenInsight Events"
* Events<-1> = Entity
Case Type = "OpenInsight Forms"
Forms<-1> = Entity
Case Type = "Stored Procedures"
Procs<-1> = Entity
Case Type = "Stored Procedure Inserts"
Inserts<-1> = Entity
End Case
Entity = '' ;*Reset for next loop
skip_entity_view_loop:
Next i
Bys = 'AD'
Justs = 'LR'
*Not yet implemented
/*
Swap @FM With @RM In Events
Events := @RM
V119('S', '', Bys, Justs, Events, '')
Swap @RM With @FM In Events
Events = Events[1,Len(Events) - 1]
*/
Swap @FM With @RM In Forms
Forms := @RM
V119('S', '', Bys, Justs, Forms, '')
Swap @RM With @FM In Forms
Forms = Forms[1,Len(Forms) - 1]
Swap @FM With @RM In Procs
Procs := @RM
V119('S', '', Bys, Justs, Procs, '')
Swap @RM With @FM In Procs
Procs = Procs[1,Len(Procs) - 1]
Swap @FM With @RM In Inserts
Inserts := @RM
V119('S', '', Bys, Justs, Inserts, '')
Swap @RM With @FM In Inserts
Inserts = Inserts[1,Len(Inserts) - 1]
O = '';
If Procs NE '' Then
O<-1> = 'Procedures:'
O<-1> = Procs
O<-1> = ''
End
If Forms NE '' Then
O<-1> = 'Forms:'
O<-1> = Forms
O<-1> = ''
End
If Events NE '' Then
O<-1> = 'Events:'
O<-1> = Events
O<-1> = ''
End
If Inserts NE '' Then
O<-1> = 'Inserts:'
O<-1> = Inserts
O<-1> = ''
End
Swap @FM With \0D0A\ In O
RetVal = O
Return
/*
Read a previously built RDK And generate a display of the contents.
Parameters:
Path - Directory containing RDK files
Format - Output format. TXT only supported.
OutputFile - Where the result should be written to
*/
viewDeployedRDK_:
Path = Param1
Format = Param2
OutputFile = Param3
Set_Status(0)
attach_table(Path, '', 'GLOBAL','')
If Get_Status(err) Then
Return
End
Open "SYSUPGRADE" To Table Else
Set_Status(-1,1,'Attached RDK volume but unable to open SYSUPGRADE')
detach_table(Path)
Return
End
Select Table
Done = 0
Disp = ''
Loop
ReadNext @ID Else done = 1
Until done
Disp<-1> = @ID
Repeat
Set_Status(0)
detach_table(Path)
If Get_Status(Err) Then
Return
End
Swap @FM With \0D0A\ In Disp
OSWrite Disp To OutputFile
Set_Status(0)
Return
/*
Given a saved selection list add it To the view
Parameters:
ListName - Name of the saved SYSLIST name
View - The view record being built
*/
addFromSyseposSavedList_:
ListName = Param1
View = outValue
Rec = Xlate('SYSLISTS', ListName, '', 'X')
*First rec row is meta data
Rows = Delete(Rec,1,0,0)
RowsCount = DCOUNT(Rows,@FM)
*Loop through all the keys in the saved list
For i = 1 To RowsCount
Row = Rows<i>
App = Field(Row,'*',1)
EntType = Field(Row,'*',2)
Other = Field(Row,'*',3)
EntId = Field(Row,'*',4)
*Figure out what type of entity it is and process it
Begin Case
Case EntType EQ 'STPROCINS'
CS_RDK_UTIL('addInsert', EntId,'','','',View)
Case EntType EQ 'STPROC'
CS_RDK_UTIL('addViewProc', EntId,'','','',View)
Case EntType EQ 'OIWIN'
CS_RDK_UTIL('addViewWindow', EntId,'','','',View)
Case EntType EQ 'STPROCEXE'
Case EntType EQ 'OIWINEXE'
Case EntType EQ 'STPROCDBG'
*Added at the same time the source is added
Case EntType EQ 'DBTABLE'
*Not supported at this time
Goto addFromSyseposSavedList_SkipRow
Case OTHERWISE$
Debug
End Case
addFromSyseposSavedList_SkipRow:
Next i
OutValue = View
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment