TSService.compressRevision

Syntax

compressRevision (wbk, metaData, callback);

Parameters

wbk. Sets workbook value.

metaData. Sets metadata that include information on revisions and time series database.

callback. Sets handler for operation execution end.

Description

The compressRevision method compresses revisions.

Example

To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:

	var compressRevisionButt = new PP.Ui.Button({
	ParentNode: document.body, //DOM parent node
	Content: "Compress Revision", //text
	Click: PP.Delegate(onClickCallback)
	});
	function onClickCallback()
	{  	
		var rubKey = wbk.getActiveSheet().getRub().meta.obInst.obDesc.k;
		var wbkPB = workbookBox.getPropertyBarView();
		var panels = wbkPB._selfNavItems;
		var revisionsPanel = null;
		var i;
		//Get panel of time series database revisions
		for (i = 0; i < panels.length; i++)
		{
			if (panels[i]._GroupName == PP.TS.Ui.PropertyGroups.RubricatorRevisions && panels[i].getTag() == rubKey)
			{
				revisionsPanel = wbkPB._selfNavItems[i];
				break;
			}
		}  
	//Get the selected revision list element		
	var sitem = revisionsPanel._RevisionsListBox.getSelectedItem();
	if (!sitem)
		return;
	//Get key of the selected revision
	var revKey = sitem.getId();
	if (!revisionsPanel.getRubKey())
		throw PP.ArgumentException(revisionsPanel);
					
	//Create an object containing data about the revision to be compressed
	var	metadata =  {
		RubKey: revisionsPanel.getRubKey(),
		Operation: PP.TS.Ui.WbkRevisionOperation.Compress,
		RevKey: revKey,
		SaveLabels: False,
		OldestRevKey: revisionsPanel._OldestRevision.k.toString()
		}				
	//Compress revisions	
	tsService.compressRevision(wbk, metadata, PP.Delegate(onResponse));
					
		function onResponse(sender, args)
		{
			//Get a list of revisions in the obtained server response 
			var res = JSON.parse(args.ResponseText);	
			var revs = res.GetRubMdResult.meta.revisions.its.it;	
			//Set a new list of revisions to the revisions panel
			revisionsPanel.setRevisions(revs);
		}
	}

After executing the example a button named Compress Revision is placed on the HTML page. In the Data tab of the side panel open the panel with the name that corresponds to time series database name. Next select a revision in the revisions list and click the Compress Revision button. After this the revisions are compressed and all labels except the selected one are removed. If the revision panel is empty, add revisions by clicking the Create Label button.

See also:

TSService