Jump to content
  • How to Create Default Information Model in Spotfire® Using IronPython Scripting


    This article provides a sample script on how to create a Default Information Model

    Introduction

    This article provides a sample script on how to create a Default Information Model

    Code Sample

    # Copyright © 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Framework.Library import *
    from System import Guid
    from Spotfire.Dxp.Data.InformationModel import *
    from System.Collections.Generic import List
    #Copy the id of DataSource 
    MyGuid = Guid('5e3be61c-3a84-4f65-9ce2-d96001044467')
    libraryManager = Application.GetService[LibraryManager]()
    informationServiceManager= Application.GetService[InformationModelManager]()
    success, dataSourceItem = libraryManager.TryGetItem(MyGuid, LibraryItemRetrievalOption.IncludePath)
    
    if success:
    	print "Found DataSource"
    	#folder to save
    	found, librarySaveFolder = libraryManager.TryGetItem("/ILMODEL", LibraryItemType.Folder)
    	if found:
    		print "Found folder to save"
    		paths=List[DataSourceItemPath]()
    		fromTable=DataSourceItemPath.CreateTable("spotfire_demodata","dbo","BASEBALL")
    		#catalog=DataSourceItemPath.CreateCatalog("spotfire_demodata")
    		paths.Add(fromTable)
    		metadata=LibraryItemMetadataSettings()
    		metadata.Description="Create an Information Model for table Baseball"
    		try:
    			informationServiceManager.CreateDefaultInformationModel(librarySaveFolder,dataSourceItem,paths,metadata,NameConflictStrategy.ThrowException)
    
    		except Exception,e:
    			print e.ToString()
    
    	else:
    		print "Did not find data source"
    
    else:
    	print "Did not find data source"
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...