TestPDMRefQuery
This template is the Cargo equivalent of Template:PDMRefDPL, providing the query to populate the table of references on ICON Schema and GIM Library Table and View pages, and Template:PDMRefListDPL, providing the query to populate the Reference List page in GIM. It is called by Template:PDMSchemaPageFormat, Template:TestPDMTable and Template:TestPDMTablePageFormat,Template:TestPDMViewPageFormat, and Template:TestPDMPageQuery. There are separate queries for ICON and GIM. Note that, while RAA does capture TestPDMRef information, none of this information displays in the RAA PDMs.
The where criterion for the GIM ref list is super-complicated, so as to allow for links to tables/views whose names end in an underscore but whose URLs don't, as well as to exclude certain tables/views from the PSAAS page.
Content is:
{{#switch:{{#explode:{{{page}}}|:|1}}
|ICON={{#cargo_query:
tables=TestPDMRef,TestPDMTable
|join on=TestPDMRef._pageName=TestPDMTable._pageName
|fields=CONCAT('[[{{#replace:{{{page}}}|{{#explode:{{{page}}}|:|3}}|Table-',TestPDMTable.tableName,'}}|',TestPDMTable.tableName,']]')=Child Table,TestPDMRef.parentTable=Parent Table,TestPDMRef.refCode=CODE,TestPDMRef.foreignKey=F
|where=TestPDMRef._pageName LIKE "Documentation:ICON:Library:%%:{{#switch:{{lc:{{#sub:{{{page}}}|-5}}}}|draft|ource={{#explode:{{{page}}}|:|4}}|#default={{#switch:{{lc:{{#explode:{{{page}}}|:|4}}}}|public|current=PDMSource|#default={{#sub:{{#explode:{{{page}}}|:|4}}|0|3}}PDMSource}}}}" AND TestPDMTable.dbSchema LIKE "{{#explode:{{#explode:{{{page}}}|:|3}}|-|1}}"
|format=sortable table
}}
|PSAAS
|GIM=<!-- GIM needs to switch for Table/View pages vs. the Reference list -->
{{#switch:{{#explode:{{#explode:{{{page}}}|:|3}}|-|0}}
|Table
|View={{#cargo_query:
tables=TestPDMRef,TestPDMTable,TestPDMView
|join on=TestPDMRef._pageName=TestPDMTable._pageName,TestPDMRef._pageName=TestPDMView._pageName
|fields=IF( (TestPDMRef._pageName LIKE "%:Table-%"),TestPDMTable.tableName,TestPDMView.viewName)=Child Table/View,TestPDMRef.foreignKey=Child Table/View Column,IF( (TestPDMRef.parentTable IS NOT NULL),TestPDMRef.parentTable,TestPDMRef.parentView)=Parent Table/View,TestPDMRef.parentColumn=Parent Table/View Column
|where=TestPDMRef._pageName LIKE "{{{page}}}"
|format=sortable table
}}
|InfoMartReferences
|#default={{#cargo_query:
tables=TestPDMRef,TestPDMTable,TestPDMView
|join on=TestPDMRef._pageName=TestPDMTable._pageName,TestPDMRef._pageName=TestPDMView._pageName
|fields=IF( (TestPDMTable.tableName IS NOT NULL),CONCAT('[[Documentation:{{#explode:{{{page}}}|:|1}}:{{#explode:{{{page}}}|:|2}}:Table-',IF(SUBSTRING(TestPDMTable.tableName,-1)="_",SUBSTRING(TestPDMTable.tableName,1,(LENGTH(TestPDMTable.tableName)-1)),TestPDMTable.tableName),':{{#explode:{{{page}}}|:|4}}|',REPLACE(TestPDMTable.tableName,"_","_<wbr/>"),']]'),
CONCAT('[[Documentation:{{#explode:{{{page}}}|:|1}}:{{#explode:{{{page}}}|:|2}}:View-',IF(SUBSTRING(TestPDMView.viewName,-1)="_",SUBSTRING(TestPDMView.viewName,1,(LENGTH(TestPDMView.viewName)-1)),TestPDMView.viewName),':{{#explode:{{{page}}}|:|4}}|',REPLACE(TestPDMView.viewName,"_","_<wbr/>"),']]'))=ChildTable/ChildView,TestPDMRef.foreignKey=ChildTable/ChildView Column,IF( (TestPDMRef.parentTable IS NOT NULL),TestPDMRef.parentTable,TestPDMRef.parentView)=ParentTable/ParentView,IF( (TestPDMRef.parentColumn IS NOT NULL),TestPDMRef.parentColumn,'')=ParentTable/ParentView Column
|where={{#if:{{{source|}}}|TestPDMRef._pageName LIKE "{{{source}}}"|{{#switch:{{#explode:{{{page}}}|:|1}}|PSAAS=TestPDMRef._pageName LIKE "Documentation:GIM:Library:%%:{{#switch:{{#explode:{{{page}}}|:|4}}|draft=DRAFT|Public=PDMSource}}" AND (TestPDMRef._pageName NOT LIKE "%CTL_%" OR TestPDMRef._pageName NOT LIKE "%STG_%" OR TestPDMRef._pageName NOT LIKE "%View-CDR%")|#default=TestPDMRef._pageName LIKE "Documentation:{{#explode:{{{page}}}|:|1}}:Library:%%:{{#switch:{{lc:{{#sub:{{{page}}}|-5}}}}|draft|ource={{#explode:{{{page}}}|:|4}}|#default={{#switch:{{lc:{{#explode:{{{page}}}|:|4}}}}|public|current=PDMSource|#default={{#sub:{{#explode:{{{page}}}|:|4}}|0|3}}PDMSource}}}}" AND TestPDMRef._pageName NOT LIKE "%View-CDR%"}}}}
|format=dynamic table
|order by=ChildTable/ChildView
|rows per page=150
|limit=5000
}}
}}
|#default=
}}