Sharing, Collaborating, and Annotating your Spotfire Analysis – Part III


In the last two weeks we have built various components which enable us to use Spotfire as a social annotation and collaboration tool.

In this week’s post we will show you the same functionality, but implemented in another way.

Storing State
Rather than passing the state information (Marking, Filtering, Active Page, and Comments) around as query parameters in a URL, we are going to store the state information in a database.This has a couple added benefits. First, you are not limited to the size restrictions of a URL. Second, you are not making the state information visible from the URL and the data can be secured better in a database. Third, you are capturing these states and annotations in case you want to use them later, like in an audit trail or similar.
The image below shows the column information for a database table in Microsoft SQL Server.




In this example, we use two database columns to store the marking information. The first (markingColumn) will store the marking column to be used from the analysis and the second (markingValues) will store marking values.

Similarly, the filtering information will also be stored using two database columns: filteringColumn and filteringValues.

In addition we store the Active Page of the analysis and comments the user entered.  Finally a GUID is generated in our code and passed in as a primary key.

An example SQL statement is shown below:

INSERT INTO dbo.States (GUID, markingColumn, markingValues, filteringColumn, filteringValues, activePage, comments)
VALUES ('4d36e97d-e325-111e-bf21-08002be65123', 'Symbol', 'SINVX,SASSX', 'Category', 'Large Growth, Large  Value, Small Growth', 'Short-Term vs. Long-Term', 'Take a look at these stocks')

After inserting this record into the database, the GUID is returned and then appended to our custom URL which can be shared out.




Retrieving State
To retrieve the state, users will enter the URL from above in the Web Browser, and the code will retrieve the GUID from the query parameter just like we did in the earlier posts.

The GUID will then be used in a SELECT statement on the Database to retrieve the state information.

SELECT * from dbo.States where GUID = '4D36E97D-E325-11CE-BFC1-08002BE76212'
Once we loop through the resulting column values from the database, we will use the Web Player APIs from last week’s post to set the state on the Analysis File as well as display the comments.

Keeping Track of Annotations
Using the same code, it is also very easy to update your web page to show a list of all the annotations for the given analysis file, rather than just one specific one. In this use case, it can serve as an audit log, or process flow showing how the analysis results have been collaborated on.




If you are interested in creating similar functionality, please consider taking our Web Player API course, or hiring Spotfire Professional Services to help you.