view m-toolbox/classes/@workspaceBrowser/cb_submit.m @ 16:91f21a0aab35 database-connection-manager

Update utils.jquery * * * Update utils.jmysql.getsinfo
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% CB_SUBMIT submits the selected objects to a repository
%
% CALL: workspaceBrowser.cb_submit
%
% M Hewitson 13-11-08
%
% $Id: cb_submit.m,v 1.5 2010/01/22 16:00:47 ingo Exp $
%
function cb_submit(varargin)
  
  wb = getappdata(0, 'WorkspaceBrowser');
  
  % Get all selected objects
  vars = workspaceBrowser.getSelectedVarNames(wb);
  objs = workspaceBrowser.getSelectedObjects(wb);
  if numel(vars) ~= numel(objs)
    error('### Number of objects not equal to number of variable names. This shouldn''t happen!');
  end
  
  svars = {};
  for kk=1:numel(objs)
    obj = objs{kk};
    if isa(obj, 'ltpda_uoh')
      svars = [svars vars(kk)];
    end
  end
  
  if numel(svars) == 0
    utils.helper.errorDlg('Please select one or more objects to submit.', 'Submission error');
    return
  end
  
  sinfo = [];
  
  % Build command
  cmd = '[ids, cids] = submit(';
  
  for kk=1:numel(svars)
    cmd = [cmd svars{kk} ','];
  end
  
  % Remove the last comma
  if cmd(end) == ',', cmd = cmd(1:end-1); end
  cmd = [cmd ');'];
  
  assignin('base', 'sinfo', sinfo);
  try
    evalin('base', cmd);
  catch
    utils.helper.errorDlg(['Failed to executed submission command: ' cmd], 'Submission error');
  end
  
end