Class

SpotfireDocument

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

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], [apiVersion])

Parameters:
Name Type Attributes Default 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

apiVersion String <optional>
'7.14'

the webplayer apiVersion (for Spotfire 7.14+)

Methods

static checkSaveLibraryPath()

Throws an 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

applyTemplateAsync(applyParameters)

Apply a template to the current document.
A template is a document with empty data tables. During the process, the data tables are temporarily exported into SBDF files of the same name and with the extension '.export.sbdf', in the same place as the template. We therefore advise you to make sure that no SBDF files with these names are present in the location of the template to apply, otherwise they will be deleted.
Other warning: once the template is applied, it becomes the current document, so the template can easily be overwritten by accident. A solution to avoid this may be to save the document as a new one, using the SpotfireDocument.save function (see the examples).

Parameters:
Name Type Description
applyParameters TemplateApplyOptions

Describes the parameters needed to apply the template.

Examples

Apply a template from the library:

spotfireDocument.applyTemplateAsync({
    path: '/Discngine/Client Automation',
    fileName: 'myNewTemplate',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

Apply a template from a local file:

spotfireDocument.applyTemplateAsync({
    path: 'C:/temp',
    fileName: 'myNewTemplate',
    location: 'Local'
})

dispose()

Disposes all resources 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.

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. If it is not precised, the active marking is used.

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);

getActiveMarkingAsync()

Gets the active marking name of the active visual.

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);
})

getMarkingsAsync()

Gets all marking names

getMetadataAsync() → {Object|Object}

List the metadata of the document.

Object

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

Object

getPropertyAsync(propertyName) → {String}

Gets the value of a property.

Parameters:
Name Type Description
propertyName String

The string representation of the property.

String

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, operation)

Sets a marking in the analysis specified by the input parameters.

Parameters:
Name Type Default Description
markingName String

The marking name in which to set the marking.

dataTableName String

The data table in which to set the marking.

whereClause String

An expression string with conditions for the data columns used to set the marking. For more information, see the documentation for the TIBCO Spotfire® Expression Language.

operation SpotfireDataSelectionOperations {Enum} SpotfireDataSelectionOperations.replace

The operation to use when combining this selection with previously set selections.

Enum options: replace, add, subtract, toggle, intersect
Example
spotfireDocument.markRowsAsync('MyMarking (0)','aTable','[Activity] <= 0', SpotfireDataSelectionOperations.add)

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)

Adds a new callback to be executed when a new document is opened.

Parameters:
Name Type Description
onDocumentChangedHandler DocumentOpenedEventHandler

the callback to be executed when a new document is opened

onDocumentClosed(onDocumentClosedHandler)

Adds a new callback to be executed when the document is closed.

Parameters:
Name Type Description
onDocumentClosedHandler DocumentClosedEventHandler

the callback to be executed when the document is closed

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

Opens an existing document from library.

Parameters:
Name Type Attributes Default Description
documentPath String

The full path to the document in the library, or to a local drive if you are using only the TIBCO Spotfire ® Analyst client</>.

onDocumentOpenedHandler DocumentOpenedEventHandler <optional>

The callback that will be executed after the document is opened.

configurationBlockText String <optional>

The configuration block text to be applied.

location SpotfireDocumentLocation {Enum} <optional>
SpotfireDocument.library

The location type of the document, from SpotfireDocumentLocation.

Enum options: library, local
Examples

Open a document from the library:

spotfireDocument.openDocument('/Discngine/Client Automation/empty')

Open a document from a local file:

spotfireDocument.openDocument('C:/temp/data.dxp', null, null, 'Local')

Open a document with a configuration block and a callback function:

spotfireDocument.openDocument('/MyTeam/data.dxp', function() {alert('document opened')}, 'myKey1="ATextToSave";myKey2=255;')

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.

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.

save(saveOptionsOrLibraryPath)

Saves the document.

Parameters:
Name Type Description
saveOptionsOrLibraryPath DocumentSaveOptions | String

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

Examples

Save the document as it 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 a configuration block:

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:'/myLibraryFolder/',
     fileName:'NewFileName'
})

Save the document as a new document in library with configurationBlockText:

spotfireDocument.save({
    path:'/myLibraryFolder/',
    fileName:'NewFileName',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

saveTemplateAsync(saveParameters)

Saves the document as a template.
A template is a document with empty data tables. During the process, the data tables are temporarily exported into SBDF files of the same name and with the extension '.export.sbdf', in the same place as the template. We therefore advise you to make sure that no SBDF files with these names are present in the location of the future template, otherwise they will be deleted.

Parameters:
Name Type Description
saveParameters DocumentSaveOptions

Describes the parameters needed to save the template.

Examples

Save a template in the library:

spotfireDocument.saveTemplateAsync({
    path: '/Discngine/Client Automation',
    fileName: 'myNewTemplate',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

Save a template in an existing local folder:

spotfireDocument.saveTemplateAsync({
    path: 'C:/temp',
    fileName: 'myNewTemplate',
    location: 'Local'
})

setSpinnerState(isActive, message, [timeout]) → {this}

Allows to add a spinner containing a custom message to indicate when Spotfire is working. This can be convenient to prevent multiple blinking caused by Python scripts being executed sequentially. Calling the method multiple times while changing message allows to update the message displayed to the user.

Parameters:
Name Type Attributes Default Description
isActive Boolean

Whether to show or hide the spinner.

message String

The message you want to display on the screen.

timeout Number <optional>
10000

The time in ms after which the spinner will be unset automatically. You can disable it by explicitely passing 0.

Returned with this to allow chaining.

this

subscribeToDocumentEvents()

Subscribes the mandatory handlers to document event (cloased and changed). Will be recall on document changed.