1 var REST = library.REST.REST();
  2 var myData = [];
  3 
  4 /**
  5  * Gets the selection for the given User.  Default user is the current user
  6  */
  7 function getSelections() {
  8   var aSelections = savedSelectionManager.getSavedSelectionsForUser(
  9     context.getUser().username
 10   );
 11   for (var i = 0; i < aSelections.length; i++) {
 12     var aSelection = aSelections[i];
 13     myData[myData.length] = {
 14       id: aSelection.getId(),
 15       name: aSelection.getName(),
 16       description: aSelection.getDescription(),
 17       public: aSelection.isPublic(),
 18     };
 19   }
 20 }
 21 
 22 /**
 23  * Returns the saved selections of the current user
 24  * @description  Queries the database for selections created by the current user. The selections are parsed into a text object keyed by AssetID from the JSON file in which they are contained, and by default are displayed to the user.
 25  * @example 'MBurl'/wf/restapi/1/getSavedSelections
 26  * @example <a target="_blank" href=http://127.0.0.1:55555/wf/restapi/1/getSavedSelections>http://127.0.0.1:55555/wf/restapi/1/getSavedSelections</a>
 27  * @class Queries the database for selections created by the current user
 28  * @name GetSavedSelections
 29  * @returns ( [{'id': 'TheSelectionId', 'name':'TheSelectionName','Description':'TheSelecionDescription'},...] )
 30  */
 31 function main() {
 32   if (myData.error != null) {
 33     return REST.formatResponse();
 34   }
 35   getSelections();
 36   return REST.formatResponse();
 37 }
 38 main();
 39