comparison m-toolbox/m/helper/mc.m @ 26:ce4df2e95a55 database-connection-manager

Remove LTPDARepositoryManager initialization
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
comparison
equal deleted inserted replaced
25:79dc7091dbbc 26:ce4df2e95a55
11 11
12 % TODO: We need to close all GUIs before doing this - Prefs GUI and Repo Gui 12 % TODO: We need to close all GUIs before doing this - Prefs GUI and Repo Gui
13 13
14 function mc() 14 function mc()
15 15
16 setappdata(0, 'LTPDApreferences', []); 16 % remove preferences
17 try
18 rmappdata(0, 'LTPDApreferences');
19 end
17 20
18 % Remove the repository manager 21 % database connection manager
19 rm = getappdata(0, 'LTPDARepositoryManager'); 22 cm = getappdata(0, 'LTPDADatabaseConnenctionManager');
20 if ~isempty(rm) 23 if ~isempty(cm)
21 % store the connections so they don't get lost 24 % save cached credentials
22 rm.manager.closeAllConnections; 25 setappdata(0, 'LTPDAcredentials', cm.credentials);
23 conns = rm.manager.getConnections; 26 % remove database connection manager
24 delete(rm); 27 rmappdata(0, 'LTPDADatabaseConnenctionManager');
25 setappdata(0, 'LTPDAConnections', conns);
26 end 28 end
27 setappdata(0, 'LTPDARepositoryManager', []);
28 29
29 evalin('caller', 'clear'); % Deletes the timer-objects 30 evalin('caller', 'clear'); % delete the timer-objects
30 clear classes % Deletes the local variables 31 clear classes % delete the local variables
31 evalin('caller', 'clear classes'); % Deletes the variables in the caller function 32 evalin('caller', 'clear classes'); % delete the variables in the caller function
32 evalin('base', 'clear classes'); % Deletes the variables in the 'base' workspace 33 evalin('base', 'clear classes'); % delete the variables in the 'base' workspace
33 34
34 % Load the preferences again 35 % load the preferences again
35 LTPDAprefs.loadPrefs; 36 LTPDAprefs.loadPrefs();
36 37
37 % Make a new Repository Manager 38 % instantiate database connection manager if required
38 conns = getappdata(0, 'LTPDAConnections'); 39 credentials = getappdata(0, 'LTPDAcredentials');
39 rm = LTPDARepositoryManager; 40 if ~isempty(credentials)
40 if ~isempty(conns) 41 cm = LTPDAConnectionManager();
41 % and put back the existing connections 42 cm.credentials = credentials;
42 for kk = 1:conns.size
43 conn = conns.get(kk-1);
44 rm.newConnection(char(conn.getHostname), ...
45 char(conn.getDatabase), ...
46 char(conn.getUsername), ...
47 char(conn.getPassword));
48 end
49 end 43 end
50 setappdata(0, 'LTPDAConnections', []); 44 try
45 rmappdata(0, 'LTPDAcredentials');
46 end
51 47
52 end 48 end