Class

SpotfireDocument

SpotfireDocument(serverUrlOrDocumentParametersObject, documentPath, [onDocumentOpened], [configurationBlockText], [sfConnector], [defaultSerializer])

Object allowing to access the TIBCO Spotfire® document and to edit it via its editor property.

Constructor

new SpotfireDocument(serverUrlOrDocumentParametersObject, documentPath, [onDocumentOpened], [configurationBlockText], [sfConnector], [defaultSerializer])

Parameters:
Name Type Attributes Description
serverUrlOrDocumentParametersObject String | DocumentParametersObject

the Spotfire Server url Or the DocumentParametersObject

documentPath String

the complete path to the library document

onDocumentOpened DocumentOpenedEventHandler <optional>

the callback that will be executed after the document is opened

configurationBlockText String <optional>

the configuration block text that will be applied after the document is opened

sfConnector SpotfireConnectorBase <optional>

the spotfire connector that will be used by this instance (used for unit test)

defaultSerializer SpotfireDocumentEditorDefaultSerializer <optional>

the serializer that will be used to serialize the state to python script when applying state

Methods

static checkSaveLibraryPath()

throw exception if the library path passed as args is not a correctly formed path

If the path is not a correctly formed spotfire library path

Error

dispose()

dispose all ressources that must be disposed (called on the doMandatoryDocumentClosedActions event)

doMandatoryDocumentChangedActions()

method always called when a document is changed (opened or closed)

doMandatoryDocumentClosedActions()

method always called when a document is closed

executePythonScript(scriptText, scriptArgs)

Execute a python script on the document synchronously

Parameters:
Name Type Description
scriptText string

the script to be executed

scriptArgs object

the list of named parameters that may be used in the script. In python script the args will be used as jsonParam[]

executePythonScriptAsync(scriptText, scriptArgs)

Execute a python script on the document asynchronously

Parameters:
Name Type Description
scriptText string

the script to be executed

scriptArgs object

the list of named parameters that may be used in the script. In python script the args will be used as jsonParam[]

exportTableAsync(exporterType, tableName, exporterArgs)

Parameters:
Name Type Description
exporterType String

The type of the exporter to be used. Only the 'PipelinePilot' exporter is implemented in this version.

tableName tableName

The TIBCO Spotfire® data table containing data to be exported.

exporterArgs Object

Exporter parameters to be used to export the data.

columns Array.<String>

Lists the columns to be exported.

filterRows Object

Settings used to limit the exported data.

type SpotfireFilterRowType

Type of the filtering. Available in the SpotfireFilterRowType enum object.

name String

Name of the marking to be used to export data.

serverRoot String

The root URL of the Pipeline Pilot server.

sessionId String

The Pipeline Pilot session ID to be used.

destinationPath String

The path on the Pipeline Pilot server in which the file will be written.

destinationFile String

The SBDF file that will contain the exported data. If it leaves empty, the name of the data table will be used to name the file.

Examples
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234'
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234',
 filterRows: {
     type: SpotfireFilterRowType.marking
 },
 columns: ['Activity', 'ALogP']
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234',
 destinationFile: 'markedData.sbdf'
 filterRows: {
     type: SpotfireFilterRowType.marking,
     name: 'Marking'
 }
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234',
 destinationFile: 'markedData.sbdf'
 filterRows: {
     type: SpotfireFilterRowType.filtering
 }
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);

getMarkedRowsAsync(markingName, dataTableName)

Get the list of marked rows with content

Parameters:
Name Type Description
markingName String

the marking name that we want to get the marked rows

dataTableName String

the dataTable name that is marked

Example
spotfireDocument.getMarkedRowsAsync('MyMarking','aTable').then(function(markedRows) {
    alert(markedRows);
})

getMarkedRowsAsync(markingName, dataTableName)

Get the list of marked rows with content

Parameters:
Name Type Description
markingName String

the marking name that we want to get the marked rows

dataTableName String

the dataTable name that is marked

getMarkingsAsync()

Get all marking names

getMetadataAsync() → {Object|Object}

List the metadata of the document.

Object

An object containing metadata of the document ('path', 'created', etc.)

Object

isDocumentOpen() → {boolean}

true if a document is opened, false if not

boolean

markingExistsAsync(markingName)

Does the marking provided exist?

Parameters:
Name Type Description
markingName String

The name of the marking to check.

markRowsAsync(markingName, dataTableName, whereClause)

Mark rows using Spotfire where clause expression for specified marking and datatable

Parameters:
Name Type Description
markingName String

the name of the marking in which you want to mark the rows

dataTableName String

the name of the dataTable from where you want to mark rows

whereClause String

the spotfire where clause to used

Example
spotfireDocument.markRowsAsync('MyMarking (0)','aTable','[Activity] <= 0')

markRowsAsync(markingName, dataTableName, whereClause)

Mark rows using Spotfire where clause expression for specified marking and datatable

Parameters:
Name Type Description
markingName String

the name of the marking in which you want to mark the rows

dataTableName String

the name of the dataTable from where you want to mark rows

whereClause String

the spotfire where clause to used

markRowsByIdsAsync(markingName, dataTableName, idColumnName, ids)

Mark rows identified by column and specified values for specified marking and datatable

Parameters:
Name Type Description
markingName String

the name of the marking in which you want to mark the rows

dataTableName String

the name of the dataTable from where you want to mark rows

idColumnName String

the name of the column that represents the id on which you want to select the rows

ids Array.<String>

array of ids that identified the rows to mark

Example
spotfireDocument.markRowsByIdsAsync('MyMarking (1)', 'aTable', 'InChIKey', [
    'APZFVJKUDMXDFA-UHFFFAOYSA-N',
    'LQUMXBMVHBUSOC-UHFFFAOYSA-N',
    'KJTUBZKMFRILQD-UHFFFAOYSA-N',
    'WYCLKVQLVUQKNZ-UHFFFAOYSA-N'
])

onDocumentChanged(onDocumentChangedHandler)

add new callback to be executed when other document is opened

Parameters:
Name Type Description
onDocumentChangedHandler DocumentOpenedEventHandler

the callback to be executed when a new document is opened

onDocumentClosed(onDocumentClosedHandler)

add new callback to be executed when document is closed

Parameters:
Name Type Description
onDocumentClosedHandler DocumentClosedEventHandler

the callback to be executed when the document is closed

openDocument(documentPath, [onDocumentOpenedHandler], [configurationBlockText])

Open an existing document from library

Parameters:
Name Type Attributes Description
documentPath String

the full documentPath to the library document

onDocumentOpenedHandler DocumentOpenedEventHandler <optional>

the callback that will be executed after the document is opened

configurationBlockText String <optional>

the configuration block text to be applied

sanitizeSaveOption([saveOptions])

Sanitize the option passed as args to the save method

Parameters:
Name Type Attributes Description
saveOptions DocumentSaveOptions <optional>

describe the save option. If not provided the document will be saved as is.

path String

the existing path where to save

fileName String

the name of the saved file

configurationBlockText String <optional>

the configuration block text to be saved in the Spotfire document

location SpotfireDocumentLocation {Enum} <optional>

the location where to save the document from SpotfireDocumentLocation

Enum options: library, local
libraryItemMetaData LibraryItemMetaData <optional>

the list of metadata to be saved on the document spofire if it is a Spotfire Document stored in library

description String <optional>

the description

otherData Object <optional>

the list of all custom metadata you want to pull as metadat for the library document

sanitizeSaveOption([saveOptions])

Sanitize the option passed as args to the save method

Parameters:
Name Type Attributes Description
saveOptions DocumentSaveOptions <optional>

describe the save option. If not provided the document will be saved as is.

path String

the existing path where to save

fileName String

the name of the saved file

configurationBlockText String <optional>

the configuration block text to be saved in the Spotfire document

location SpotfireDocumentLocation {Enum} <optional>

the location where to save the document from SpotfireDocumentLocation

Enum options: library, local
libraryItemMetaData LibraryItemMetaData <optional>

the list of metadata to be saved on the document spofire if it is a Spotfire Document stored in library

description String <optional>

the description

otherData Object <optional>

the list of all custom metadata you want to pull as metadat for the library document

save(saveOptionsOrLibraryPath)

Save the document

Parameters:
Name Type Description
saveOptionsOrLibraryPath DocumentSaveOptions

list all options for saving the document. If array is string, assuming that the save operation is done in the library

path String

the existing path where to save

fileName String

the name of the saved file

configurationBlockText String

the configuration block text to be saved in the Spotfire document

location SpotfireDocumentLocation {Enum}

the location where to save the document from SpotfireDocumentLocation

Enum options: library, local
libraryItemMetaData LibraryItemMetaData

the list of metadata to be saved on the document spofire if it is a Spotfire Document stored in library

description String

the description

otherData Object

the list of all custom metadata you want to pull as metadat for the library document

Examples
Save the document as is
spotfireDocument.save()
Save the document as a new document in local folder (FOR ANALYST ONLY)
spotfireDocument.save({
    path:'c:\\TMP\\',
    fileName:'NewFileName.dxp',
    location: SpotfireDocumentLocation.local
})
Save the document as a new document in local folder (FOR ANALYST ONLY) with configurationBlockText
spotfireDocument.save({
    path:'c:\\TMP\\',
    fileName:'NewFileName.dxp',
    location: SpotfireDocumentLocation.local,
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})
Save the document as a new document in library
 spotfireDocument.save({
     path:'/Gabriel/',
     fileName:'NewFileName'
})
Save the document as a new document in library with configurationBlockText
spotfireDocument.save({
    path:'/Gabriel/',
    fileName:'NewFileName',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

subscribeToDocumentEvents()

subscribe mandatory handler to document event (cloased and changed). Will be recall on document changed