Child pages
  • Session workspace
Skip to end of metadata
Go to start of metadata

The session workspace is a feature of openBIS for passing temporary data between a client and an openBIS data store server. These temporary files are automatically deleted when the session expires. It is useful in combination with server-side services such as aggregation services, ingestion services, and the graph service. The session workspace can be used to provide or retrieve files processed or returned by these services.

 

Use Case 1 : Downloading a file generated on the server

Aggregation Services provide a way of extending the openBIS API to support installation-specific features. They can be easily invoked from clients, including webapps, and can access openBIS metadata as well as data from the file system. One potential scenario is a parameterized aggregation service that gathers information for, e.g., an experiment, and produces the result in an Excel file for a biologist to further process.

The API for aggregation services offers a straightforward way for providing parameter values, but it returns a table as a result and cannot return files. To get around this limitation, the aggregation service can generate a file and put it in the session workspace. The result of the aggregation service would contain the path to the file in the session workspace. The client could then retrieve the file from the session workspace using the information returned by the aggregation service.

Use Case 2 : Generating graphs of arbitrary data

The graph service offers a way of generating scatterplots, histograms and heatmaps as PNG images. It takes parameters that specify the type of graph to generate and which file it should use for the data. To use the graph service with data that is not in a data set, it is necessary to upload the data to the session workspace.

Use Case 3 : Registering a data set without a dropbox

Ingestion services are an alternative to dropboxes for registering data. Whereas dropboxes are triggered by activity on the file system, ingestion services are explicitly triggered when invoked by a client. They can accept a dictionary (map) of parameters to the service. The dictionary is adequate for communicating small amounts of data, but not appropriate for transmitting many MB. For this situation, the ingestion service could be implemented to accept data from the session workspace. The file to register is uploaded to the session workspace and the path to the file is provided to the ingestion service as a parameter.

Access from OpenBIS webapps

Session workspace files can be easily managed by the OpenBIS webapps. Users can upload, download and delete files right from their web applications using the new created javascript methods (all in openbis.js file):

  • createSessionWorkspaceUploader(uploaderContainer) - creates a session workspace file uploader inside the specified uploaderContainer element
  • createSessionWorkspaceDownloadUrl(filePath, callback) - creates a session workspace download url for a file with the specified filePath

  • createSessionWorkspaceDownloadLink(filePath, linkText, callback) - create a session workspace download link for a file with the specified filePath
  • downloadSessionWorkspaceFile(filePath, callback) - downloads a session workspace file with the specified filePath

  • deleteSessionWorkspaceFile(filePath, callback) - deletes a session workspace file with the specified filePath

Note: user has to be authenticated to call these methods.

Example - creating an uploader

<html>
<head>
	<script src="http://myopenbis.com:8888/openbis/resources/js/jquery.js"></script>
	<script src="http://myopenbis.com:8888/openbis/resources/js/openbis.js"></script>
	<script>
	  var o = new openbis("http://myopenbis.com:8888/openbis/openbis");
	</script>
</head>
<body>

<div id="uploader"></div>

<script>

$(document).ready(function(){
  // we assume that we are already logged in
  o.createSessionWorkspaceUploader("#uploader");
});

</script>

</body>
</html>

Example - downloading a file

<html>
<head>
	<script src="http://myopenbis.com:8888/openbis/resources/js/jquery.js"></script>
	<script src="http://myopenbis.com:8888/openbis/resources/js/openbis.js"></script>
	<script>
	  var o = new openbis("http://myopenbis.com:8888/openbis/openbis");
	</script>
</head>
<body>

<script>

$(document).ready(function(){
   // we assume that we are already logged in and "test.txt" file exists in the session workspace
   o.downloadSessionWorkspaceFile("test.txt", function(response){
     alert(response);
   });
});

</script>

</body>
</html>

Example - deleting a file

<html>
<head>
	<script src="http://myopenbis.com:8888/openbis/resources/js/jquery.js"></script>
	<script src="http://myopenbis.com:8888/openbis/resources/js/openbis.js"></script>
	<script>
	  var o = new openbis("http://myopenbis.com:8888/openbis/openbis");
	</script>
</head>
<body>

<script>

$(document).ready(function(){
   // we assume that we are already logged in and "test.txt" file exists in the session workspace
   o.deleteSessionWorkspaceFile("test.txt");
});

</script>

</body>
</html>

Example Code

The attached session-workspace-example.zip includes examples that implement the use cases 1 and 2 described above.

Set up

Download the zip file and unpack it. Inside are two folders session-workspace and session-workspace-example-data. The session-workspace folder contains the core plugins for the example. Put this folder in the core-plugins folder of your openBIS server and enable the session-workspace core plugin. This will add two webapps to the Utilities menu, the Aggregation Service Example and the Graph Service Example.

Aggregation Service Example

The aggregation service example webapp calls an aggregation service that produces a file and then displays a link to download the file.

Graph Service Example

The graph service example webapp provides a session-workspace uploader that can be used to provide files for the graph service. Once a file is uploaded to the session workspace, the webapp displays graphs that reference this file.

Example files to try are contained in the example-data folder.

  • No labels