changeset 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 79dc7091dbbc
children 29276498ebdb
files m-toolbox/classes/@LTPDAprefs/cb_guiClosed.m m-toolbox/m/etc/ltpda_startup.m m-toolbox/m/helper/mc.m
diffstat 3 files changed, 32 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/m-toolbox/classes/@LTPDAprefs/cb_guiClosed.m	Mon Dec 05 16:20:06 2011 +0100
+++ b/m-toolbox/classes/@LTPDAprefs/cb_guiClosed.m	Mon Dec 05 16:20:06 2011 +0100
@@ -10,11 +10,9 @@
 %
 
 function cb_guiClosed(varargin)
-  disp('*** Goodbye from LTPDAprefs');
   ltpdaPrefs = varargin{1};
   
   if ~isempty(ltpdaPrefs) && isvalid(ltpdaPrefs)
-%     fprintf(2, 'deleting handles\n');
     %--- called when window is closed
     h = handle(ltpdaPrefs.gui, 'callbackproperties');
     set(h, 'WindowClosedCallback', []);
--- a/m-toolbox/m/etc/ltpda_startup.m	Mon Dec 05 16:20:06 2011 +0100
+++ b/m-toolbox/m/etc/ltpda_startup.m	Mon Dec 05 16:20:06 2011 +0100
@@ -11,14 +11,14 @@
   
   % For the case that the user calls 'ltpda_startup' in his current MATLAB
   % session again it is necessary to destroy ALL java objects.
-  setappdata(0, 'LTPDApreferences', []);
+  try
+    rmappdata(0, 'LTPDApreferences');
+  end
   
-  % Remove the repository manager
-  rm = getappdata(0, 'LTPDARepositoryManager');
-  if ~isempty(rm)
-    delete(rm);
+  % Remove the database connection manager
+  try
+    rmappdata(0, 'LTPDADatabaseConnectionManager');
   end
-  setappdata(0, 'LTPDARepositoryManager', []);
   
   clear java
   clear classes
@@ -313,9 +313,6 @@
   % methods coming from the extensions
   mc;
     
-  % ---- Start Repository Manager
-  LTPDARepositoryManager;
-  
 end
 
 function installExtensionJarFiles
--- a/m-toolbox/m/helper/mc.m	Mon Dec 05 16:20:06 2011 +0100
+++ b/m-toolbox/m/helper/mc.m	Mon Dec 05 16:20:06 2011 +0100
@@ -13,40 +13,36 @@
 
 function mc()
   
-  setappdata(0, 'LTPDApreferences', []);
+  % remove preferences
+  try
+    rmappdata(0, 'LTPDApreferences');
+  end
   
-  % Remove the repository manager
-  rm = getappdata(0, 'LTPDARepositoryManager');
-  if ~isempty(rm)
-    % store the connections so they don't get lost
-    rm.manager.closeAllConnections;
-    conns = rm.manager.getConnections;
-    delete(rm);
-    setappdata(0, 'LTPDAConnections', conns);
+  % database connection manager
+  cm = getappdata(0, 'LTPDADatabaseConnenctionManager');
+  if ~isempty(cm)
+    % save cached credentials
+    setappdata(0, 'LTPDAcredentials', cm.credentials);
+    % remove database connection manager
+    rmappdata(0, 'LTPDADatabaseConnenctionManager');
   end
-  setappdata(0, 'LTPDARepositoryManager', []);
-  
-  evalin('caller', 'clear');         % Deletes the timer-objects
-  clear classes                      % Deletes the local variables
-  evalin('caller', 'clear classes'); % Deletes the variables in the caller function
-  evalin('base', 'clear classes');   % Deletes the variables in the 'base' workspace
   
-  % Load the preferences again
-  LTPDAprefs.loadPrefs;
+  evalin('caller', 'clear');         % delete the timer-objects
+  clear classes                      % delete the local variables
+  evalin('caller', 'clear classes'); % delete the variables in the caller function
+  evalin('base', 'clear classes');   % delete the variables in the 'base' workspace
+  
+  % load the preferences again
+  LTPDAprefs.loadPrefs();
   
-  % Make a new Repository Manager
-  conns = getappdata(0, 'LTPDAConnections');
-  rm = LTPDARepositoryManager;
-  if ~isempty(conns)
-    % and put back the existing connections
-    for kk = 1:conns.size
-      conn = conns.get(kk-1);
-      rm.newConnection(char(conn.getHostname), ...
-        char(conn.getDatabase), ...
-        char(conn.getUsername), ...
-        char(conn.getPassword));
-    end
+  % instantiate database connection manager if required
+  credentials = getappdata(0, 'LTPDAcredentials');
+  if ~isempty(credentials)
+    cm = LTPDAConnectionManager();
+    cm.credentials = credentials;
   end
-  setappdata(0, 'LTPDAConnections', []);
+  try
+    rmappdata(0, 'LTPDAcredentials');
+  end
   
 end