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