from Spotfire.Dxp.Data.DataOperations import DataSourceOperation
from Spotfire.Dxp.Application import DocumentMetadata
from Spotfire.Dxp.Data.DataOperations import DataOperation
from Spotfire.Dxp.Application.Visuals import HtmlTextArea
from Spotfire.Dxp.Framework.Library import LibraryManager, LibraryItemType, LibraryItem, LibraryItemRetrievalOption
lm = Application.GetService(LibraryManager)
from System import Guid
def writeHtml(tableName,type,path):
global html
html=html+"<tr><td>"+tableName+"</td><td>"+type+"</td><td>"+path+"</td></tr>"
html="<table border=1><tr style='text-align:center'><th>Data Table</th><th>Type</th><th>Source</th></tr>"
for tbl in Document.Data.Tables:
sourceView = tbl.GenerateSourceView();
op=sourceView.GetAllOperations[DataOperation]()
if type(op[0]).__name__ == 'DataSourceOperation':
t=op[0].GetDataFlow().DataSource
if(type(t).__name__ == "InformationLinkDataSource"):
found=t.FindAll("id::"+str(t.Id))
writeHtml(tbl.Name,type(t).__name__,found.First.Path)
if(type(t).__name__ == "TextFileDataSource" or type(t).__name__ == "Excel2FileDataSource"):
if (t.FilePath == None):
path="Clipboard"
else:
path=t.FilePath
writeHtml(tbl.Name,type(t).__name__,path)
if(type(t).__name__ == "DatabaseDataSource"):
writeHtml(tbl.Name,type(t).__name__,t.Settings.Provider)
if(type(t).__name__ == "StdfFileDataSource" or type(t).__name__ == "SbdfFileDataSource"):
writeHtml(tbl.Name,type(t).__name__,t.FilePath)
if(type(t).__name__ == "SbdfLibraryDataSource"):
l = lm.Search(t.Name, LibraryItemRetrievalOption.IncludePath)
for item in l:
writeHtml(tbl.Name,type(t).__name__,item.Path)
elif(type(op[0]).__name__ == "DataConnectionOperation"):
writeHtml(tbl.Name,type(op[0]).__name__,op[0].DisplayName)
elif(type(op[0]).__name__ == "DataTableDataSourceOperation"):
writeHtml(tbl.Name,type(op[0]).__name__,op[0].DataTable.Name)
elif (type(op[0]).__name__ == "DataFunctionOperation"):
t=op[0].DataFunction
sourceType= t.DataFunctionDefinition.ServiceType.DisplayName
writeHtml(tbl.Name,sourceType,op[0].DisplayName)
html=html+"</table>"
myTextArea.As[HtmlTextArea]().HtmlContent=html
myTextArea - script parameter referring to a Textarea visualization which will be populated with the source information for all the data tables in
the current dxp.