Mercurial > hg > ltpda
comparison m-toolbox/classes/@repogui2/cb_submit.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % CB_SUBMIT callback executed when the user clicks on the 'Submit' button | |
2 % | |
3 % M Hewitson | |
4 % | |
5 % $Id: cb_submit.m,v 1.1 2008/09/22 14:28:56 hewitson Exp $ | |
6 % | |
7 function cb_submit(varargin) | |
8 | |
9 | |
10 myh = varargin{1}; | |
11 mainfig = varargin{end}; | |
12 | |
13 % get object list | |
14 objlist = findobj(mainfig.handle, 'Tag', 'RepoguiWorkspaceObjsList'); | |
15 objstr = get(objlist, 'String'); | |
16 vals = get(objlist, 'Value'); | |
17 | |
18 % Build sinfo structure | |
19 sinfo.conn = mainfig.connection; | |
20 sinfo.experiment_title = get(findobj(mainfig.handle, 'Tag', 'RepoguiExperimentTitleEdit'), 'String'); | |
21 sinfo.experiment_description = get(findobj(mainfig.handle, 'Tag', 'RepoguiExperimentDescriptionEdit'), 'String'); | |
22 sinfo.analysis_description = get(findobj(mainfig.handle, 'Tag', 'RepoguiAnalysisDescriptionEdit'), 'String'); | |
23 sinfo.quantity = get(findobj(mainfig.handle, 'Tag', 'RepoguiQuantityEdit'), 'String'); | |
24 sinfo.keywords = get(findobj(mainfig.handle, 'Tag', 'RepoguiKeywordsEdit'), 'String'); | |
25 sinfo.reference_ids = get(findobj(mainfig.handle, 'Tag', 'RepoguiReferenceIDsEdit'), 'String'); | |
26 sinfo.additional_comments = get(findobj(mainfig.handle, 'Tag', 'RepoguiAdditonalCommentsEdit'), 'String'); | |
27 sinfo.additional_authors = get(findobj(mainfig.handle, 'Tag', 'RepoguiAdditionalAuthorsEdit'), 'String'); | |
28 | |
29 if ~isa(sinfo.conn, 'database') | |
30 error('### Please connect to a database before trying to submit.'); | |
31 end | |
32 | |
33 | |
34 % Build structure array | |
35 k = 1; | |
36 objs = []; | |
37 for j=1:length(vals) | |
38 | |
39 objname = deblank(strtok(objstr{vals(j)})); | |
40 cmd = sprintf('obj = evalin(''base'', ''%s'');', objname); | |
41 eval(cmd); | |
42 | |
43 for l=1:numel(obj) | |
44 objs = [objs obj(l)]; | |
45 k = k + 1; | |
46 end | |
47 end | |
48 | |
49 % Submit objects | |
50 try | |
51 [ids, cid] = submit(objs, sinfo); | |
52 if isempty(ids) | |
53 warning('!!! Failed to submit object: %s', objname); | |
54 else | |
55 disp(sprintf('++ Submitted object(s) %s (ref id = %s, collection id = %d)', objname, mat2str(ids), cid)); | |
56 end | |
57 catch | |
58 warning('!!! Failed to submit object: %s', objname); | |
59 rethrow(lasterror) | |
60 end | |
61 | |
62 end |