Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@jmysql/submitDialog.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 % SUBMITDIALOG a submission dialog for submitting objects an LTPDA repository. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SUBMITDIALOG a submission dialog for submitting objects an | |
5 % LTPDA repository. | |
6 % | |
7 % CALL: sinfo = utils.jmysql.submitDialog(); | |
8 % sinfo = utils.jmysql.submitDialog(conn); | |
9 % sinfo = utils.jmysql.submitDialog(conn,sinfo); | |
10 % | |
11 % INPUTS: | |
12 % conn - a connection object like that returned from | |
13 % utils.jmysql.connect. | |
14 % sinfo - an sinfo structure to pre-populate the entry fields | |
15 % | |
16 % OUTPUTS: | |
17 % sinfo - an sinfo structure suitable to pass to submit | |
18 % | |
19 % NOTE: the sinfo object contains a valid and connected database connection | |
20 % object. It is up to the caller to close this connection when it is no | |
21 % longer required. | |
22 % | |
23 % NOTE: if an input connection is provided, this is not closed by this | |
24 % process. | |
25 % | |
26 % VERSION: $Id: submitDialog.m,v 1.4 2009/10/02 09:19:50 hewitson Exp $ | |
27 % | |
28 % HISTORY: 24-05-2007 M Hewitson | |
29 % Creation | |
30 % | |
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
32 | |
33 | |
34 | |
35 function sinfo = submitDialog(varargin) | |
36 | |
37 if nargin > 0 && ~isa(varargin{1}, 'mpipeline.repository.RepositoryConnection') | |
38 error('### The first argument should be empty or a RepositoryConnection'); | |
39 end | |
40 | |
41 isinfo = []; | |
42 | |
43 if nargin == 2 && isstruct(varargin{2}) | |
44 isinfo = varargin{2}; | |
45 end | |
46 | |
47 % Inputs | |
48 conn = []; | |
49 if nargin > 0 | |
50 conn = varargin{1}; | |
51 end | |
52 | |
53 % Check the connection | |
54 if ~isempty(conn) | |
55 closeConnection = false; | |
56 if ~conn.isConnected | |
57 conn.openConnection | |
58 end | |
59 if ~conn.isConnected | |
60 error('### Failed to connect to repository.'); | |
61 end | |
62 else | |
63 closeConnection = true; | |
64 end | |
65 | |
66 % Get host list | |
67 prefs = getappdata(0, 'LTPDApreferences'); | |
68 hosts = java.util.ArrayList(); | |
69 servers = prefs.repository.servers; | |
70 for kk=1:numel(servers) | |
71 hosts.add(servers{kk}); | |
72 end | |
73 | |
74 jisinfo = []; | |
75 if ~isempty(isinfo) | |
76 | |
77 jisinfo = mpipeline.repository.SubmissionInfo([]); | |
78 jisinfo.setExperimentTitle(isinfo.experiment_title); | |
79 jisinfo.setExperimentDescription(isinfo.experiment_description); | |
80 jisinfo.setAnalysisDescription(isinfo.analysis_description); | |
81 jisinfo.setQuantity(isinfo.quantity); | |
82 jisinfo.setKeywords(isinfo.keywords); | |
83 jisinfo.setReferenceIDs(isinfo.reference_ids); | |
84 jisinfo.setAdditionalComments(isinfo.additional_comments); | |
85 jisinfo.setAdditionalAuthors(isinfo.additional_authors); | |
86 | |
87 end | |
88 | |
89 % Open submit dialog | |
90 warning('off', 'MATLAB:JavaEDTAutoDelegation'); | |
91 srd = mpipeline.repository.SubmitInfoDialog([], jisinfo, hosts, conn); | |
92 srd.setVisible(true) | |
93 warning('on', 'MATLAB:JavaEDTAutoDelegation'); | |
94 | |
95 sinfo = []; | |
96 if ~srd.isCancelled | |
97 | |
98 jsinfo = srd.getSubmissionInfo; | |
99 sinfo.experiment_title = char(jsinfo.getExperimentTitle); | |
100 sinfo.experiment_description = char(jsinfo.getExperimentDescription); | |
101 sinfo.analysis_description = char(jsinfo.getAnalysisDescription); | |
102 sinfo.quantity = char(jsinfo.getQuantity); | |
103 sinfo.keywords = char(jsinfo.getKeywords); | |
104 sinfo.reference_ids = char(jsinfo.getReferenceIDs); | |
105 sinfo.additional_comments = char(jsinfo.getAdditionalComments); | |
106 sinfo.additional_authors = char(jsinfo.getAdditionalAuthors); | |
107 | |
108 jconn = srd.getRepoConnection; | |
109 sinfo.conn = jconn; %utils.jmysql.jconnTodbconn(jconn); | |
110 if closeConnection | |
111 jconn.closeConnection; | |
112 end | |
113 end | |
114 | |
115 end | |
116 |