0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % SUBMIT Submits the given objects to an LTPDA repository
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % DESCRIPTION: Submits the given objects to an LTPDA repository. If multiple
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % objects are submitted together a corresponding collection entry will be made.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % If not explicitly disabled the user will be prompt for entering submission
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % metadata and for chosing the database where to submit the objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 % CALL: [IDS, CIDS] = submit(O1, PL)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % [IDS, CIDS] = submit(O1, O2, PL)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % INPUTS: O1, O2, ... - objects to be submitted
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % PL - plist whih submission and repository informations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % OUTPUTS: IDS - IDs assigned to the submitted objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 % CID - ID of the collection entry
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % <a href="matlab:utils.helper.displayMethodInfo('ltpda_uo', 'submit')">Parameters Description</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % METADATA:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % 'experiment title' - title for the submission (required >4 characters)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % 'experiment description' - description of this submission (required >10 characters)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % 'analysis description' - description of the analysis performed (required >10 characters)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % 'quantity' - the physical quantity represented by the data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % 'keywords' - comma-delimited list of keywords
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 % 'reference ids' - comma-delimited list object IDs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % 'additional comments' - additional comments
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % 'additional authors' - additional author names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 % VERSION: $Id: submit.m,v 1.91 2011/11/18 08:08:26 mauro Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % Notes on submission
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % We can check ask the database for a list of allowed modules. This needs a
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 % new table in the database. Then this list is passed to validate so that
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 % if the 'validate' plist option (which needs to be added) is set to true,
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % then we call validate on the object before submitting. If validate is
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % true, then we set the validated flag in the database after submission if
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % it passes.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 function varargout = submit(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % check if this is a call for parameters
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 if utils.helper.isinfocall(varargin{:})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 varargout{1} = getInfo(varargin{3});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % collect all AOs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 [pls, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 [sinfo, invars, objs] = utils.helper.collect_objects(rest(:), 'struct');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 % identify plists which are only used for the submission process
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 mask = false(numel(pls), 1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 for ii = 1:numel(pls)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 if ~utils.helper.isSubmissionPlist(pls(ii))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 mask(ii) = true;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % add all plist that do not look to contain parameters for the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % submission to the list of objects submitted to the repository
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 if sum(mask)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 objs = [objs, {pls(mask)}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % keep all the other as parameters plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 if sum(~mask)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 pls = combine(pls(~mask));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 % rearrange nested objects lists into a single cell array
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 objs = flatten(objs);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 if isempty(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85 error('### input at least one object to submit to the repository');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88 % combine user plist with default
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 pls = fixPlist(pls);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 dpl = getDefaultPlist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91 pls = combine(pls, dpl.pset('HOSTNAME', ''));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 % for backwards compatibility convert any user supplied sinfo-structure into a plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 pls = ltpda_uo.convertSinfo2Plist(pls, sinfo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 % read XML submission informations file
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97 filename = pls.find('sinfo filename');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 if ~isempty(filename)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 pl = fixPlist(utils.xml.read_sinfo_xml(filename));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101 pls = combine(pl, pls);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 catch err
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 error('### unable to read specified file: %s', filename);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 % collect additional informations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 sinfo = ltpda_uo.submitDialog(pls);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109 if isempty(sinfo)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 [varargout{1}, varargout{2}] = userCanceled();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 % check completeness of user supplied informations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 sinfo = checkSinfo(sinfo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117 % user supplied connection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 conn = find(pls, 'conn');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 % obtain a connection from the connection manager
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121 rm = LTPDARepositoryManager();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 if isempty(conn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 connections = rm.findConnections(pls);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 if isempty(connections)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 % no connection found. create a new one
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 conn = rm.newConnection(pls);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 if isempty(conn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 [varargout{1}, varargout{2}] = userCanceled();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 elseif numel(connections) == 1 && ~utils.prog.yes2true(pls.find('use selector'))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 % found only one connection and we are not forcing the use of the selector
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 conn = connections(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 % make the user select the desired database connection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 conn = rm.manager.selectConnection([]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 if isempty(conn)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 [varargout{1}, varargout{2}] = userCanceled();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140 return
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145 % avoid to ask for a password if one was specified in the plist
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 if isjava(conn) && ~conn.isConnected()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 passwd = pls.find('password');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 if ~isempty(passwd)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 conn.setPassword(passwd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 % connect to the database
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 if isempty(conn.openConnection())
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 error('### unable to connect to the database')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 utils.helper.msg(msg.PROC1, 'submitting %d objects to repository', numel(objs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 % lock connection to avoid expire during processing
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162 conn.setLocked(true);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 % reload connection table if we have a GUI
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 if ~isempty(rm.gui)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 rm.gui.reloadConnectionTable();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 % look-up user id
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 userid = utils.jmysql.getUserID(conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171 username = conn.getUsername();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 utils.helper.msg(msg.PROC1, 'got user id %d for user: %s', userid, char(username));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 if userid < 1 || isnan(userid) || strcmp(userid, 'No Data') || ischar(userid)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175 error('### Unknown username.');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 % author of the data: let's take the username
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 author = username;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181 % date for the transaction.transdata and objmeta.submitted columns as UTC time string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 t = time();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183 tdate = format(t, 'yyyy-mm-dd HH:MM:SS', 'UTC');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 % machine details
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 prov = provenance();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 utils.helper.msg(msg.IMPORTANT, 'submitting to %s@%s:%s', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 char(conn.getUsername), char(conn.getHostname), char(conn.getDatabase));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 % obtain the underlying connection
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 c = conn.getConn();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 % start a transaction. either we submitt all objects or we roll back all changes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195 c.setAutoCommit(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 % process each object and collect id numbers
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198 ids = zeros(numel(objs), 1); cid = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 for kk = 1:numel(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 % this object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 obj = objs{kk};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 utils.helper.msg(msg.PROC1, 'submitting object: %s / %s', class(obj), obj.name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206 % format object creation time as UTC time string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 if isa(obj, 'plist')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 % plist-objects stores creatins time as milli secs since the epoch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 created = time().format('yyyy-mm-dd HH:MM:SS', 'UTC');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 created = obj.created.format('yyyy-mm-dd HH:MM:SS', 'UTC');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 % Set the UUID if it is empty. This should only happen for PLIST
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 % objects.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216 if isempty(obj.UUID)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 obj.UUID = char(java.util.UUID.randomUUID);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220 % create an XML representaion of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 if utils.prog.yes2true(pls.find('binary'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 utils.helper.msg(msg.PROC2, 'binary submit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 otxt = ['binary submit ' datestr(now)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 utils.helper.msg(msg.PROC2, 'xml submit');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 otxt = utils.prog.obj2xml(obj);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 % create an MD5 hash of the xml representation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 md5hash = utils.prog.hash(otxt, 'MD5');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 % create a binary representaion of the object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 bobj = utils.prog.obj2binary(obj);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234 if isempty(bobj)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 error('### failed to obtain a binary representation');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 % submit object to objs table
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 stmt = c.prepareStatement(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 'INSERT INTO objs (xml, hash, uuid) VALUES (?, ?, ?)');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241 stmt.setObject(1, otxt);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 stmt.setObject(2, char(md5hash));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 stmt.setObject(3, obj.UUID);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 stmt.executeUpdate();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 % obtain object id
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 rs = stmt.getGeneratedKeys();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248 if rs.next()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 objid = rs.getInt(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 objid = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 rs.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 stmt.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 % insert binary representation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 stmt = c.prepareStatement(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 'INSERT INTO bobjs (obj_id, mat) VALUES (?,?)');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259 stmt.setObject(1, objid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 stmt.setObject(2, bobj);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 stmt.execute();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 stmt.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 % reference IDs are stored in a CSV string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 if ischar(sinfo.reference_ids)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 refids = sinfo.reference_ids;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 refids = utils.prog.csv(sinfo.reference_ids);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 % insert object meta data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 stmt = c.prepareStatement(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 [ 'INSERT INTO objmeta (obj_id, obj_type, name, created, version, ' ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 'ip, hostname, os, submitted, experiment_title, experiment_desc, ' ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 'reference_ids, additional_comments, additional_authors, keywords, ' ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 'quantity, analysis_desc, author) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)' ]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 stmt.setObject( 1, objid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 stmt.setObject( 2, java.lang.String(class(obj)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 stmt.setObject( 3, java.lang.String(obj.name));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 stmt.setObject( 4, java.lang.String(created));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 stmt.setObject( 5, java.lang.String(getappdata(0, 'ltpda_version')));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 stmt.setObject( 6, java.lang.String(prov.ip));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 stmt.setObject( 7, java.lang.String(prov.hostname));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 stmt.setObject( 8, java.lang.String(prov.os));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 stmt.setObject( 9, java.lang.String(tdate));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 stmt.setObject(10, java.lang.String(sinfo.experiment_title));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287 stmt.setObject(11, java.lang.String(sinfo.experiment_description));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 stmt.setObject(12, java.lang.String(refids));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 stmt.setObject(13, java.lang.String(sinfo.additional_comments));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 stmt.setObject(14, java.lang.String(sinfo.additional_authors));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 stmt.setObject(15, java.lang.String(sinfo.keywords));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 stmt.setObject(16, java.lang.String(sinfo.quantity));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 stmt.setObject(17, java.lang.String(sinfo.analysis_description));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 stmt.setObject(18, java.lang.String(author));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 stmt.execute();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 stmt.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 % update other meta-data tables
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 cols = utils.jmysql.execute(c, 'SHOW COLUMNS FROM tsdata');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 if utils.helper.ismember('obj_id', cols(:,1))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 % the tsdata table contains an obj id column. use the new database schema
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 utils.jmysql.insertObjMetadata(c, obj, objid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304 % otherwise use the old one
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 utils.helper.msg(msg.PROC2, 'using back-compatibility code');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 utils.jmysql.insertObjMetadataV1(c, obj, objid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 % update transactions table
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 stmt = c.prepareStatement(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 'INSERT INTO transactions (obj_id, user_id, transdate, direction) VALUES (?, ?, ?, ?)');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312 stmt.setObject(1, objid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 stmt.setObject(2, userid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 stmt.setObject(3, java.lang.String(tdate));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 stmt.setObject(4, java.lang.String('in'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 stmt.execute();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 stmt.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 % collect the id of the submitted object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 ids(kk) = objid;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 % make collection entry
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 if numel(objs) > 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 % insert record into collections table
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327 stmt = c.prepareStatement(...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 'INSERT INTO collections (nobjs, obj_ids) VALUES (?, ?)');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 stmt.setObject(1, length(ids));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 stmt.setObject(2, java.lang.String(utils.prog.csv(ids)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 stmt.executeUpdate();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 % obtain collection id
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 rs = stmt.getGeneratedKeys();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 if rs.next()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 cid = rs.getInt(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 cid = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 rs.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 stmt.close();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 catch ex
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 utils.helper.msg(msg.IMPORTANT, 'submission error. no object submitted')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 c.close()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 conn.setLocked(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 rethrow(ex)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 % commit the transaction
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 c.commit();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 % report IDs of the inserted objects
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 for kk = 1:numel(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 utils.helper.msg(msg.IMPORTANT, 'submitted %s object with ID: %d, UUID: %s, name: %s', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 class(objs{kk}), ids(kk), objs{kk}.UUID, objs{kk}.name);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360 if ~isempty(cid)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 utils.helper.msg(msg.IMPORTANT, 'made collection entry with ID: %d', cid);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 % unlock connection expire
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365 conn.setLocked(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 % reset timer
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 LTPDARepositoryManager.resetTimer(rm.timerClearPass, conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 LTPDARepositoryManager.resetTimer(rm.timerDisconnect, conn);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 % pass back outputs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
372 if nargout > 0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
373 varargout{1} = ids;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
374 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
375 if nargout > 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
376 varargout{2} = cid;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
377 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
378 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
379
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
380
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
381 function varargout = userCanceled()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
382 % signal that the user cancelled the submission
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
383 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
384 utils.helper.msg(msg.PROC1, 'user cancelled');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
385 varargout{1} = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
386 varargout{2} = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
387 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
388
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
389
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
390 function sinfo = checkSinfo(sinfo)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
391 % check sinfo structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
392
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
393 import utils.const.*
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
394
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
395 % fieldnames
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
396 mainfields = {'experiment_title', 'experiment_description', 'analysis_description'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
397 extrafields = {'quantity', 'keywords', 'reference_ids', 'additional_comments', 'author', 'additional_authors'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
398
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
399 % fieldnames of the input structure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
400 fnames = fieldnames(sinfo);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
401
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
402 % check mandatory fields
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
403 for jj = 1:length(mainfields)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
404 if ~ismember(fnames, mainfields{jj})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
405 error('### the sinfo structure should contain a ''%s'' field', mainfields{jj});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
406 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
407 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
408
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
409 % check extra fields
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
410 for jj = 1:length(extrafields)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
411 if ~ismember(fnames, extrafields{jj})
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
412 utils.helper.msg(msg.PROC2, 'setting default for field %s', extrafields{jj});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
413 sinfo.(extrafields{jj}) = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
414 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
415 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
416
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
417 % additional checks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
418 if length(sinfo.experiment_title) < 5
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
419 error('### ''experiment title'' should be at least 5 characters long');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
420 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
421 if length(sinfo.experiment_description) < 10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
422 error('### ''experiment description'' should be at least 10 characters long');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
423 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
424 if length(sinfo.analysis_description) < 10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
425 error('### ''analysis description'' should be at least 10 characters long');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
426 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
427
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
428 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
429
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
430
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
431 function ii = getInfo(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
432 if nargin == 1 && strcmpi(varargin{1}, 'None')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
433 sets = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
434 pl = [];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
435 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
436 sets = {'Default'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
437 pl = getDefaultPlist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
438 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
439 % Build info object
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
440 ii = minfo(mfilename, 'ltpda_uo', 'ltpda', utils.const.categories.internal, '$Id: submit.m,v 1.91 2011/11/18 08:08:26 mauro Exp $', sets, pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
441 ii.setModifier(false);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
442 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
443
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
444
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
445 function plout = getDefaultPlist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
446 persistent pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
447 if ~exist('pl', 'var') || isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
448 pl = buildplist();
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
449 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
450 plout = pl;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
451 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
452
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
453 function plo = buildplist()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
454
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
455 plo = plist.TO_REPOSITORY_PLIST;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
456
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
457 p = param({'sinfo filename', 'Path to an XML file containing submission metadata'}, paramValue.EMPTY_STRING);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
458 plo.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
459
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
460 p = param({'binary', 'Submit only binary version of the objects'}, paramValue.FALSE_TRUE);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
461 plo.append(p);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
462 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
463
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
464
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
465 function pl = fixPlist(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
466 % accept parameters where words are separated either by spaces or underscore
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
467 if ~isempty(pl)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
468 for ii = 1:pl.nparams
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
469 pl.params(ii).setKey(strrep(pl.params(ii).key, '_', ' '));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
470 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
471 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
472 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
473
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
474
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
475 function flat = flatten(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
476 % flatten nested lists into a single cell array
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
477
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
478 flat = {};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
479
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
480 while iscell(objs) && numel(objs) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
481 objs = objs{1};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
482 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
483
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
484 if numel(objs) == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
485 flat = {objs};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
486 return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
487 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
488
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
489 for jj = 1:numel(objs)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
490 obj = flatten(objs(jj));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
491 for kk = 1:numel(obj)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
492 flat = [ flat obj(kk) ];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
493 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
494 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
495
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
496 end
|