changeset 45:a59cdb8aaf31 database-connection-manager

Merge
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 19:07:22 +0100
parents f90d4f666cc7 (diff) 409a22968d5e (current diff)
children ca0b8d4dcdb6
files m-toolbox/classes/@ao/ao.m m-toolbox/classes/@ltpda_uo/retrieve.m m-toolbox/classes/@ssm/ssm.m
diffstat 162 files changed, 5955 insertions(+), 8610 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@credentials/credentials.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,183 @@
+classdef credentials
+
+  properties
+
+    hostname = [];
+    database = [];
+    username = [];
+    password = [];
+    expiry = 0;
+
+  end % properties
+
+  methods
+
+    function obj = credentials(hostname, database, username, password)
+    % CREDENTIALS Constructor for credentials objects.
+    %
+    % Those are simple container objects to hold credentials required for
+    % establishing a connection to a database server, in addition to an
+    % expiry time.
+    %
+    % CREDENTIALS(hostname, database, username, password) The constructor can
+    % be called with any number of arguments. The default value for the object
+    % properties is the empty vector.
+
+      switch nargin
+        case 1
+          obj.hostname = hostname;
+        case 2
+          obj.hostname = hostname;
+          obj.database = database;
+        case 3
+          obj.hostname = hostname;
+          obj.database = database;
+          obj.username = username;
+        case 4
+          obj.hostname = hostname;
+          obj.database = database;
+          obj.username = username;
+          obj.password = password;
+      end
+    end
+
+    function str = char(obj, mode)
+    % CHAR Convert a credentials object to string representation.
+    %
+    % It takes an optional second argument that defines the representation to
+    % use. The default is to replace the password, if present, with the YES
+    % string, other possible modes are SHORT where password is omitted, or FULL
+    % where the password is shown at it is.
+
+      if nargin < 2
+        mode = '';
+      end
+      switch mode
+        case 'short'
+          % do not show password
+          frm = 'mysql://%s/%s username=%s';
+          str = sprintf(frm, obj.hostname, obj.database, obj.username);
+        case 'full'
+          % show password
+          frm = 'mysql://%s/%s username=%s password=%s';
+          str = sprintf(frm, obj.hostname, obj.database, obj.username, obj.password);
+        otherwise
+          % by default only show if a password is known
+          passwd = [];
+          if ischar(obj.password)
+            passwd = 'YES';
+          end
+          frm = 'mysql://%s/%s username=%s password=%s';
+          str = sprintf(frm, obj.hostname, obj.database, obj.username, passwd);
+      end
+    end
+
+    function disp(objs)
+    % DISP Overloaded display method for credentials objects.
+    %
+    % Uses the default string representation of the char() method where the
+    % password, if present, is replaced with the string YES.
+
+      for obj = objs
+        disp(['    ' char(obj) char(10)]);
+      end
+    end
+
+    function len = length(obj)
+    % LENGTH Returns the number of not null fields in the object.
+
+      len = 0;
+      if ~isempty(obj.hostname)
+        len = len + 1;
+      end
+      if ~isempty(obj.database)
+        len = len + 1;
+      end
+      if ~isempty(obj.username)
+        len = len + 1;
+      end
+      if ~isempty(obj.password)
+        len = len + 1;
+      end
+    end
+
+    function rv = complete(obj)
+    % COMPLETE Checks if the credentials are complete.
+    %
+    % Credentials object are complete when they contains all the required
+    % information to connect to a database. Namely the HOSTNAME, DATABASE
+    % and USERNAME properties should not be empty, the PASSWORD property is
+    % allowed to be an empty string '' but not [].
+
+      info = {'hostname', 'database', 'username'};
+      for kk = 1:numel(info)
+        if isempty(obj.(info{kk}))
+          rv = false;
+          return;
+        end
+      end
+      if ~ischar(obj.password)
+        rv = false;
+        return;
+      end
+      rv = true;
+    end
+
+    function rv = expired(obj)
+    % EXPIRED Checks if the credentials are expired.
+    %
+    % Credential objects expire when their expiry time is smaller than the
+    % current time in seconds since the epoch, as obtained by the time()
+    % function. Credentials with zero or negative expiry time never expire.
+
+      rv = false;
+      if obj.expiry > 0 && double(time()) > obj.expiry
+        rv = true;
+      end
+    end
+
+    function rv = match(obj, hostname, database, username)
+    % MATCH Check if the credentials object matches the given information.
+    %
+    % MATCH(obj, hostname) Returns true when HOSTANAME parameter match
+    % the object properties.
+    %
+    % MATCH(obj, hostname, database) Returns true when HOSTANAME and
+    % DATABASE parameters match the object properties.
+    %
+    % MATCH(obj, hostname, database, username) Returns true when
+    % HOSTANAME, DATABASE, and USERNAME parameters match the object
+    % properties.
+
+      % default arguments
+      switch nargin
+        case 4
+        case 3
+          username = [];
+        case 2
+          username = [];
+          database = [];
+        otherwise
+          error('### wrong number of parameters');
+      end
+
+      % default return value
+      rv = true;
+
+      if ~strcmp(obj.hostname, hostname)
+        rv = false;
+        return;
+      end
+      if ischar(database) && ~strcmp(obj.database, database)
+        rv = false;
+        return;
+      end
+      if ischar(username) && ~strcmp(obj.username, username)
+        rv = false;
+        return;
+      end
+    end
+
+  end % methods
+
+end
\ No newline at end of file
--- a/m-toolbox/classes/+utils/@jmysql/connect.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/connect.m	Tue Dec 06 19:07:22 2011 +0100
@@ -11,55 +11,15 @@
 % in the LTPDA user preferences.
 %
 % CALL:        conn = connect(hostname)
-%              conn = connect(hostname, dbname)
-%              conn = connect(hostname, dbname, dbuser, dbpass)
+%              conn = connect(hostname, database)
+%              conn = connect(hostname, database, username, password)
 %
 % VERSION:     $Id: connect.m,v 1.13 2011/04/01 08:36:49 hewitson Exp $
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-function varargout = connect(varargin)
-  
-  dbuser = '';
-  dbpass = '';
-  dbhost = '';
-  dbname = '';
+function conn = connect(varargin)
+
+  conn = LTPDADatabaseConnectionManager().connect(varargin{:});
   
-  if nargin == 1
-    dbhost = varargin{1};
-  elseif nargin == 2
-    dbhost = varargin{1};
-    dbname = varargin{2};
-  elseif nargin == 3
-    dbhost = varargin{1};
-    dbname = varargin{2};
-  elseif nargin == 4
-    dbhost = varargin{1};
-    dbname = varargin{2};
-    dbuser = varargin{3};
-    dbpass = varargin{4};
-  elseif nargin == 5
-    dbhost = varargin{1};
-    dbname = varargin{2};
-    dbuser = varargin{3};
-    dbpass = varargin{4};
-  end
-  
-  rm = LTPDARepositoryManager();
-  conn = rm.findConnections(dbhost, dbname, dbuser, dbpass);
-  
-  if isempty(conn)
-    conn = rm.newConnection(dbhost, dbname, dbuser, dbpass);
-  end
-  
-  if ~isempty(dbpass) && isempty(char(conn.getPassword))
-    conn.setPassword(dbpass)
-  end
-  
-  % If we have more than one matching connection, let the user choose.
-  if numel(conn) > 1
-    conn = rm.manager.selectConnection([]);
-  end
-  
-  varargout{1} = conn(1);
 end
--- a/m-toolbox/classes/+utils/@jmysql/dbconnTojconn.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-% DBCONNTOJCONN convert a MATLAB database connection to a java db connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: DBCONNTOJCONN convert a MATLAB database toolbox connection
-%              to a java db connection.
-%
-% CALL:        jconn = utils.jmysql.dbconnTojconn(dbconn);
-%
-% INPUTS:
-%              dbconn - a database toolbox connecton
-% 
-% OUTPUTS:     
-%              jconn - a connection object like that returned from
-%                     utils.jmysql.connect.
-%
-%
-% VERSION:     $Id: dbconnTojconn.m,v 1.1 2009/07/28 06:46:09 hewitson Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-
-function jconn = dbconnTojconn(conn)
-  
-  if nargin ~= 1 || ~isa(conn, 'database')
-    error('### The first argument should be a database connection');
-  end
-
-  r = regexp(conn.URL, '//(.+)/', 'tokens');
-  host = r{1};
-  
-  db   = conn.Instance;
-  user = conn.UserName;
-  
-  jconn = utils.jmysql.connect(host, db, user, '');
-  
-  
-  
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/dbquery.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/dbquery.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,27 +1,25 @@
-% DBQUERY query an AO repository database.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: DBQUERY query an AO repository database.
+function varargout = dbquery(conn, varargin)
+% DBQUERY  Query an AO repository database
 %
 % CALL:        info = dbquery(conn);
 %              info = dbquery(conn, query);
 %              info = dbquery(conn, table, query);
 %
 % INPUTS:
-%           conn   - a database connection object such as that returned by
-%                    utils.jmysql.connect().
-%           query  - a valid MySQL query string
-%           table  - a table name
+%
+%    conn  - a database connection object implementing java.sql.Connection
+%   query  - a valid MySQL query string
+%   table  - a table name
 %
 % OUTPUTS:
-%           info - the returned 'info' structure contains the fields from
-%                  each matching record.
+%
+%     info - structure containing fields from each matching record
 %
 % EXAMPLES:
 %
-%   >> info  = utils.jmysql.dbquery(conn, 'select * from objmeta where id>1000 and id<2000');
-%   >> info  = utils.jmysql.dbquery(conn, 'ao',           'id>1000 and id<2000');
-%   >> info  = utils.jmysql.dbquery(conn, 'objmeta',      'name like "x12"');
+%   >> info  = utils.jmysql.dbquery(conn, 'SELECT * FROM objmeta WHERE id>1000 AND id<2000');
+%   >> info  = utils.jmysql.dbquery(conn, 'ao',           'id>1000 AND id<2000');
+%   >> info  = utils.jmysql.dbquery(conn, 'objmeta',      'name LIKE "x12"');
 %   >> info  = utils.jmysql.dbquery(conn, 'users',        'username="aouser"');
 %   >> info  = utils.jmysql.dbquery(conn, 'collections',  'id=3');
 %   >> info  = utils.jmysql.dbquery(conn, 'collections',  'obj_ids="1,2"');
@@ -30,111 +28,65 @@
 %
 %   >> tables  = utils.jmysql.dbquery(conn)
 %
-%   The 'tables' cell-array will contain a list of the tables in the database.
+%   The 'tables' cell-array will contain a list of the tables in the database
 %
 %   >> info  = utils.jmysql.dbquery(conn, query)
 %
-%   The 'info' cell-array will contain the results from the SQL query.
+%   The 'info' cell-array will contain the results from the SQL query
 %
 % VERSION:     $Id: dbquery.m,v 1.2 2010/01/19 20:55:30 ingo Exp $
 %
-% HISTORY:     10-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-function varargout = dbquery(varargin)
-
-  conn = varargin{1};
-  if ~isa(conn, 'mpipeline.repository.RepositoryConnection')
-    error('### First input must be a database connection object.');
+  if ~isa(conn, 'java.sql.Connection')
+    error('### first argument should be a java.sql.Connection object');
   end
 
-  if nargin == 1
-    % get table list
-    info = getTableList(conn);
-
-  elseif nargin == 2
-    % execute query
-    info = simpleQuery(conn, varargin{2});
+  switch nargin
+    case 1
+      % get table list
+      try
+        info = utils.mysql.execute(conn, 'SHOW TABLES');
+      catch ex
+        error('### failed to get table list. %s', ex.message);
+      end
 
-  elseif nargin == 3
-    % query a table
-    table    = varargin{2};
-    query    = varargin{3};
-    info = runQuery(conn, table, query);
-  else
-    error('### Incorrect inputs.');
+    case 2
+      % execute query
+      try
+        info = utils.mysql.execute(conn, varargin{1});
+      catch ex
+        error('### failed to execute query. %s', ex.message);
+      end
+
+    case 3
+      % query a table
+      table = varargin{1};
+      query = varargin{2};
+      info = runQuery(conn, table, query);
+
+    otherwise
+      error('### incorrect inputs');
   end
 
   varargout{1} = info;
 end
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get table list
-function info = getTableList(conn)
 
+function info = getFieldList(conn, table)
   info = {};
-  
-  % open a connection
   try
-    q = 'show tables';
-    results = conn.query(q);
-    while results.next
-      info = [info {char(results.getString(1))}];
+    rows = utils.mysql.execute(conn, sprintf('DESCRIBE `%s`', table));
+    for kk = 1:size(rows, 1)
+      info = [info rows(kk,1)];
     end
-  catch
-    error('### Failed to get table list.');
+  catch ex
+    error('### failed to get field list. %s', ex.message);
   end
 end
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get field list
-function info = getFieldList(conn, table)
 
-  info = {};
-  try
-    q = ['describe ' table];
-    results = conn.query(q);
-    while results.next
-      info = [info {char(results.getObject(1))}];
-    end
-  catch
-    error('### Failed to get field list.');
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get field list
-function info = simpleQuery(conn, q)
-
-  % open a connection
+function info = runQuery(conn, table, query)
   info = {};
-  try
-    results = conn.query(q);
-    mt = results.getMetaData;
-    Ncols = mt.getColumnCount;
-    row = 1;
-    while results.next
-      for kk=1:Ncols
-        info{row,kk} = convertValue(results.getObject(kk));
-      end
-      row = row + 1;
-    end
-    
-  catch ME
-    disp(ME.message)
-    error('### Failed to execute query.');
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Run a query
-function info = runQuery(conn, table, query)
-
-  % Run query
-  info = {};
-
   fields = getFieldList(conn, table);
   f = '';
   fs = {};
@@ -143,22 +95,10 @@
     f  = [f fields{j} ',' ];
     fs = [fs fields(j)];
   end
-  q = sprintf('select %s  from %s where %s', f(1:end-1), table, query);
-  disp(['** QUERY: ' q]);
+  q = sprintf('SELECT %s FROM %s WHERE %s', f(1:end-1), table, query);
   try
-    info = simpleQuery(conn, q);
-  catch
-    error('### Failed to query table.');
+    info = utils.mysql.execute(conn, q);
+  catch ex
+    error('### failed to query table. %s', ex.message);
   end
 end
-
-function val = convertValue(val)
-  
-  switch class(val)
-    case 'java.sql.Timestamp'
-      val = char(val);
-    otherwise
-  end
-end
-
-
--- a/m-toolbox/classes/+utils/@jmysql/execute.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-function rows = execute(conn, query, varargin)
-  % execute the given SQL query with optional parameters varargin
-  % through connection conn. the results are returned in a 2d cell
-  % array
-  %
-  % differs from similar riutines in utils.jmysql by the use of proper
-  % SQL escaping of the query arguments. the connection object should
-  % be an object implementing the java.sql.Connection interface.
-
-  if nargin < 2
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### invalid connection');
-  end
-
-  % return value
-  rows = {};
-
-  % build query
-  stmt = conn.prepareStatement(query);
-  for kk = 1:numel(varargin)
-    stmt.setObject(kk, varargin{kk});
-  end
-
-  % execute query
-  rs = stmt.executeQuery();
-
-  % get results into a cell array
-  ncols = rs.getMetaData.getColumnCount();
-  row = 1;
-  while rs.next()
-    for kk = 1:ncols
-      rows{row,kk} = java2matlab(rs.getObject(kk));
-    end
-    row = row + 1;
-  end
-
-end
-
-function val = java2matlab(val)
-  % matlab converts all base types. just add a conversion for datetime columns
-  switch class(val)
-    case 'java.sql.Timestamp'
-      val = time(plist('time', char(val), 'timezone', 'UTC'));
-  end
-end
--- a/m-toolbox/classes/+utils/@jmysql/getRepositoryVersion.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-% getRepositoryVersion tries to get the version of the repository by
-% inspecting various fields in the database.
-% 
-% ver = utils.jmysql.getRepositoryVersion(conn)
-% 
-% Rules:
-%       objs table contains field 'uuid' => ver = 2.1
-% 
-% else: ver = 2.0;
-% 
-% M Hewitson 11-08-09
-% 
-% $Id: getRepositoryVersion.m,v 1.2 2009/08/11 12:33:19 ingo Exp $
-% 
-
-function ver = getRepositoryVersion(conn)
-  
-  ver = '2.0';
-  
-  q    = ['describe ' char(conn.getDatabase) '.objs'];
-  results = conn.query(q);
-  fields = {};
-  while results.next
-    fields = [fields {char(results.getString(1))}];
-  end
-
-  if utils.helper.ismember('uuid', fields)
-    ver = '2.1';
-  end
-  
-  
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/getUserID.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-% GETUSERID gets the user ID number corresponding to the given user name.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETUSERID gets the user ID number corresponding to the
-%              user name that connected to the MySQL database.
-%
-% CALL:        userid = getUserID(conn)
-%
-% VERSION:     $Id: getUserID.m,v 1.1 2008/08/08 11:51:12 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function [userid,dbuser] = getUserID(varargin)
-
-  userid = [];
-  conn = varargin{1};
-  if nargin > 1
-    username = varargin{2};
-  else
-    username = char(conn.getUsername);
-  end
-  try
-    if ~conn.isConnected
-      conn.openConnection;
-    end
-    if conn.isConnected
-      q    = sprintf('select id from users where username="%s"', username);
-      results = conn.query(q);
-      while results.next
-        userid = str2num(char(results.getString(1)));
-      end
-    end
-    dbuser = conn.getUsername;
-        
-  catch
-    warning('!!! Unable to retrieve user ID.');
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/getXdoc.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-% GETXDOC retrieves an object with given id from the LTPDA
-% repository specified by the input database connection. The object is
-% converted from its XML text format to an Xdoc. This can then be converted
-% into an object using the appropriate object constructor.
-%
-% Usage: xdoc = getXdoc(conn, id)
-%
-% Inputs:
-%         conn - a database connection object
-%         id   - the object id
-%
-% Outputs:
-%         xdoc - an Xdoc representation of the object.
-%
-% M Hewitson 30-08-07
-%
-% $Id: getXdoc.m,v 1.2 2009/06/17 11:05:53 ingo Exp $
-%
-%
-
-function xdoc = getXdoc(conn, id)
-
-  xdoc = '';
-  
-  try
-    results = conn.query(sprintf('select xml from objs where id="%d"', id));
-    while results.next
-      objTxt = char(results.getString(1));
-    end
-  catch curs
-    error('### Unable to read xml for ID %d. Server returned %s', id, curs.message);
-  end
-
-  if ~isempty(objTxt) && ~strcmp(objTxt(:), 'No Data')
-    % convert to Java string
-    str = java.lang.String(objTxt);
-    % open stream on this string
-    stream = java.io.StringBufferInputStream(str);
-    % make parser
-    builder = javax.xml.parsers.DocumentBuilderFactory.newInstance.newDocumentBuilder;
-
-    xdoc = builder.parse(stream);
-  else
-    xdoc = [];
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/getsinfo.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/getsinfo.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,79 +1,56 @@
-% GETSINFO This function returns an sinfo object containing many useful information about an object retrieved from the repository
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function sinfo = getsinfo(conn, varargin)
+% GETSINFO  Retrieved objects submission info from the repository.
+%
+% CALL:
 %
-% usage:   sinfo = getsinfo(id, conn)
+%   sinfo = getsinfo(conn, id, id)
 %
-% inputs:  id    = obj_id from objmeta table
-%          conn  = utils.mysql.connect(server, dbname);
+% INPUTS:
+%
+%      id - object ID
+%    conn - repository connection implementing java.sql.Connection
 %
-% outputs: sinfo cell array object containing info about object having the
-%          given obj_id on the repository.
-%          sinfo contains the following fields:
-%          - name
-%          - experiment_title
-%          - experiment_desc
-%          - analysis_desc
-%          - quantity
-%          - additional_authors
-%          - additional_comments
-%          - keywords and reference_ids
+% OUTPUTS:
+%
+%   sinfo - array of sinfo structures containing fields
 %
-%          A Monsky 05-02-2009
-%
-% version: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $
+%    - name
+%    - experiment_title
+%    - experiment_desc
+%    - analysis_desc
+%    - quantity
+%    - additional_authors
+%    - additional_comments
+%    - keywords
+%    - reference_ids
 %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [varargout] = getsinfo(varargin)
-  
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Collect input variable names
-  in_names = cell(size(varargin));
-  for ii = 1:nargin,in_names{ii} = inputname(ii);end
-  
-  % Collect all ids and plists and connections
-  pl = utils.helper.collect_objects(varargin(:), 'plist');
-  id = utils.helper.collect_objects(varargin(:), 'double');
-  conn  = utils.helper.collect_objects(varargin(:), 'mpipeline.repository.RepositoryConnection');
-  
-  if isempty(conn)
-    error('### This method needs a java connection (mpipeline.repository.RepositoryConnection).');
-  end
-  
-  if isempty(id)
-    error('### This method needs at least one object id.');
+% VERSION: $Id: getsinfo.m,v 1.2 2011/03/29 13:40:16 hewitson Exp $
+
+  if ~isa(conn, 'java.sql.Connection')
+    error('### first argument should be a java.sql.Connection object');
   end
-  
-  if nargout == 0
-    error('### lscov can not be used as a modifier method. Please give at least one output');
-  end
-  
-  % combine plists
-  pl = combine(pl, plist());
-  
-  % Algorithm
-  % Get complete experiment information for each input id
+
   sinfo = [];
-  for ii=1:length(id)
-    qall = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '...
-      'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ...
-      sprintf('where objmeta.obj_id=%d',id(ii))];
-    
-    infoall = utils.jmysql.dbquery(conn, qall);
+  for kk = 1:length(varargin)
+
+    q = ['SELECT name, experiment_title, experiment_desc, analysis_desc, ' ...
+         'quantity, additional_authors, additional_comments, keywords, ' ...
+         'reference_ids FROM objmeta WHERE obj_id = ?'];
+
+    info = utils.mysql.execute(conn, q, varargin{kk});
+
     s.conn                    = conn;
-    s.name                    = infoall{1};
-    s.experiment_title        = infoall{2};
-    s.experiment_description  = infoall{3};
-    s.analysis_description    = infoall{4};
-    s.quantity                = infoall{5};
-    s.additional_authors      = infoall{6};
-    s.additional_comments     = infoall{7};
-    s.keywords                = infoall{8};
-    s.reference_ids           = infoall{9};
+    s.name                    = info{1};
+    s.experiment_title        = info{2};
+    s.experiment_description  = info{3};
+    s.analysis_description    = info{4};
+    s.quantity                = info{5};
+    s.additional_authors      = info{6};
+    s.additional_comments     = info{7};
+    s.keywords                = info{8};
+    s.reference_ids           = info{9};
+
     sinfo = [sinfo s];
   end
-  
-  % Set output
-  varargout{1} = sinfo;
+
 end
--- a/m-toolbox/classes/+utils/@jmysql/insert.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-% INSERT inserts values into a single row of a table using JDBC driver
-% specified by the input connection.
-%
-% Usage: message = insert(conn, table, 'field1', value1, 'field2', value2,...)
-%
-% M Hewitson
-%
-% 31-07-07
-%
-% $Id: insert.m,v 1.4 2009/09/16 13:38:58 hewitson Exp $
-%
-
-function message = insert(conn, table, varargin)
-
-  message = '';
-  q = sprintf('INSERT INTO %s SET ',  table);
-  
-  for j=1:2:length(varargin)
-    
-    col = varargin{j};
-    val = varargin{j+1};
-    if isnumeric(val)
-      if ~any(isnan(val))
-        q = [q col '=' num2str(val) ','];
-      end
-    elseif ischar(val)
-      q = [q col '=' '''' val '''' ','];
-    else
-      error('### val class [%s]', class(val))
-    end
-        
-  end
-  
-  q = deblank([q(1:end-1) ';']);
-
-  if length(q) > 50
-    qdisp = [q(1:50) '...'];
-    utils.helper.msg(utils.const.msg.PROC1, 'running query %s', qdisp);
-  else
-    utils.helper.msg(utils.const.msg.PROC1, 'running query %s', q);
-  end
-  
-  try
-    stmt = conn.createStatement;
-    stmt.execute(q);
-  catch Me
-    error('### insert: failed to execute query');
-  end
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/insertObjMetadata.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-function insertObjMetadata(conn, obj, objid)
-  % an utility to insert entries for various object metadata in the
-  % corresponding tables. differs from insertObjMetadataV1() by
-  % the use of the new v3.0 database structure
-  %
-  % MUST BE KEPT IN SYNC WITH updateObjMetadata()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-  % VERSION:     $Id: insertObjMetadata.m,v 1.9 2011/11/09 18:45:14 mauro Exp $
-  %
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-  import utils.const.*
-
-  if nargin < 3
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### incorrect usage');
-  end
-
-  % class of object
-  cl = class(obj);
-  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
-
-  switch cl
-    case 'ao'
-
-      % call recursively to insert the data object info
-      utils.jmysql.insertObjMetadata(conn, obj.data, objid);
-
-      % insert the AO info
-      stmt = conn.prepareStatement(...
-        'INSERT INTO ao (obj_id, data_type, description) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(class(obj.data)));
-      
-      desc = obj.description;
-      if length(desc)>65535
-        warning('Object description length exceeded. Truncating to 65535 characters');
-        desc = desc(1:65535);
-      end
-      stmt.setObject(3, java.lang.String(desc));
-      stmt.execute();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO cdata (obj_id, yunits) VALUES (?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.execute();
-      stmt.close();
-
-    case 'fsdata'
-
-      % possible bad entries
-      fs = obj.fs;
-      if ~isfinite(fs)
-        fs = [];
-      end
-        
-      stmt = conn.prepareStatement(...
-        'INSERT INTO fsdata (obj_id, xunits, yunits, fs) VALUES (?, ?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.xunits)));
-      stmt.setObject(3, java.lang.String(char(obj.yunits)));
-      stmt.setObject(4, fs);
-      stmt.execute();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO tsdata (obj_id, xunits, yunits, fs, t0, nsecs, toffset) VALUES (?, ?, ?, ?, ?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.xunits)));
-      stmt.setObject(3, java.lang.String(char(obj.yunits)));
-      stmt.setObject(4, obj.fs);
-      stmt.setObject(5, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
-      stmt.setObject(6, obj.nsecs);
-      stmt.setObject(7, obj.toffset);
-      stmt.execute();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO xydata (obj_id, xunits, yunits) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.xunits)));
-      stmt.setObject(3, java.lang.String(char(obj.yunits)));
-      stmt.execute();
-      stmt.close();
-
-    case 'mfir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    case 'miir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    otherwise
-      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
-
-  end
-
-end
--- a/m-toolbox/classes/+utils/@jmysql/insertObjMetadataV1.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-function id = insertObjMetadataV1(conn, obj, objid)
-  % an utility to insert entries for various object metadata in the
-  % corresponding tables. uses the old v2.1 database schema.
-  %
-  % MUST BE KEPT IN SYNC WITH updateObjMetadataV1()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-
-  import utils.const.*
-
-  if nargin < 3
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### incorrect usage');
-  end
-
-  % default output value
-  id = [];
-
-  % class of object
-  cl = class(obj);
-  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
-
-  switch cl
-    case 'ao'
-
-      % call recursively to insert the data object info
-      dataid = utils.jmysql.insertObjMetadataV1(conn, obj.data, objid);
-
-      % insert the AO info
-      stmt = conn.prepareStatement(...
-        'INSERT INTO ao (obj_id, data_type, data_id, description) VALUES (?, ?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(class(obj.data)));
-      stmt.setObject(3, dataid);
-      desc = obj.description;
-      if length(desc)>65535
-        warning('Object description length exceeded. Truncating to 65535 characters');
-        desc = desc(1:65535);
-      end
-      stmt.setObject(4, java.lang.String(desc));
-      stmt.execute();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO cdata (yunits) VALUES (?)');
-      stmt.setObject(1, java.lang.String(char(obj.yunits)));
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'fsdata'
-
-      % possible bad entries
-      fs = obj.fs;
-      if ~isfinite(fs)
-        fs = [];
-      end
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO fsdata (xunits, yunits, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.setObject(3, fs);
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO tsdata (xunits, yunits, fs, t0, nsecs) VALUES (?, ?, ?, ?, ?)');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.setObject(3, obj.fs);
-      stmt.setObject(4, java.lang.String(format(obj.t0, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
-      stmt.setObject(5, obj.nsecs);
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO xydata (xunits, yunits) VALUES (?, ?)');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'mfir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    case 'miir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    otherwise
-      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
-
-  end
-end
--- a/m-toolbox/classes/+utils/@jmysql/jconnTodbconn.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-% JCONNTODBCONN convert a java db connection to a MATLAB database
-% connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: JCONNTODBCONN convert a java db connection to a MATLAB
-%              database Toolbox connection.
-%
-% CALL:        dbconn = utils.jmysql.jconnTodbconn(jconn);
-%
-% INPUTS:
-%              jconn - a connection object like that returned from
-%                     utils.jmysql.connect.
-% 
-% OUTPUTS:     dbconn - a database toolbox connecton
-%
-%
-% VERSION:     $Id: jconnTodbconn.m,v 1.1 2009/07/28 06:46:09 hewitson Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-
-function conn = jconnTodbconn(jconn)
-  
-  if nargin ~= 1 || ~isa(jconn, 'mpipeline.repository.RepositoryConnection')
-    error('### The first argument should be a RepositoryConnection');
-  end
-
-  host = char(jconn.getHostname);
-  db   = char(jconn.getDatabase);
-  user = char(jconn.getUsername);
-  pw   = char(jconn.getPassword);
-  
-  dbdriver = getappdata(0, 'mysql_driver');
-  dburl    = sprintf('jdbc:mysql://%s/%s',host,db);
-
-  disp(sprintf('** Connecting to %s as %s...', host, user))
-
-  conn     = database(db,user,pw,dbdriver,dburl);
-  disp('** Connection status:')
-  disp(ping(conn))
-  
-  
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/jmysql.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/jmysql.m	Tue Dec 06 19:07:22 2011 +0100
@@ -25,24 +25,11 @@
     varargout = getsinfo(varargin) % return sinfo structure of repository object
 
     %%% MYSQL TOOLS
-    varargout = connect(varargin) % connects to an LTPDA repository and returns the connection object.
-    varargout = query(varargin) % perform a query on an LTPDA repository and returns the results.
+    varargout = connect(varargin) % connects to an LTPDA repository and returns the connection object
+    varargout = query(varargin) % perform a query on an LTPDA repository and returns the results
     varargout = resultsToCell(varargin) % convert a ResultSet to a cell-array
     varargout = displayResults(varargin) % display a ResultSet in a table
-    varargout = queryDialog(varargin) % show a query builder dialog
-    varargout = submitDialog(varargin) % show a submission dialog
-    varargout = jconnTodbconn(varargin) % convert a java connection to database toolbox connection
-    varargout = dbconnTojconn(varargin) % convert a database toolbox connection to java connection
-    varargout = getUserID(varargin)
-    varargout = getXdoc(varargin)
-    varargout = insert(varargin)
-    varargout = getRepositoryVersion(varargin)
     varargout = dbquery(varargin)
-    varargout = insertObjMetadata(varargin)
-    varargout = updateObjMetadata(varargin)
-    varargout = insertObjMetadataV1(varargin) % back-compatibility for old database schema
-    varargout = updateObjMetadataV1(varargin) % back-compatibility for old database schema
-    varargout = execute(varargin)
 
   end % End static methods
 
--- a/m-toolbox/classes/+utils/@jmysql/query.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/query.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,70 +1,44 @@
-% QUERY query an LTPDA repository.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function varargout = query(conn, query, varargin)
+% QUERY  Query an LTPDA repository.
 %
-% DESCRIPTION: QUERY query an LTPDA repository.
+% DEPRECATED! Use utils.mysql.execute instead!
 %
-% CALL:                     results = query(conn, q)
-%              [results, col_names] = query(conn, q)
+% CALL:                [results] = query(conn, q, varargin)
+%              [results, cnames] = query(conn, q, varargin)
 %
 % INPUTS:
-%              conn - an mpipeline.repository.RepositoryConnection object,
-%                     as is returned by utils.jmysql.connect
-%              q    - a valid MySQL query string
+%
+%      conn  - database connection object implementing java.sql.Connection
+%     query  - a valid SQL query
+%  varargin  - optional query parameters
 %
 % OUTPUTS:
-%                results - a cell-array of the results
-%              col_names - a cell-array of the column names in the query
-%
-% VERSION:     $Id: query.m,v 1.1 2009/07/27 19:46:21 hewitson Exp $
 %
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
+%   results  - a cell-array of the results
+%    cnames  - a cell-array of the column names in the query
 %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
+% VERSION: $Id: query.m,v 1.1 2009/07/27 19:46:21 hewitson Exp $
+%
 
-%              (*) the expiry time for MySQL logins is a property of the
-%              LTPDA Toolbox and can be set in the LTPDA Preferences.
-
-
-function varargout = query(varargin)
+  warning('!!! deprecated. use utils.mysql.execute instead');
   
-  prefs = getappdata(0, 'LTPDApreferences');
-  
-  if ~isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')
-    error('### The first argument should be a RepositoryConnection');
+  if ~isa(conn, 'java.sql.Connection')
+    error('### first argument should be a java.sql.Connection object');
   end
   
-  if ~ischar(varargin{2})
-    error('### The second argument should be a query string.');
+  stmt = conn.prepareStatement(query);
+  for kk = 1:numel(varargin)
+    stmt.setObject(kk, varargin{kk});
   end
   
-  % Inputs
-  conn = varargin{1};
-  q    = varargin{2};
-  
-  % Outputs
-  results  = {};
-  colnames = {};
+  % execute query
+  resultSet = stmt.executeQuery();
   
-  % Check connection
-  if ~conn.isConnected
-    conn.openConnection
-  end
-  
-  if ~conn.isConnected
-    conn.display;
-    error('### Failed to open connection');
-    return
-  end
-  
-  resultSet = conn.query(q);
-    
-  % Set outputs
+  % set outputs
   if nargout > 0
     varargout{1} = resultSet;
     if nargout == 2
-      % Get column names from the meta data
+      % get column names from the meta data
       rsm = resultSet.getMetaData;
       Nc = rsm.getColumnCount;
       colnames = cell(1,Nc);
--- a/m-toolbox/classes/+utils/@jmysql/queryDialog.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-% QUERYDIALOG a visual query builder for querying an LTPDA repository.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: QUERYDIALOG a visual query builder for querying an LTPDA
-%              repository.
-%
-% CALL:        utils.jmysql.queryDialog();
-%              utils.jmysql.queryDialog(conn);
-%
-% INPUTS:
-%              conn - a connection object like that returned from
-%                     utils.jmysql.connect.
-%
-%
-% VERSION:     $Id: queryDialog.m,v 1.2 2009/09/22 14:40:07 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-
-function  queryDialog(varargin)
-  
-  if nargin == 1 && ~isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')
-    error('### The first argument should be empty or a RepositoryConnection');
-  end
-  
-  
-  % Inputs
-  conn = [];
-  if nargin > 0
-    conn  = varargin{1};
-  end
-  
-  if isempty(conn)
-    conn = utils.jmysql.connect();
-  end
-  
-  if ~conn.isConnected
-    conn.openConnection
-  end
-  
-  if ~conn.isConnected
-    error('### Failed to connect to repository.');
-  end
-  
-  % open a query dialog
-  if nargin == 0
-    closeConnectionOnExit = true;
-  else
-    closeConnectionOnExit = false;
-  end
-  warning('off', 'MATLAB:JavaEDTAutoDelegation');
-  qrd = mpipeline.repository.RepositoryQueryDialog([], false, conn, false, closeConnectionOnExit);
-  qrd.setVisible(true)
-  warning('off', 'MATLAB:JavaEDTAutoDelegation');
-  
-  
-  
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/resultsToCell.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@jmysql/resultsToCell.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,58 +1,67 @@
-% RESULTSTOCELL converts a java sql ResultSet to a cell-array
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function varargout = resultsToCell(resultSet)
+% RESULTSTOCELL  Converts a java.sql.ResultSet to a cell array
 %
-% DESCRIPTION: RESULTSTOCELL converts a java sql ResultSet to a cell-array.
+% DEPRECATED! Use utils.mysql.execute instead!
 %
-% CALL:        [results, colnames] = utils.jmysql.resultsToCell(resultSet);
+% CALL:
+%
+%   [results, colnames] = utils.jmysql.resultsToCell(rs);
 %
 % INPUTS:
-%              resultSet - a result set like that returned from
-%                          utils.jmysql.query
+%
+%   rs       - a java.sql.ResultSet like that returned from utils.jmysql.query
 %
 % OUTPUTS:
-%              results      - a cell array of results
-%              col_names    - a cell array of column names
 %
+%   results  - a cell array of results
+%   colnames - a cell array of column names
 %
-% VERSION:     $Id: resultsToCell.m,v 1.1 2009/07/27 19:46:21 hewitson Exp $
+% VERSION: $Id: resultsToCell.m,v 1.1 2009/07/27 19:46:21 hewitson Exp $
 %
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+  warning('!!! deprecated. use utils.mysql.execute instead');
+  
+  if ~isa(resultSet, 'java.sql.ResultSet')
+    error('### first argument should be a java.sql.ResultSet');
+  end
 
+  % get results into a cell array
+  md = rs.getMetaData();
+  nc = md.getColumnCount();
+  row = 1;
+  while rs.next()
+    for kk = 1:nc
+      % convert to matlab objects
+      rows{row, kk} = java2matlab(rs.getObject(kk));
+    end
+    row = row + 1;
+  end
+      
+  % get column names
+  names = cell(1, nc);
+  for kk = 1:nc
+    names{kk} = char(md.getColumnName(kk));
+  end
+      
+  % assign output
+  switch nargout
+    case 0
+      varargout{1} = rows;
+    case 1
+      varargout{1} = rows;
+    case 2
+      varargout{1} = names;
+      varargout{2} = rows;
+    otherwise
+      error('### too many output arguments');
+  end      
+end
 
 
-function varargout = resultsToCell(varargin)
-  
-  prefs = getappdata(0, 'LTPDApreferences');
-  
-  if ~isa(varargin{1}, 'java.sql.ResultSet')
-    error('### The first argument should be a ResultSet');
+function val = java2matlab(val)
+  % matlab converts all base types. just add a conversion for datetime columns
+  switch class(val)
+    case 'java.sql.Timestamp'
+      val = time(plist('time', char(val), 'timezone', 'UTC'));
   end
-  
-  % Inputs
-  resultSet  = varargin{1};
-  
-  os = mpipeline.repository.RepositoryConnection.resultSetToObjectArray(resultSet);
-  disp(sprintf('*** converted result set: [%dx%d]', numel(os), numel(os(1))));
-  
-  % Set outputs
-  if nargout > 0
-    varargout{1} = cell(os);
-    if nargout == 2
-      % Get column names from the meta data
-      rsm = resultSet.getMetaData;
-      Nc = rsm.getColumnCount;
-      colnames = cell(1,Nc);
-      for kk=1:Nc
-        colnames{kk} = char(rsm.getColumnName(kk));
-      end
-      
-      varargout{2} = colnames;
-    end
-  end
-  
-  
 end
-
--- a/m-toolbox/classes/+utils/@jmysql/submitDialog.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-% SUBMITDIALOG a submission dialog for submitting objects an LTPDA repository.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: SUBMITDIALOG a submission dialog for submitting objects an
-%              LTPDA repository.
-%
-% CALL:        sinfo = utils.jmysql.submitDialog();
-%              sinfo = utils.jmysql.submitDialog(conn);
-%              sinfo = utils.jmysql.submitDialog(conn,sinfo);
-%
-% INPUTS:
-%              conn  - a connection object like that returned from
-%                      utils.jmysql.connect.
-%              sinfo - an sinfo structure to pre-populate the entry fields
-%
-% OUTPUTS: 
-%              sinfo - an sinfo structure suitable to pass to submit
-% 
-% NOTE: the sinfo object contains a valid and connected database connection
-% object. It is up to the caller to close this connection when it is no
-% longer required.
-% 
-% NOTE: if an input connection is provided, this is not closed by this
-% process.
-%
-% VERSION:     $Id: submitDialog.m,v 1.4 2009/10/02 09:19:50 hewitson Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-
-function sinfo = submitDialog(varargin)
-  
-  if nargin > 0 && ~isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')
-    error('### The first argument should be empty or a RepositoryConnection');
-  end
-  
-  isinfo = [];
-  
-  if nargin == 2 && isstruct(varargin{2})
-    isinfo = varargin{2};
-  end
-  
-  % Inputs
-  conn = [];
-  if nargin > 0
-    conn  = varargin{1};
-  end
-
-  % Check the connection
-  if ~isempty(conn)
-    closeConnection = false;
-    if ~conn.isConnected
-      conn.openConnection
-    end
-    if ~conn.isConnected
-      error('### Failed to connect to repository.');
-    end
-  else
-    closeConnection = true;
-  end
-  
-  % Get host list
-  prefs = getappdata(0, 'LTPDApreferences');
-  hosts = java.util.ArrayList();
-  servers = prefs.repository.servers;
-  for kk=1:numel(servers)
-    hosts.add(servers{kk});
-  end
-  
-  jisinfo = [];
-  if ~isempty(isinfo) 
-    
-    jisinfo = mpipeline.repository.SubmissionInfo([]);
-    jisinfo.setExperimentTitle(isinfo.experiment_title);
-    jisinfo.setExperimentDescription(isinfo.experiment_description);
-    jisinfo.setAnalysisDescription(isinfo.analysis_description);
-    jisinfo.setQuantity(isinfo.quantity);
-    jisinfo.setKeywords(isinfo.keywords);
-    jisinfo.setReferenceIDs(isinfo.reference_ids);
-    jisinfo.setAdditionalComments(isinfo.additional_comments);
-    jisinfo.setAdditionalAuthors(isinfo.additional_authors);
-    
-  end
-  
-  % Open submit dialog
-  warning('off', 'MATLAB:JavaEDTAutoDelegation');
-  srd = mpipeline.repository.SubmitInfoDialog([], jisinfo, hosts, conn);
-  srd.setVisible(true)
-  warning('on', 'MATLAB:JavaEDTAutoDelegation');
-  
-  sinfo = [];
-  if ~srd.isCancelled
-    
-    jsinfo = srd.getSubmissionInfo;
-    sinfo.experiment_title       = char(jsinfo.getExperimentTitle);
-    sinfo.experiment_description = char(jsinfo.getExperimentDescription);
-    sinfo.analysis_description   = char(jsinfo.getAnalysisDescription);
-    sinfo.quantity               = char(jsinfo.getQuantity);
-    sinfo.keywords               = char(jsinfo.getKeywords);
-    sinfo.reference_ids          = char(jsinfo.getReferenceIDs);
-    sinfo.additional_comments    = char(jsinfo.getAdditionalComments);
-    sinfo.additional_authors     = char(jsinfo.getAdditionalAuthors);
-    
-    jconn = srd.getRepoConnection;    
-    sinfo.conn = jconn; %utils.jmysql.jconnTodbconn(jconn);    
-    if closeConnection
-      jconn.closeConnection;
-    end
-  end
-  
-end
-
--- a/m-toolbox/classes/+utils/@jmysql/updateObjMetadata.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-function updateObjMetadata(conn, obj, objid)
-  % an utility to update entries for various object metadata in the
-  % corresponding tables. differs from insertObjMetadataV1() by
-  % the use of the new v3.0 database structure
-  %
-  % MUST BE KEPT IN SYNC WITH insertObjMetadata()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-  % VERSION:     $Id: updateObjMetadata.m,v 1.7 2011/11/09 18:47:04 mauro Exp $
-  %
-  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-  import utils.const.*
-
-  if nargin < 3
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### incorrect usage');
-  end
-
-  % class of object
-  cl = class(obj);
-  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
-
-  switch cl
-    case 'ao'
-
-      % call recursively to insert the data object info
-      utils.jmysql.updateObjMetadata(conn, obj.data, objid);
-
-      % insert the AO info
-      stmt = conn.prepareStatement(...
-        'UPDATE ao SET data_type=?, description=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(class(obj.data)));
-      desc = obj.description;
-      if length(desc)>65535
-        warning('Object description length exceeded. Truncating to 65535 characters');
-        desc = desc(1:65535);
-      end
-      stmt.setObject(2, java.lang.String(desc));
-      stmt.setObject(3, objid);
-      stmt.executeUpdate();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE cdata SET yunits=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(char(obj.yunits)));
-      stmt.setObject(2, objid);
-      stmt.executeUpdate();
-      stmt.close();
-
-    case 'fsdata'
-
-      % possible bad entries
-      fs = obj.fs;
-      if ~isfinite(fs)
-        fs = [];
-      end
-        
-      stmt = conn.prepareStatement(...
-        'UPDATE fsdata SET xunits=?, yunits=?, fs=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.setObject(3, fs);
-      stmt.setObject(4, objid);
-      stmt.executeUpdate();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=?, toffset=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.setObject(3, obj.fs);
-      stmt.setObject(4, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
-      stmt.setObject(5, obj.nsecs);
-      stmt.setObject(6, obj.toffset);
-      stmt.setObject(7, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE xydata SET xunits=?, yunits=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.setObject(3, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'mfir'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE mfir SET in_file=?, fs=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(obj.infile));
-      stmt.setObject(2, obj.fs);
-      stmt.setObject(3, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'miir'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE miir SET in_file=?, fs=? WHERE obj_id = ?');
-      stmt.setObject(1, java.lang.String(obj.infile));
-      stmt.setObject(2, obj.fs);
-      stmt.setObject(3, objid);
-      stmt.execute();
-      stmt.close();
-
-    otherwise
-      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
-
-  end
-
-end
--- a/m-toolbox/classes/+utils/@jmysql/updateObjMetadataV1.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-function id = updateObjMetadataV1(conn, obj, objid)
-  % an utility to update entries for various object metadata in the
-  % corresponding tables. uses the old v2.1 database schema.
-  %
-  % MUST BE KEPT IN SYNC WITH insertObjMetadataV1()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-
-  import utils.const.*
-
-  if nargin < 3
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### incorrect usage');
-  end
-
-  % default return value
-  id = [];
-  
-  % class of object
-  cl = class(obj);
-  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
-
-  switch cl
-    case 'ao'
-
-      % get data type and id
-      stmt = conn.prepareStatement(...
-        'SELECT data_id, data_type FROM ao WHERE obj_id = ?');
-      stmt.setObject(1, objid);
-      rs = stmt.executeQuery();
-      rs.next();
-      dataid = rs.getInt(1);
-      datatype = rs.getString(2);
-      rs.close();
-      stmt.close();
-      
-      % check if the data type is consistent
-      if ~strcmp(datatype, class(obj.data))
-        error('### cannot update an object with one having a different data type');
-      end
-        
-      % call recursively to insert the data object info
-      id = utils.jmysql.updateObjMetadataV1(conn, obj.data, dataid);
-
-      % update ao description
-      stmt = conn.prepareStatement(...
-        'UPDATE ao SET description=? WHERE obj_id = ?');
-      desc = obj.description;
-      if length(desc)>65535
-        warning('Object description length exceeded. Truncating to 65535 characters');
-        desc = desc(1:65535);
-      end
-      stmt.setObject(1, desc);
-      stmt.setObject(2, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE cdata SET yunits=? WHERE id = ?');
-      stmt.setObject(1, char(obj.yunits));
-      stmt.setObject(2, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'fsdata'
-
-      % possible bad entries
-      fs = obj.fs;
-      if ~isfinite(fs)
-        fs = [];
-      end
-        
-      stmt = conn.prepareStatement(...
-        'UPDATE fsdata SET xunits=?, yunits=?, fs=? WHERE id = ?');
-      stmt.setObject(1, char(obj.xunits));
-      stmt.setObject(2, char(obj.yunits));
-      stmt.setObject(3, fs);
-      stmt.setObject(4, objid);      
-      stmt.execute();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=? WHERE id = ?');
-      stmt.setObject(1, char(obj.xunits));
-      stmt.setObject(2, char(obj.yunits));
-      stmt.setObject(3, obj.fs);
-      stmt.setObject(4, format(obj.t0, 'yyyy-mm-dd HH:MM:SS', 'UTC'));
-      stmt.setObject(5, obj.nsecs);
-      stmt.setObject(6, objid);      
-      stmt.execute();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE xydata SET xunits=?, yunits=? WHERE id = ?');
-      stmt.setObject(1, char(obj.xunits));
-      stmt.setObject(2, char(obj.yunits));
-      stmt.setObject(3, objid);      
-      stmt.execute();
-      stmt.close();
-
-    case 'mfir'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE mfir SET in_file=?, fs=? WHERE obj_id = ?');
-      stmt.setObject(1, obj.infile);
-      stmt.setObject(2, obj.fs);
-      stmt.setObject(3, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'miir'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE miir SET in_file=?, fs=? WHERE obj_id = ?');
-      stmt.setObject(1, obj.infile);
-      stmt.setObject(2, obj.fs);
-      stmt.setObject(3, objid);      
-      stmt.execute();
-      stmt.close();
-
-    otherwise
-      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
-
-  end
-
-end
--- a/m-toolbox/classes/+utils/@mysql/connect.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@mysql/connect.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,189 +1,50 @@
-% CONNECT connects to an LTPDA repository and returns the connection object.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function conn = connect(hostname, database, username, password)
+% CONNECT Opens a connection to the given database.
 %
-% DESCRIPTION: CONNECT connects to an LTPDA repository and returns the
-%              connection object.
-% 
-%              CONNECT stores a persistent set of logins where a login has
-%              the fields:
-%                  'hostname' - the hostname of the MySQL server
-%                  'db'       - the name of the database
-%                  'user'     - the username for connection to this db
-%                  'passwd'   - the password for this user
-% 
-%              If a login for the requested hostname and db doesn't exist,
-%              or if the existing login is too old (*) then the user is
-%              prompted to log in again.
-%               
-%              (*) the expiry time for MySQL logins is set to 30s.
+% CALL:
+%
+%   conn = utils.mysql.connect(hostname, database, username, password)
 %
-% CALL:        conn = connect(hostname)  % connects to 'test' database
-%              conn = connect(hostname, dbname)  % dialog prompt for username and password
-%              [conn, password] = connect(hostname, dbname) % return password to caller
-%              conn = connect(hostname, dbname, dbuser, dbpass) % connect with explicit username and password
+% This function returns a Java java.sql.Connection object.
 %
-% VERSION:     $Id: connect.m,v 1.8 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% On authetication error an utils:mysql:connect:AccessDenied exception
+% is thrown. On other errors an utils:mysql:connect:ConnectionError
+% exception is thrown.
 
-
-%              (*) the expiry time for MySQL logins is a property of the
-%              LTPDA Toolbox and can be set in the LTPDA Preferences.
-
-
-function varargout = connect(varargin)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  if nargin < 1
-    error('### Incorrect inputs')
-  end
+  % informative message
+  import utils.const.*
+  utils.helper.msg(msg.PROC1, 'connection to mysql://%s/%s username=%s', hostname, database, username);
 
-  persistent logins;
-  
-  prefs = getappdata(0, 'LTPDApreferences');
-  expTime = prefs.repository.loginExpiry;
-  
-  dbuser = '';
-  dbpass = '';
+  % connection credential
+  uri = sprintf('jdbc:mysql://%s/%s', hostname, database);
+  db = javaObject('com.mysql.jdbc.Driver');
+  pl = javaObject('java.util.Properties');
+  pl.setProperty(db.USER_PROPERTY_KEY, username);
+  pl.setProperty(db.PASSWORD_PROPERTY_KEY, password);
 
-  force = false;
-  if nargin == 1
-    dbhost = varargin{1};
-    dbname = 'test';
-  elseif nargin == 2
-    dbhost = varargin{1};
-    dbname = varargin{2};
-  elseif nargin == 3
-    dbhost = varargin{1};
-    dbname = varargin{2};
-    force = varargin{3};
-  elseif nargin == 4
-    dbhost = varargin{1};
-    dbname = varargin{2};
-    dbuser = varargin{3};
-    dbpass = varargin{4};
-  elseif nargin == 5
-    dbhost = varargin{1};
-    dbname = varargin{2};
-    dbuser = varargin{3};
-    dbpass = varargin{4};
-    force = varargin{5};
-  end
-  
-  if isempty(logins)
-    % Prompt for username and password
-    [dbuser, dbpass] = getlogin(dbhost, dbname, dbuser, dbpass, force);
-        
-    % in the case the user clicks cancel
-    if ~ischar(dbuser) && ~ischar(dbpass)
-      if (dbuser == -1 && dbpass == -1)
-        varargout{1} = -1;
-        varargout{2} = -1;
-        return
+  try
+    % connect
+    conn = db.connect(uri, pl);
+  catch ex
+    % exceptions handling in matlab sucks
+    if strcmp(ex.identifier, 'MATLAB:Java:GenericException')
+      % extract exception class and message
+      lines = regexp(ex.message, '\n', 'split');
+      p = strfind(lines{2}, ': ');
+      id = lines{2}(1:p(1)-1);
+      message = lines{2}(p(1)+2:end);
+      % some notable cases
+      switch id
+        case 'java.sql.SQLException'
+          throwAsCaller(MException('utils:mysql:connect:AccessDenied', '### access denied: %s', message))
+        case 'com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException'
+          throwAsCaller(MException('utils:mysql:connect:ConnectionError', '### connection error: %s. check database name', message))
+        case 'com.mysql.jdbc.exceptions.jdbc4.CommunicationsException'
+          throwAsCaller(MException('utils:mysql:connect:ConnectionError', '### connection error: %s. check hostname', message))
       end
+      % user friendlier exception
+      throwAsCaller(MException('utils:mysql:connect:ConnectionError', '### connection error: %s: %s', id, message))
     end
-    
-    % Create a new login
-    login.hostname = dbhost;
-    login.db       = dbname;
-    login.user     = dbuser;
-    login.passwd   = dbpass;
-    login.ts       = now;
-    
-    % store this login
-    logins = [logins login];
-    
-  else
-    % look for a login to this hostname/db
-    loginFound = false;
-    for kk=1:numel(logins)
-      login = logins(kk);
-      dt = (now - login.ts) * 86400; % [s]
-      if strcmp(login.hostname, dbhost) && strcmp(login.db, dbname)
-        if dt < expTime
-          % get the username and password from here
-          dbuser = login.user;
-          dbpass = login.passwd;
-          logins(kk).ts = now;
-          loginFound = true;
-          break;
-        end
-      end
-    end    
-    
-    % If we didn't find a login then create a new one
-    if force || isempty(dbuser) || isempty(dbpass)
-      [dbuser, dbpass] = getlogin(dbhost, dbname, dbuser, dbpass, force);
-      
-      % Create a new login
-      login.hostname = dbhost;
-      login.db       = dbname;
-      login.user     = dbuser;
-      login.passwd   = dbpass;
-      login.ts       = now;
-      
-      % store this login
-      if ~loginFound
-        logins = [logins login];      
-      end
-    end
-    
+    rethrow(ex);
   end
-  
-  %% return if we don't have a dbuser
-  if isempty(dbuser)
-    return
-  end
-  
-  %% Database settings
-  dbdriver = getappdata(0, 'mysql_driver');
-  dburl    = sprintf('jdbc:mysql://%s/%s',dbhost,dbname);
-
-  disp(sprintf('** Connecting to %s as %s...', dbhost, dbuser))
-
-  conn     = database(dbname,dbuser,dbpass,dbdriver,dburl);
-  disp('** Connection status:')
-  disp(ping(conn))
-
-  % Set outputs
-  if nargout > 0
-    varargout{1} = conn;
-    if nargout == 2
-      varargout{2} = dbpass;
-    end
-  end
-
 end
-
-function [dbuser, dbpass] = getlogin(dbhost, dbname, dbuser, dbpass, force)
-      
-    % first try defaults
-    if isempty(dbuser)
-      dbuser = getappdata(0, 'ltpda_repo_user');
-    end
-    if isempty(dbpass)
-      dbpass = getappdata(0, 'ltpda_repo_pass');
-    end
-    
-    % then log-in dialog
-    if force || isempty(dbuser) || isempty(dbpass)
-
-        ld = logindialog.LoginDialog([], true);
-        ld.setVisible(true)
-        if ~ld.isCancelled
-            dbuser = char(ld.getUsername);
-            dbpass = [char(ld.getPassword)]'; % for some reason we get a column here, so transpose.
-        end
-
-      if isempty(dbuser) || isempty(dbpass)
-        warning('!!! Login process cancelled.');
-        dbuser = -1;
-        dbpass = -1;
-        return
-      end
-    end
-    
-end
--- a/m-toolbox/classes/+utils/@mysql/dbquery.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-% DBQUERY query an AO repository database.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: DBQUERY query an AO repository database.
-%
-% CALL:        info = dbquery(conn);
-%              info = dbquery(conn, query);
-%              info = dbquery(conn, table, query);
-%
-% INPUTS:
-%           conn   - a database connection object such as that returned by
-%                    utils.mysql.connect().
-%           query  - a valid MySQL query string
-%           table  - a table name
-%
-% OUTPUTS:
-%           info - the returned 'info' structure contains the fields from
-%                  each matching record.
-%
-% EXAMPLES:
-%
-%   >> info  = dbquery(conn, 'select * from objmeta where id>1000 and id<2000');
-%   >> info  = dbquery(conn, 'ao',           'id>1000 and id<2000');
-%   >> info  = dbquery(conn, 'objmeta',      'name like "x12"');
-%   >> info  = dbquery(conn, 'users',        'username="aouser"');
-%   >> info  = dbquery(conn, 'collections',  'id=3');
-%   >> info  = dbquery(conn, 'collections',  'obj_ids="1,2"');
-%   >> info  = dbquery(conn, 'transactions', 'user_id=3');
-%   >> info  = dbquery(conn, 'transactions', 'obj_id=56');
-%
-%   >> info  = dbquery(conn)
-%
-%   The 'info' structure will contain a list of the tables in the database.
-%
-%   >> info  = dbquery(conn, query)
-%
-%   The 'info' structure will contain a list of records resulting from the SQL query.
-%
-% VERSION:     $Id: dbquery.m,v 1.2 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     10-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = dbquery(varargin)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  conn = varargin{1};
-  if ~isa(conn, 'database')
-    error('### First input must be a database connection object.');
-  end
-
-  if nargin == 1
-    % get table list
-    info = getTableList(conn);
-
-  elseif nargin == 2
-    % execute query
-    info = simpleQuery(conn, varargin{2});
-
-  elseif nargin == 3
-    % query a table
-    table    = varargin{2};
-    query    = varargin{3};
-    info = runQuery(conn, table, query);
-  else
-    error('### Incorrect inputs.');
-  end
-
-  varargout{1} = info;
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get table list
-function info = getTableList(conn)
-
-  % open a connection
-  try
-    curs = exec(conn, 'show tables');
-    curs = fetch(curs);
-    info = curs.Data;
-    close(curs);
-  catch
-    error('### Failed to get table list. Server returned: %s', curs.Message);
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get field list
-function info = getFieldList(conn, table)
-
-  try
-    curs = exec(conn, sprintf('describe %s', table));
-    curs = fetch(curs);
-    info = curs.Data;
-    close(curs);
-  catch
-    error('### Failed to get field list. Server returned: %s', curs.Message);
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get field list
-function info = simpleQuery(conn, q)
-
-  % open a connection
-
-  try
-    curs = exec(conn, sprintf('%s', q));
-    curs = fetch(curs);
-    info = curs.Data;
-    close(curs);
-  catch
-    error('### Failed to execute query. Server returned: %s', curs.Message);
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Run a query
-function info = runQuery(conn, table, query)
-
-  % Run query
-  info = [];
-
-  fieldlist = getFieldList(conn, table);
-  fields  = fieldlist(:,1);
-  f = '';
-  fs = {};
-  for j=1:length(fields)
-    % special cases
-    f  = [f fields{j} ',' ];
-    fs = [fs fields(j)];
-  end
-  q = sprintf('select %s  from %s where %s', f(1:end-1), table, query);
-  disp(['** QUERY: ' q]);
-  try
-    curs = exec(conn, q);
-    curs = fetch(curs);
-    info = curs.Data;
-    close(curs);
-  catch
-    error('### Failed to query table. Server returned: %s', curs.Message);
-  end
-end
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@mysql/execute.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,108 @@
+function varargout = execute(conn, query, varargin)
+% EXECUTE Execute the given QUERY with optional parameters VARARGIN
+% substituted for the '?' placeholders through connection CONN. In the
+% case of data manupulation queries returns the update count. In case
+% of data retrival queries returns a 2D cell array with the query
+% results and optionally a cell array with column names.
+%
+% CALL:
+%
+%          [rows] = utils.mysql.execute(conn, query, varargin)
+%   [rows, names] = utils.mysql.execute(conn, query, varargin)
+%
+% PARAMETERS:
+%
+%      conn -  an object implementing the java.sql.Connection interface
+%     query -  SQL query string. ? are substituted with PARAMS values
+%  varargin -  query parameters
+%
+% RETURNS:
+%
+%      rows -  update count in the case of data manipulation queries
+%              or 2D cell array with query resutls in the case of
+%              data retrival queries
+%     names -  names of the columns in the result set
+%
+
+  % check parameters
+  if nargin < 2
+    error('### incorrect usage');
+  end
+  if ~isa(conn, 'java.sql.Connection')
+    error('### invalid connection');
+  end
+
+  % build query
+  stmt = conn.prepareStatement(query);
+  for kk = 1:numel(varargin)
+    stmt.setObject(kk, matlab2sql(varargin{kk}));
+  end
+
+  % execute query
+  rv = stmt.execute();
+
+  switch rv
+    case 0
+      % we have an update count
+      varargout{1} = stmt.getUpdateCount();
+    case 1
+      % we have a result set
+      rs = stmt.getResultSet();
+
+      % get results into a cell array
+      md = rs.getMetaData();
+      nc = md.getColumnCount();
+      row = 1;
+      rows = {};
+      while rs.next()
+        for kk = 1:nc
+          % convert to matlab objects
+          rows{row, kk} = java2matlab(rs.getObject(kk));
+        end
+        row = row + 1;
+      end
+
+      % get column names
+      names = cell(1, nc);
+      for kk = 1:nc
+        names{kk} = char(md.getColumnName(kk));
+      end
+
+      % assign output
+      switch nargout
+        case 0
+          varargout{1} = rows;
+        case 1
+          varargout{1} = rows;
+        case 2
+          varargout{1} = names;
+          varargout{2} = rows;
+        otherwise
+          error('### too many output arguments');
+      end
+
+    otherwise
+      erorr('### error');
+  end
+end
+
+
+function val = matlab2sql(val)
+  switch class(val)
+    case 'char'
+      % matlab converts length one strings to the wrong java type
+      val = java.lang.String(val);
+    case 'time'
+      % convert time objects to strings
+      val = val.format('yyyy-mm-dd HH:MM:SS', 'UTC');
+  end
+end
+
+
+function val = java2matlab(val)
+  % matlab converts all base types. just add a conversion for datetime columns
+  switch class(val)
+    case 'java.sql.Timestamp'
+      val = time(plist('time', char(val), 'timezone', 'UTC'));
+  end
+end
--- a/m-toolbox/classes/+utils/@mysql/getAOsInTimeSpan.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-% GETAOSINTIMESPAN performs high-level queries to retrieve AOs from an LTPDA repository.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETAOSINTIMESPAN performs high-level queries to retrieve AOs
-%              from an LTPDA repository. The AOs for that channel in that time-span
-%              are joined together and then split on the requested
-%              interval. The resulting AO covers the requested interval,
-%              assuming that the repositoy contains a contiguos set of AOs
-%              spanning the requested time.
-%
-% CALL:        b = getAOsInTimeSpan(pl)
-%
-% INPUTS:      pl - a plist containing parameters as described below
-%
-% OUTPUTS:     b  - a vector of AOs resulting from the query
-%
-% PARAMETERS:
-%
-%     choose from
-%              'hostname'       - hostname/IP address of LTPDA Repository
-%              'database'       - the name of the database to query
-%          or
-%              'conn'           - a database connection object
-%
-%    in addition, we need
-%              'binary'         - retrieve binary data (true or false)
-%              'channels'       - a cell array of AO names
-%              'timespan'       - a timespan object to specify the
-%                                 time-interval of interest
-%
-% The timespan is applied start <= data < end.
-%
-% OPTIONAL PARAMETERS:
-%
-%    further restrict the search with the following conditions
-%
-%               'username'   - specify the username of the person who
-%                              submitted the AO
-%               'submitted'  - specify the date the AO was submitted
-%
-% EXAMPLES:
-%
-% 1) Find all AOs which are called 'ChannelX' submitted after 1st May 2007
-%
-%    pl = plist('hostname', 'localhost', 'database', 'ltpda_test', ...
-%               'channels', {'channelX'}, ...
-%               'timespan', timespan('2007-05-01 00:00:00', '3000-01-01 12:34:50', ...
-%               );
-%
-%    a = getAOsInTimeSpan(pl);
-%
-% 2) Find all AOs for ChannelX and ChannelY on 1st May 2007 submitted by
-%    hewitson
-%
-%    pl = plist('hostname', 'localhost', 'database', 'ltpda_test', ...
-%               'channels', {'channelX'}, ...
-%               'timespan', timespan('2007-05-01 00:00:00', '2007-05-02 00:00:00', ...
-%               'username', 'hewitson');
-%
-%    a = getAOsInTimeSpan(pl);
-%
-% VERSION:     $Id: getAOsInTimeSpan.m,v 1.3 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     25-02-08 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = getAOsInTimeSpan(varargin)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my AO model retrieve_in_timespan');
-  % Collect input ao's, plist's and ao variable names
-  in_names = {};
-  for ii = 1:nargin
-    in_names{end+1} = inputname(ii);
-  end
-  [pl, pl_invars] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
-
-  % Process the input plist
-  conn     = find(pl, 'conn');
-  hostname = find(pl, 'hostname');
-  database = find(pl, 'database');
-  channels = find(pl, 'channels');
-  tspan    = find(pl, 'timespan');
-  useBinary = find(pl, 'binary');
-
-  % Check inputs
-  if isempty(hostname) || ~ischar(hostname)
-    if isempty(conn) || ~isa(conn, 'database')
-      error(sprintf('### Plist should contain ''hostname'' and ''database'' parameters,\n or a ''conn'' parameter.'));
-    end
-  end
-  if isempty(database) || ~ischar(database)
-    if isempty(conn) || ~isa(conn, 'database')
-      error(sprintf('### Plist should contain ''hostname'' and ''database'' parameters,\n or a ''conn'' parameter.'));
-    end
-  end
-  if isempty(channels)
-    error('### Plist should contain a ''channels'' parameter.');
-  end
-  if isempty(tspan) || ~isa(tspan, 'timespan')
-    error('### Plist should contain a ''timespan'' parameter.');
-  end
-
-  % Check the channels value is a cell
-  if ~iscell(channels)
-    channels = {channels};
-  end
-
-  % Get a connection to the database
-  iConnected = 0;
-  if ~isa(conn, 'database')
-    % then we connect
-    try
-      conn = utils.mysql.connect(hostname, database);
-      iConnected = 1;
-    catch
-      error('### Failed to connect to server: %s/%s', hostname, database);
-    end
-  end
-
-  % Collect the data
-  try
-    aout =  hlq(conn, channels, tspan, useBinary);
-  catch
-    lasterr
-    % Do we need to close database connection?
-    if iConnected
-      close(conn);
-    end
-    error('### Error retrieving objects.');
-  end
-
-  % Do we need to close database connection?
-  if iConnected
-    close(conn);
-  end
-
-  % set outputs
-  varargout{1} = aout;
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% A prototype for the kind of high-level query functions we might need
-function objsOut = hlq(conn, channels, ts, useBinary)
-
-  % prepare output
-  objsOut = [];
-
-  % Loop over the channels
-  for j=1:length(channels)
-
-    % this channel
-    channel = channels{j};
-
-    % the query
-    q =      ['select objmeta.obj_id from objmeta,ao,tsdata ' ...
-      'where objmeta.obj_id=ao.obj_id ' ...
-      'and ao.data_id=tsdata.id ' ...
-      sprintf('and objmeta.name=''%s''', channel) ...
-      sprintf('and tsdata.t0+INTERVAL tsdata.nsecs SECOND  >= ''%s''', char(ts.startT)) ...
-      sprintf('and tsdata.t0 <= ''%s''', char(ts.endT))];
-
-    % execute query
-    info = utils.mysql.dbquery(conn, q);
-
-    % collect objects
-    if useBinary
-      objs = ltpda_uo.retrieve(conn, 'binary', [info{:}]);
-    else
-      objs = ltpda_uo.retrieve(conn, [info{:}]);
-    end
-    
-    % join these up
-    ojn = join([objs{:}]);
-
-    % split out the bit we want
-    os = split(ojn, plist('split_type', 'interval', 'timespan', ts));
-
-    % add to outputs
-    objsOut = [objsOut os];
-  end % end loop over channels
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Returns the default plist
-function pl = getDefaultPlist(varargin)
-
-  pl = plist('hostname', 'localhost', ...
-    'database', 'ltpda_test',  ...
-    'channels', {'chan1', 'chan2'}, ...
-    'timespan', timespan('1970-01-01 00:00:00', '2010-10-12 12:45:32') ...
-    );
-end
-
-
--- a/m-toolbox/classes/+utils/@mysql/getMD5hash.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-% GETMD5HASH gets the md5 hash string of a given object ID.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETMD5HASH gets the md5 hash string of a given object ID.
-%
-% CALL:        h = getMD5hash(conn, id)
-%
-% VERSION:     $Id: getMD5hash.m,v 1.2 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function h = getMD5hash(conn, id)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  q    = sprintf('select hash from objs where id="%d"', id);
-  curs = exec(conn, q);
-  curs = fetch(curs);
-  h = curs.Data{1};
-  close(curs);
-
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getMaxId.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-% GETMAXID get the maximum Id from the objs table.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETMAXID get the maximum Id from the objs table.
-%
-% CALL:        id = getMaxId()
-%
-% VERSION:     $Id: getMaxId.m,v 1.2 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function id = getMaxId(conn)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  q    = 'select max(id) from objs';
-  curs = exec(conn, q);
-  curs = fetch(curs);
-  id   = curs.Data{1};
-  close(curs);
-
-  if isnan(id)
-    id = 0;
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getObjIds.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-% GETOBJIDS gets a list of object ids from a given collection id.
-%
-% Usage: ids = getObjIds(conn,cid);
-%
-% Inputs:
-%     conn - a database connection object
-%     cid  - a collection id
-%
-% Outputs:
-%     ids  - a list of object ids
-%
-% M Hewitson 30-08-07
-%
-% $Id: getObjIds.m,v 1.2 2010/01/22 12:46:08 ingo Exp $
-%
-
-function ids = getObjIds(conn, cid)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  try
-    curs    = exec(conn, sprintf('select obj_ids from collections where id="%d"', cid));
-    curs    = fetch(curs);
-    ids     = str2num(curs.Data{1});
-    close(curs);
-  catch
-    error('### Unable to determine object IDs from collection ID. Server returned %s', curs.Message);
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getObjType.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-% GETOBJTYPE gets the object type associated with the given object id.
-%
-% Usage: ids = getObjType(conn,id);
-%
-% Inputs:
-%     conn - a database connection object
-%     id   - an object id
-%
-% Outputs:
-%     type - the type of this object
-%
-% M Hewitson 30-08-07
-%
-% $Id: getObjType.m,v 1.2 2010/01/22 12:46:08 ingo Exp $
-%
-
-function type = getObjType(conn, id)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  try
-    curs    = exec(conn, sprintf('select obj_type from objmeta where obj_id="%d"', id));
-    curs    = fetch(curs);
-    type    = curs.Data{1};
-    close(curs);
-  catch
-    warning('!!! Unable to get object type for ID %d. [Server returned: %s]', id, curs.Message);
-    type = '';
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getRepositoryVersion.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-% getRepositoryVersion tries to get the version of the repository by
-% inspecting various fields in the database.
-% 
-% ver = utils.mysql.getRepositoryVersion(conn)
-% 
-% Rules:
-%       objs table contains field 'uuid' => ver = 2.1
-% 
-% else: ver = 2.0;
-% 
-% M Hewitson 11-08-09
-% 
-% $Id: getRepositoryVersion.m,v 1.3 2010/01/22 12:46:08 ingo Exp $
-% 
-
-function ver = getRepositoryVersion(conn)
-  
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  ver = '2.0';
-  
-  q    = ['describe ' conn.Instance '.objs'];
-  curs = exec(conn, q);
-  curs = fetch(curs);
-  
-  if utils.helper.ismember('uuid', curs.Data(:,1))
-    ver = '2.1';
-  end
-  
-  
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getUserID.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-% GETUSERID gets the user ID number corresponding to the given user name.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETUSERID gets the user ID number corresponding to the
-%              user name that connected to the MySQL database.
-%
-% CALL:        userid = getUserID(conn)
-%
-% VERSION:     $Id: getUserID.m,v 1.3 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function [userid,dbuser] = getUserID(conn, username)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-
-  userid = [];
-  try
-    q    = sprintf('select id from users where username="%s"', conn.Username);
-    curs = exec(conn, q);
-    curs = fetch(curs);
-    userid = curs.Data{1};
-    close(curs);
-  catch curs
-    warning('!!! Unable to retrieve user ID. [Server returned: %s]', curs.message);
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getXdoc.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-% GETXDOC retrieves an object with given id from the LTPDA
-% repository specified by the input database connection. The object is
-% converted from its XML text format to an Xdoc. This can then be converted
-% into an object using the appropriate object constructor.
-%
-% Usage: xdoc = getXdoc(conn, id)
-%
-% Inputs:
-%         conn - a database connection object
-%         id   - the object id
-%
-% Outputs:
-%         xdoc - an Xdoc representation of the object.
-%
-% M Hewitson 30-08-07
-%
-% $Id: getXdoc.m,v 1.3 2010/01/22 12:46:08 ingo Exp $
-%
-%
-
-function xdoc = getXdoc(conn, id)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-
-  try
-    curs    = exec(conn, sprintf('select xml from objs where id="%d"', id));
-    curs    = fetch(curs);
-    objTxt  = char([curs.Data{1}].');
-    close(curs);
-  catch
-    error('### Unable to read xml for ID %d. Server returned %s', id, curs.Message);
-  end
-
-  if ~isempty(objTxt) && ~strcmp(objTxt(:), 'No Data')
-    % convert to Java string
-    str = java.lang.String(objTxt);
-    % open stream on this string
-    stream = java.io.StringBufferInputStream(str);
-    % make parser
-    builder = javax.xml.parsers.DocumentBuilderFactory.newInstance.newDocumentBuilder;
-
-    xdoc = builder.parse(stream);
-  else
-    xdoc = [];
-  end
-
-end
-
--- a/m-toolbox/classes/+utils/@mysql/getsinfo.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-% GETSINFO This function returns an sinfo object containing many useful information about an object retrieved from the repository
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% usage:   sinfo = getsinfo(id, conn)
-%
-% inputs:  id    = obj_id from objmeta table
-%          conn  = utils.mysql.connect(server, dbname);
-%
-% outputs: sinfo cell array object containing info about object having the
-%          given obj_id on the repository.
-%          sinfo contains the following fields:
-%          - name
-%          - experiment_title
-%          - experiment_desc
-%          - analysis_desc
-%          - quantity
-%          - additional_authors
-%          - additional_comments
-%          - keywords and reference_ids
-%
-%          A Monsky 05-02-2009
-%
-% version: $Id: getsinfo.m,v 1.6 2011/03/29 13:40:17 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [varargout] = getsinfo(varargin)
-  
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Collect input variable names
-  in_names = cell(size(varargin));
-  for ii = 1:nargin,in_names{ii} = inputname(ii);end
-  
-  % Collect all ids and plists and connections
-  pl = utils.helper.collect_objects(varargin(:), 'plist');
-  id = utils.helper.collect_objects(varargin(:), 'double');
-  conn  = utils.helper.collect_objects(varargin(:), 'database');
-  
-  if isempty(conn)
-    error('### This method needs a MATLAB connection.');
-  end
-  
-  if isempty(id)
-    error('### This method needs at least one object id.');
-  end
-  
-  if nargout == 0
-    error('### lscov can not be used as a modifier method. Please give at least one output');
-  end
-  
-  % combine plists
-  pl = combine(pl, plist());
-  
-  % Algorithm
-  % Get complete experiment information for each input id
-  sinfo = [];
-  for ii=1:length(id)
-    qall = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '...
-      'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ...
-      sprintf('where objmeta.obj_id=%d',id(ii))];
-    
-    infoall = utils.mysql.dbquery(conn, qall);
-    s.conn                    = conn;
-    s.name                    = infoall{1};
-    s.experiment_title        = infoall{2};
-    s.experiment_description  = infoall{3};
-    s.analysis_description    = infoall{4};
-    s.quantity                = infoall{5};
-    s.additional_authors      = infoall{6};
-    s.additional_comments     = infoall{7};
-    s.keywords                = infoall{8};
-    s.reference_ids           = infoall{9};
-    sinfo = [sinfo s];
-  end
-  
-  % Set output
-  varargout{1} = sinfo;
-end
--- a/m-toolbox/classes/+utils/@mysql/insert.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-% INSERT inserts values into a single row of a table using JDBC driver
-% specified by the input connection.
-%
-% Usage: message = insert(conn, table, 'field1', value1, 'field2', value2,...)
-%
-% M Hewitson
-%
-% 31-07-07
-%
-% $Id: insert.m,v 1.6 2010/01/22 12:46:08 ingo Exp $
-%
-
-function message = insert(conn, table, varargin)
-
-  error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-  
-  q = sprintf('INSERT INTO %s SET ',  table);
-  
-  for j=1:2:length(varargin)
-    
-    col = varargin{j};
-    val = varargin{j+1};
-    if isnumeric(val)
-      if ~any(isnan(val))
-        q = [q col '=' num2str(val) ','];
-      end
-    elseif ischar(val)
-      q = [q col '=' '''' val '''' ','];
-    else
-      error('### val class [%s]', class(val))
-    end
-        
-  end
-  
-  q = deblank([q(1:end-1) ';']);
-
-  utils.helper.msg(utils.const.msg.PROC1, 'running query %s', q);
-  
-  try
-    curs = exec(conn, q);
-    message = curs.Message;
-    close(curs);
-  catch
-    error('### insert: failed to execute query: %s\nServer returned %s', q, curs.Message);
-  end
-end
-
--- a/m-toolbox/classes/+utils/@mysql/logindlg.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-function [varargout]=logindlg(varargin)
-   % LOGINDLG   Dialog for visually secure login.
-   %
-   % Author: Jeremy Smith
-   % Date: September 24, 2005
-   % Last Edit: July 7, 2006
-   % Version: 1.2
-   % Tested on: Matlab 7.0.4.365 (R14) Service Pack 2 and Matlab 7.1 SP 3
-   % Description: custom login dialog because Matlab doesn't have an option
-   %       for characters in an edit field to be replaced by asterixes
-   %       (password security)
-   %
-   % =======================================================================
-   % ============== UPDATED FOR USE WITH LTPDA PACKAGE =====================
-   % =======================================================================
-   %
-   % The function now has a fixed supported syntax to call:
-   %          [login password] = loginLTPDA('userID','password')
-   % or
-   %          [login password] = loginLTPDA('','')
-   %
-   % It will only accept 2 string inputs and it will provide 2 string
-   % outputs.
-   % If 2 empty strings are passed the edit fields will be empty, otherwise
-   % they'll show as defaults the strings passed.
-   %
-   %   $Id: logindlg.m,v 1.4 2010/01/22 12:46:08 ingo Exp $
-
-   error('### Obsolete as of LTPDA version 2.2. Replaced my the utils class jmysql (utils.jmysql.%s)', mfilename());
-   
-   Login    = varargin{1};
-   password = varargin{2};
-   for i=1:numel(password), passwordHidden(i)='*'; end
-   if ~exist('passwordHidden','var'), passwordHidden = ''; end
-
-   set(0,'Units','pixels')
-   Screen = get(0,'screensize');
-   loginSize = [230 130];
-   Position = [(Screen(3)-loginSize(1))/2 (Screen(4)-loginSize(2))/2 loginSize];
-
-
-   % Create the GUI
-   gui.main = dialog('HandleVisibility','on',...
-      'Color','white',...
-      'IntegerHandle','off',...
-      'Menubar','none',...
-      'Name','LTPDA Login',...
-      'NumberTitle','off',...
-      'Name','Login',...
-      'Tag','logindlg',...
-      'Units','pixels',...
-      'Userdata','logindlg',...
-      'Position',Position);
-
-   set(gui.main,'Closerequestfcn',{@Cancel,gui.main},'Keypressfcn',{@Escape,gui.main})
-
-   FONTSIZE = 12;
-   
-   % Texts
-   gui.login_text = uicontrol(gui.main,'Style','text','BackgroundColor','white','FontSize',FONTSIZE,'HorizontalAlign','center','Units','pixels','String','Login','Position',[0 105 Position(3) 20]);
-   gui.password_text = uicontrol(gui.main,'Style','text','BackgroundColor','white','FontSize',FONTSIZE,'HorizontalAlign','center','Units','pixels','String','Password','Position',[0 60 Position(3) 20]);
-
-   % Edits
-   gui.edit1 = uicontrol(gui.main,'Tag','userid','Style','edit','FontSize',FONTSIZE,'HorizontalAlign','center','BackgroundColor','white','Units','pixels','String',Login,'KeyPressfcn',{@KeyPress_Func2,gui.main},'Position',[5 85 Position(3)-10 24],'Userdata',0);
-   gui.edit2 = uicontrol(gui.main,'Tag','password','Style','edit','FontSize',FONTSIZE,'HorizontalAlign','center','BackgroundColor','white','Units','pixels','String',passwordHidden,'Position',[5 40 Position(3)-10 24],'KeyPressfcn',{@KeyPress_Function,gui.main},'Userdata',password);
-
-   % Buttons
-   buttonSize = [75 26];
-   gui.OK = uicontrol(gui.main,'Style','push','FontSize',FONTSIZE,'Units','pixels','String','OK','Position',[Position(3)/2-buttonSize(1)-1 5 buttonSize],'KeyPressFcn',{@OKReturn,gui.main},'Callback',{@OK,gui.main});
-   gui.Cancel = uicontrol(gui.main,'Style','push','FontSize',FONTSIZE,'Units','pixels','String','Cancel','Position',[Position(3)/2+1 5 buttonSize],'KeyPressFcn',{@CancelReturn,gui.main},'Callback',{@Cancel,gui.main});
-
-   % Images
-   logosize = [31,31];
-   dimension = [5 3 logosize];
-   logo = axes('Parent',gui.main,'Units','pixels','Position',dimension);
-   image(imread('buttonyes.jpg'),'Parent',logo);
-   axis(logo,'off');
-   logosize = [31,31];
-   dimension = [Position(3)-logosize(1)-5 3 logosize];
-   logo = axes('Parent',gui.main,'Units','pixels','Position',dimension);
-   image(imread('buttonno.jpg'),'Parent',logo);
-   axis(logo,'off');
-   
-   setappdata(0,'logindlg',gui) % Save handle data
-   setappdata(gui.main,'Check',0) % Error check setup. If Check remains 0 an empty cell array will be returned
-
-   uicontrol(gui.edit1) % Make the first edit box active
-   % uicontrol(gui.OK) % Make the OK button active
-
-   % Pause the GUI and wait for a button to be pressed
-   uiwait(gui.main)
-   
-   try if varargin{3}, welcome2LTPDA(varargin{4},varargin{5}); pause(1); end; catch end
-
-   Check = getappdata(gui.main,'Check'); % Check to see if a button was pressed
-
-   % Format output
-   if Check == 1
-      Login = get(gui.edit1,'String');
-      Password = get(gui.edit2,'Userdata');
-
-      varargout(1) = {Login};
-      varargout(2) = {Password};
-   else % If OK wasn't pressed output empty fields
-      varargout(1) = {''};
-      varargout(2) = {''};
-   end
-
-   delete(gui.main) % Close the GUI
-   setappdata(0,'logindlg',[]) % Erase handles from memory
-
-   %% Hide Password
-function KeyPress_Function(h,eventdata,fig)
-   % Function to replace all characters in the password edit box with
-   % asterixes
-   password = get(h,'Userdata');
-   key = get(fig,'currentkey');
-
-   switch key
-      case 'backspace'
-         password = password(1:end-1); % Delete the last character in the password
-      case 'return'  % This cannot be done through callback without making tab to the same thing
-         gui = getappdata(0,'logindlg');
-         OK([],[],gui.main);
-      case 'tab'  % Avoid tab triggering the OK button
-         gui = getappdata(0,'logindlg');
-         uicontrol(gui.OK);
-      otherwise
-         password = [password get(fig,'currentcharacter')]; % Add the typed character to the password
-   end
-
-   SizePass = size(password); % Find the number of asterixes
-   if SizePass(2) > 0
-      asterix(1,1:SizePass(2)) = '*'; % Create a string of asterixes the same size as the password
-      set(h,'String',asterix) % Set the text in the password edit box to the asterix string
-   else
-      set(h,'String','')
-   end
-
-   set(h,'Userdata',password) % Store the password in its current state
-
-function KeyPress_Func2(h,eventdata,fig)
-   % To check whenever the user press Enter
-   if ~isempty(get(fig,'CurrentCharacter')) && real(get(fig,'CurrentCharacter'))==13 && get(h,'UserData')==0
-      setappdata(fig,'Check',1)
-      uiresume(fig)
-   elseif real(get(fig,'CurrentCharacter'))==13
-      uicontrol(findobj(gcf,'Tag','password'))
-   else
-      set(h,'UserData',1)
-   end
-
-   %% Cancel
-function Cancel(h,eventdata,fig)
-   uiresume(fig)
-
-   %% OK
-function OK(h,eventdata,fig)
-   % Set the check and resume
-   setappdata(fig,'Check',1)
-   uiresume(fig)
-
-function CancelReturn(h,eventdata,fig)
-   if real(get(fig,'CurrentCharacter'))==13
-      uiresume(fig)
-   end
-
-   %% OK
-function OKReturn(h,eventdata,fig)
-   % Set the check and resume
-   if real(get(fig,'CurrentCharacter'))==13
-      setappdata(fig,'Check',1)
-      uiresume(fig)
-   end
-
-   %% Escape
-function Escape(h,eventdata,fig)
-   % Close the login if the escape button is pushed and neither edit box is
-   % active
-   key = get(fig,'currentkey');
-
-   if isempty(strfind(key,'escape')) == 0 && h == fig
-      Cancel([],[],fig)
-   end
\ No newline at end of file
--- a/m-toolbox/classes/+utils/@mysql/mysql.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/+utils/@mysql/mysql.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,73 +1,11 @@
-% MYSQL class for tools to manipulate the current object/figure/axis.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: MYSQL class for tools to manipulate the current
-%              object/figure/axis.
-%
-% MYSQL METHODS:
-%
-%     Static methods:
-%       yticks      - Set the input vector as the y-ticks of the current axis
-%       %%% GENERAL TOOLS
-%       logindlg          - creates a login dialog box.
-%       dbquery           - query an AO repository database.
-%       getAOsInTimeSpan  - performs high-level queries to retrieve AOs from
-%                           a LTPDA repository.
-%       insert            - inserts values into a single row of a table using
-%                           JDBC driver specified by the input connection.
-%
-%       %%% MYSQL TOOLS
-%       connect           - connects to an LTPDA repository and returns
-%                           the connection object.
-%       getMaxId          - get the maximum Id from the objs table.
-%       getMD5hash        - gets the md5 hash string of a given object ID.
-%       getObjIds         - gets a list of object ids from a given collection id.
-%       getObjType        - gets the object type associated with the given object id.
-%       getUserID         - gets the user ID number corresponding to the given
-%                           user name.
-%       getXdoc           - retrieves an object with given id from the
-%                           LTPDA repository
-%
-% HELP:        To see the available static methods, call
-%              >> methods utils.mysql
-%
-% HISTORY:     26-05-2008 Diepholz
-%                 Creation
-%
-% VERSION:     $Id: mysql.m,v 1.3 2009/08/11 12:02:46 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+classdef mysql
+% UTILS.MYSQL  MySQL database utilities.
 
-classdef mysql
-
-  %------------------------------------------------
-  %--------- Declaration of Static methods --------
-  %------------------------------------------------
   methods (Static)
 
-    %-------------------------------------------------------------
-    % List other methods
-    %-------------------------------------------------------------
+    conn = connect(hostname, database, username, password);
+    varargout = execute(conn, query, varargin);
 
-    %%% GENERAL TOOLS
-	varargout = getsinfo(varargin) % return sinfo structure of repository object
-    varargout = logindlg(varargin) % creates a login dialog box.
-    varargout = dbquery(varargin)  % query an AO repository database.
-    varargout = getAOsInTimeSpan(varargin) % performs high-level queries to retrieve AOs from an LTPDA repository.
-    message   = insert(conn, table, varargin) % inserts values into a single row of a table using JDBC driver specified by the input connection.
-    varargout = getRepositoryVersion(varargin);
-    
-    
-    %%% MYSQL TOOLS
-    varargout = connect(varargin) % connects to an LTPDA repository and returns the connection object.
-    id   = getMaxId(conn)         % get the maximum Id from the objs table.
-    h    = getMD5hash(conn, id)   % gets the md5 hash string of a given object ID.
-    ids  = getObjIds(conn, cid)   % gets a list of object ids from a given collection id.
-    type = getObjType(conn, id)   % gets the object type associated with the given object id.
-    [userid,dbuser] = getUserID(conn, username) % gets the user ID number corresponding to the given user name.
-    xdoc = getXdoc(conn, id)      % retrieves an object with given id from the LTPDA repository
-
-  end % End static methods
+  end % static methods
 
 end
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/adjustPlist.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,37 @@
+function adjustPlist(conn, pl)
+% ADJUSTPLIST(CONN, PL) Removes CONN, USERNAME, PASSWORD parameters
+% from plist PL, and adds or or substitutes HOSTNAME and DATABASE
+% parameters with the ones used to establish connection CONN.
+%
+% The resulting plist may be used to set object history.
+
+  % check parameters
+  if ~isa(conn, 'java.sql.Connection')
+    error('### invalid call');
+  end
+  if ~isa(pl, 'plist')
+    error('### invalid call');
+  end
+
+  % get connection parameters
+  r = '^jdbc:mysql://(?<hostname>.+)/(?<database>.+)$';
+  c = regexp(char(conn.getMetaData().getURL()), r, 'names');
+
+  % remove unwanted parameters
+  prem(pl, 'conn');
+  prem(pl, 'username');
+  prem(pl, 'password');
+
+  % add essentials connections parameters
+  pset(pl, 'hostname', c.hostname);
+  pset(pl, 'database', c.database);
+
+end
+
+
+function prem(pl, key)
+% PREM Remove parameter KEY if present in plist PL.
+  if isparam(pl, key)
+    remove(pl, key);
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/getCollectionIDs.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,26 @@
+function ids = getCollectionIDs(conn, cid)
+% GETCOLLECTIONIDS  Return the IDs of the object composing a collection.
+%
+% CALL:
+%
+%   ids = utils.repository.getCollectionIDs(conn, cid)
+%
+% PARAMETERS:
+%
+%   CONN   database connection implementing java.sql.Connection
+%   CID    collection id
+%
+
+  rows = utils.mysql.execute(conn, 'SELECT nobjs, obj_ids FROM collections WHERE id = ?', cid);
+  if isempty(rows)
+    error('### collection %d not found', cid);
+  end
+  nobjs = rows{1};
+  ids = strread(rows{2}, '%d', 'delimiter', ',');
+  if length(ids) ~= nobjs
+    error('### inconsistent collection description');
+  end
+  % transform column vector in row vector
+  ids = ids';
+  
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/getObjectType.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,20 @@
+function type = getObjectType(conn, id)
+% GETOBJECTTYPE  Return the type of the object.
+%
+% CALL:
+%
+%   ids = utils.repository.getObjectType(conn, cid)
+%
+% PARAMETERS:
+%
+%   CONN   database connection implementing java.sql.Connection
+%   ID     object id
+%
+
+  rows = utils.mysql.execute(conn, 'SELECT obj_type FROM objmeta WHERE obj_id = ?', id);
+  if isempty(rows)
+    error('### object %d not found', id);
+  end
+  type = rows{1};
+  
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/getUser.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,20 @@
+function [username, userid] = getUser(conn)
+% GETUSER  Return username and userid of the current database user.
+%
+% CALL:
+%
+%   [username, userid] = utils.repository.getUser(conn)
+%
+
+  % current database user
+  rows = utils.mysql.execute(conn, 'SELECT SUBSTRING_INDEX(USER(),''@'',1)');
+  username = rows{1};
+
+  % userid
+  rows = utils.mysql.execute(conn, 'SELECT id FROM users WHERE username = ?', username);
+  if isempty(rows)
+    error('### could not determine user id');
+  end
+  userid = rows{1};
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/insertObjMetadata.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,124 @@
+function insertObjMetadata(conn, obj, objid)
+% an utility to insert entries for various object metadata in the
+% corresponding tables. differs from insertObjMetadataV1() by
+% the use of the new v3.0 database structure
+%
+% MUST BE KEPT IN SYNC WITH updateObjMetadata()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+% VERSION:     $Id: insertObjMetadata.m,v 1.9 2011/11/09 18:45:14 mauro Exp $
+%
+
+  import utils.const.*
+
+  if nargin < 3
+    error('### incorrect usage');
+  end
+  if ~isjava(conn)
+    error('### incorrect usage');
+  end
+
+  % class of object
+  cl = class(obj);
+  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
+
+  switch cl
+    case 'ao'
+
+      % call recursively to insert the data object info
+      utils.repository.insertObjMetadata(conn, obj.data, objid);
+
+      % insert the AO info
+      stmt = conn.prepareStatement(...
+        'INSERT INTO ao (obj_id, data_type, description) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(class(obj.data)));
+      
+      desc = obj.description;
+      if length(desc)>65535
+        warning('Object description length exceeded. Truncating to 65535 characters');
+        desc = desc(1:65535);
+      end
+      stmt.setObject(3, java.lang.String(desc));
+      stmt.execute();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO cdata (obj_id, yunits) VALUES (?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.execute();
+      stmt.close();
+
+    case 'fsdata'
+
+      % possible bad entries
+      fs = obj.fs;
+      if ~isfinite(fs)
+        fs = [];
+      end
+        
+      stmt = conn.prepareStatement(...
+        'INSERT INTO fsdata (obj_id, xunits, yunits, fs) VALUES (?, ?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.xunits)));
+      stmt.setObject(3, java.lang.String(char(obj.yunits)));
+      stmt.setObject(4, fs);
+      stmt.execute();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO tsdata (obj_id, xunits, yunits, fs, t0, nsecs, toffset) VALUES (?, ?, ?, ?, ?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.xunits)));
+      stmt.setObject(3, java.lang.String(char(obj.yunits)));
+      stmt.setObject(4, obj.fs);
+      stmt.setObject(5, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
+      stmt.setObject(6, obj.nsecs);
+      stmt.setObject(7, obj.toffset);
+      stmt.execute();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO xydata (obj_id, xunits, yunits) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.xunits)));
+      stmt.setObject(3, java.lang.String(char(obj.yunits)));
+      stmt.execute();
+      stmt.close();
+
+    case 'mfir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    case 'miir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    otherwise
+      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
+
+  end
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/insertObjMetadataV1.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,142 @@
+function id = insertObjMetadataV1(conn, obj, objid)
+% an utility to insert entries for various object metadata in the
+% corresponding tables. uses the old v2.1 database schema.
+%
+% MUST BE KEPT IN SYNC WITH updateObjMetadataV1()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+
+  import utils.const.*
+
+  if nargin < 3
+    error('### incorrect usage');
+  end
+  if ~isjava(conn)
+    error('### incorrect usage');
+  end
+
+  % default output value
+  id = [];
+
+  % class of object
+  cl = class(obj);
+  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
+
+  switch cl
+    case 'ao'
+
+      % call recursively to insert the data object info
+      dataid = utils.repository.insertObjMetadataV1(conn, obj.data, objid);
+
+      % insert the AO info
+      stmt = conn.prepareStatement(...
+        'INSERT INTO ao (obj_id, data_type, data_id, description) VALUES (?, ?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(class(obj.data)));
+      stmt.setObject(3, dataid);
+      desc = obj.description;
+      if length(desc)>65535
+        warning('Object description length exceeded. Truncating to 65535 characters');
+        desc = desc(1:65535);
+      end
+      stmt.setObject(4, java.lang.String(desc));
+      stmt.execute();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO cdata (yunits) VALUES (?)');
+      stmt.setObject(1, java.lang.String(char(obj.yunits)));
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'fsdata'
+
+      % possible bad entries
+      fs = obj.fs;
+      if ~isfinite(fs)
+        fs = [];
+      end
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO fsdata (xunits, yunits, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.setObject(3, fs);
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO tsdata (xunits, yunits, fs, t0, nsecs) VALUES (?, ?, ?, ?, ?)');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.setObject(3, obj.fs);
+      stmt.setObject(4, java.lang.String(format(obj.t0, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
+      stmt.setObject(5, obj.nsecs);
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO xydata (xunits, yunits) VALUES (?, ?)');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'mfir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    case 'miir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    otherwise
+      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
+
+  end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/repository.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,18 @@
+classdef repository
+
+  methods (Static)
+
+    adjustPlist(conn, pl);
+    type = getObjectType(conn, id);
+    ids = getCollectionIDs(conn, cid);
+    varargout = getUser(conn);
+
+    varargout = insertObjMetadata(varargin);
+    varargout = insertObjMetadataV1(varargin);
+
+    varargout = updateObjMetadata(varargin);
+    varargout = updateObjMetadataV1(varargin);
+
+  end % static methods
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/updateObjMetadata.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,123 @@
+function updateObjMetadata(conn, obj, objid)
+% an utility to update entries for various object metadata in the
+% corresponding tables. differs from insertObjMetadataV1() by
+% the use of the new v3.0 database structure
+%
+% MUST BE KEPT IN SYNC WITH insertObjMetadata()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+% VERSION:     $Id: updateObjMetadata.m,v 1.7 2011/11/09 18:47:04 mauro Exp $
+%
+
+  import utils.const.*
+
+  if nargin < 3
+    error('### incorrect usage');
+  end
+  if ~isjava(conn)
+    error('### incorrect usage');
+  end
+
+  % class of object
+  cl = class(obj);
+  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
+
+  switch cl
+    case 'ao'
+
+      % call recursively to insert the data object info
+      utils.repository.updateObjMetadata(conn, obj.data, objid);
+
+      % insert the AO info
+      stmt = conn.prepareStatement(...
+        'UPDATE ao SET data_type=?, description=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(class(obj.data)));
+      desc = obj.description;
+      if length(desc)>65535
+        warning('Object description length exceeded. Truncating to 65535 characters');
+        desc = desc(1:65535);
+      end
+      stmt.setObject(2, java.lang.String(desc));
+      stmt.setObject(3, objid);
+      stmt.executeUpdate();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE cdata SET yunits=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(char(obj.yunits)));
+      stmt.setObject(2, objid);
+      stmt.executeUpdate();
+      stmt.close();
+
+    case 'fsdata'
+
+      % possible bad entries
+      fs = obj.fs;
+      if ~isfinite(fs)
+        fs = [];
+      end
+        
+      stmt = conn.prepareStatement(...
+        'UPDATE fsdata SET xunits=?, yunits=?, fs=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.setObject(3, fs);
+      stmt.setObject(4, objid);
+      stmt.executeUpdate();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=?, toffset=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.setObject(3, obj.fs);
+      stmt.setObject(4, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
+      stmt.setObject(5, obj.nsecs);
+      stmt.setObject(6, obj.toffset);
+      stmt.setObject(7, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE xydata SET xunits=?, yunits=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.setObject(3, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'mfir'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE mfir SET in_file=?, fs=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(obj.infile));
+      stmt.setObject(2, obj.fs);
+      stmt.setObject(3, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'miir'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE miir SET in_file=?, fs=? WHERE obj_id = ?');
+      stmt.setObject(1, java.lang.String(obj.infile));
+      stmt.setObject(2, obj.fs);
+      stmt.setObject(3, objid);
+      stmt.execute();
+      stmt.close();
+
+    otherwise
+      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
+
+  end
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/updateObjMetadataV1.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,137 @@
+function id = updateObjMetadataV1(conn, obj, objid)
+% an utility to update entries for various object metadata in the
+% corresponding tables. uses the old v2.1 database schema.
+%
+% MUST BE KEPT IN SYNC WITH insertObjMetadataV1()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+
+  import utils.const.*
+
+  if nargin < 3
+    error('### incorrect usage');
+  end
+  if ~isjava(conn)
+    error('### incorrect usage');
+  end
+
+  % default return value
+  id = [];
+  
+  % class of object
+  cl = class(obj);
+  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
+
+  switch cl
+    case 'ao'
+
+      % get data type and id
+      stmt = conn.prepareStatement(...
+        'SELECT data_id, data_type FROM ao WHERE obj_id = ?');
+      stmt.setObject(1, objid);
+      rs = stmt.executeQuery();
+      rs.next();
+      dataid = rs.getInt(1);
+      datatype = rs.getString(2);
+      rs.close();
+      stmt.close();
+      
+      % check if the data type is consistent
+      if ~strcmp(datatype, class(obj.data))
+        error('### cannot update an object with one having a different data type');
+      end
+        
+      % call recursively to insert the data object info
+      id = utils.repository.updateObjMetadataV1(conn, obj.data, dataid);
+
+      % update ao description
+      stmt = conn.prepareStatement(...
+        'UPDATE ao SET description=? WHERE obj_id = ?');
+      desc = obj.description;
+      if length(desc)>65535
+        warning('Object description length exceeded. Truncating to 65535 characters');
+        desc = desc(1:65535);
+      end
+      stmt.setObject(1, desc);
+      stmt.setObject(2, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE cdata SET yunits=? WHERE id = ?');
+      stmt.setObject(1, char(obj.yunits));
+      stmt.setObject(2, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'fsdata'
+
+      % possible bad entries
+      fs = obj.fs;
+      if ~isfinite(fs)
+        fs = [];
+      end
+        
+      stmt = conn.prepareStatement(...
+        'UPDATE fsdata SET xunits=?, yunits=?, fs=? WHERE id = ?');
+      stmt.setObject(1, char(obj.xunits));
+      stmt.setObject(2, char(obj.yunits));
+      stmt.setObject(3, fs);
+      stmt.setObject(4, objid);      
+      stmt.execute();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=? WHERE id = ?');
+      stmt.setObject(1, char(obj.xunits));
+      stmt.setObject(2, char(obj.yunits));
+      stmt.setObject(3, obj.fs);
+      stmt.setObject(4, format(obj.t0, 'yyyy-mm-dd HH:MM:SS', 'UTC'));
+      stmt.setObject(5, obj.nsecs);
+      stmt.setObject(6, objid);      
+      stmt.execute();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE xydata SET xunits=?, yunits=? WHERE id = ?');
+      stmt.setObject(1, char(obj.xunits));
+      stmt.setObject(2, char(obj.yunits));
+      stmt.setObject(3, objid);      
+      stmt.execute();
+      stmt.close();
+
+    case 'mfir'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE mfir SET in_file=?, fs=? WHERE obj_id = ?');
+      stmt.setObject(1, obj.infile);
+      stmt.setObject(2, obj.fs);
+      stmt.setObject(3, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'miir'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE miir SET in_file=?, fs=? WHERE obj_id = ?');
+      stmt.setObject(1, obj.infile);
+      stmt.setObject(2, obj.fs);
+      stmt.setObject(3, objid);      
+      stmt.execute();
+      stmt.close();
+
+    otherwise
+      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
+
+  end
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@LTPDADatabaseConnectionManager/LTPDADatabaseConnectionManager.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,526 @@
+classdef LTPDADatabaseConnectionManager < handle
+
+  properties(SetAccess=private)
+
+    connections = {};
+    credentials = {};
+    userMessage = [];
+
+  end % private properties
+
+  properties(Dependent=true)
+
+    credentialsExpiry; % seconds
+    cachePassword; % 0=no 1=yes 2=ask
+    maxConnectionsNumber;
+    knownRepositories; % known repositories stored into prefereces
+
+  end % dependent properties
+
+  methods(Static)
+
+    function reset()
+    % RESET Resets the state of the connection manager.
+    %
+    % This static method removes the LTPDADatabaseConnectionManager
+    % instance data from the appdata storage. Causes the reset of the
+    % credentials cache and the removal of all the connections from
+    % the connection pool.
+
+      rmappdata(0, LTPDADatabaseConnectionManager.appdataKey);
+    end
+
+
+    function key = appdataKey()
+    % APPDATAKEY Returns the key used to store instance data in appdata.
+    %
+    % This is defined as static method, and not has an instance constant
+    % property, to to be accessible by the reset static method.
+
+      key = 'LTPDADatabaseConnectionManager';
+    end
+
+  end % static methods
+
+  methods
+
+    function cm = LTPDADatabaseConnectionManager()
+    % LTPDACONNECTIONMANAGER Manages credentials and database connections.
+    %
+    % This constructor returns an handler to a LTPDADatabaseConnectionManager
+    % class instance. Database connections can be obtained trough the
+    % obtained object with the connect() method.
+    %
+    % The purpose of this class it to keep track of open database connections
+    % and to cache database credentials. It must be used in all LTPDA toolbox
+    % functions that required to obtain database connections. Its behaviour can
+    % be configured via LTPDA toolbox user preferences. The object status is
+    % persisted trough the appdata matlab facility.
+
+      % import credentials class
+      import utils.credentials
+
+      % load state from appdata
+      acm = getappdata(0, cm.appdataKey());
+
+      if isempty(acm)
+        % store state in appdata
+        setappdata(0, cm.appdataKey(), cm);
+
+        import utils.const.*
+        utils.helper.msg(msg.PROC1, 'new connection manager');
+      else
+        cm = acm;
+      end
+
+      % add known repositories from preferences
+      repos = cm.knownRepositories;
+      for kk = 1:numel(repos)
+        repo = repos{kk};
+        for jj = 1:3
+          % null empty parameters
+          if isempty(repo{jj})
+            repo{jj} = [];
+          end
+        end
+        cm.add(utils.credentials(repo{:}));
+      end
+
+      % reset user message
+      cm.userMessage = [];
+    end
+
+
+    function str = disp(cm)
+      disp(sprintf('%s()\n', class(cm)));
+    end
+
+
+    function val = get.credentialsExpiry(cm)
+      % obtain from user preferences
+      p = getappdata(0, 'LTPDApreferences');
+      val = double(p.getRepoPrefs().getExpiry());
+    end
+
+
+    function val = get.cachePassword(cm)
+      % obtain from user preferences
+      p = getappdata(0, 'LTPDApreferences');
+      val = double(p.getRepoPrefs().getCachePassword());
+    end
+
+
+    function val = get.maxConnectionsNumber(cm)
+      % obtain from user preferences
+      p = getappdata(0, 'LTPDApreferences');
+      val = double(p.getRepoPrefs().getMaxConnectionsNumber());
+    end
+
+
+    function val = get.knownRepositories(cm)
+      % obtain from user preferences
+      p = getappdata(0, 'LTPDApreferences');
+      val = cell(p.getRepoPrefs().getRepositories().toArray());
+    end
+
+
+    function n = count(cm)
+    % COUNT Returns the number of open connections in the connections pool.
+    %
+    % This method has the side effect of removing all closed connections from
+    % the connections pool, so that the underlying objects can be garbage
+    % collected.
+
+      import utils.const.*
+
+      % find closed connections in the pool
+      mask = false(numel(cm.connections), 1);
+      for kk = 1:numel(cm.connections)
+        if cm.connections{kk}.isClosed()
+          utils.helper.msg(msg.PROC1, 'connection id=%d closed', kk);
+          mask(kk) = true;
+        end
+      end
+
+      % remove them
+      cm.connections(mask) = [];
+
+      % count remainig ones
+      n = numel(cm.connections);
+    end
+
+    function clear(cm)
+    % CLEAR Removes all cached credentials from the connection manager.
+      cm.credentials = {};
+    end
+
+
+    function conn = connect(cm, varargin)
+    % CONNECT Uses provided credential to establish a database connection.
+    %
+    % CONNECT(hostname, database, username, password) Returns an object
+    % implementing the java.sql.Connection interface handing a connection to
+    % the specified database. Any of the parameter is optional. The user will
+    % be queried for the missing information.
+    %
+    % The returned connection are added to a connections pool. When the number
+    % of connections in the pool exceeds a configurable maximum, no more
+    % connection are instantiated. Closed connections are automatically
+    % removed from the pool.
+    %
+    % CONNECT(pl) Works as the above but the parameters are obtained from the
+    % plist object PL. If the 'connection' parameter in the plist contains an
+    % object implementing the java.sql.Connection interface, this object is
+    % returned instead that opening a new connection. In this case the
+    % connection in not added to the connection pool.
+
+      import utils.const.*
+
+      % save current credentials cache
+      cache = cm.credentials;
+
+      % count open connections in the pool
+      count = cm.count();
+
+      % check parameters
+      if numel(varargin) == 1 && isa(varargin{1}, 'plist')
+
+        % extract parameters from plist
+        pl = varargin{1};
+
+        % check if we have a connection parameter
+        conn = find(pl, 'conn');
+        if ~isempty(conn)
+          % check that it implements java.sql.Connection interface
+          if ~isa(conn, 'java.sql.Connection')
+            error('### connection is not valid database connection');
+          end
+          % return this connection
+          return;
+        end
+
+        % otherwise
+        hostname = find(pl, 'hostname');
+        database = find(pl, 'database');
+        username = find(pl, 'username');
+        password = find(pl, 'password');
+
+        % if there is no hostname ignore other parameters
+        if ~ischar(hostname) || isempty(hostname)
+          varargin = {};
+        % if there is no database ignore other parameters
+        elseif ~ischar(database) || isempty(database)
+          varargin = {hostname};
+        % if there is no username ignore other parameters
+        elseif ~ischar(username) || isempty(username)
+          varargin = {hostname, database};
+        % password can not be null but can be an empty string
+        elseif ~ischar(password)
+          varargin = {hostname, database, username};
+        else
+          varargin = {hostname, database, username, password};
+        end
+      end
+
+      % check number of connections
+      if count > cm.maxConnectionsNumber
+        error('### too many open connections');
+      end
+
+      % connect
+      try
+        conn = cm.getConnection(varargin{:});
+
+        % add connection to pool
+        utils.helper.msg(msg.PROC1, 'add connection to pool');
+        cm.connections{end+1} = conn;
+
+      catch ex
+        % restore our copy of the credentials cache
+        utils.helper.msg(msg.PROC1, 'undo cache changes');
+        cm.credentials = cache;
+
+        % hide implementation details
+        ex.throw();
+      end
+    end
+
+
+    function close(cm, ids)
+    % CLOSE Forces connections to be closed.
+    %
+    % In the case bugs in other routines working with database connections
+    % produce orphan connections, this method can be used to force the close
+    % of those connections.
+    %
+    % CLOSE(ids) Closes the connections with the corresponding IDs in the
+    % connections pool. If no ID is given all connections in the pool are
+    % closed.
+
+      if nargin < 2
+        ids = 1:numel(cm.connections);
+      end
+      cellfun(@close, cm.connections(ids));
+
+      % remove closed connections from pool
+      cm.count();
+    end
+
+
+    function add(cm, c)
+    % ADD Adds credentials to the credentials cache.
+    %
+    % This method can be used to initialize or add to the cache, credentials
+    % that will be used in subsequent connections attempts. This method accepts
+    % only credentials in the form of utils.credentials objects.
+
+      % check input arguments
+      if nargin < 2 || ~isa(c, 'utils.credentials')
+        error('### invalid call');
+      end
+
+      % add to the cache
+      cm.cacheCredentials(c);
+    end
+
+  end % methods
+
+  methods(Access=private)
+
+    function conn = getConnection(cm, varargin)
+    % GETCONNECTION Where the implementation of the connect method really is.
+
+      import utils.const.*
+
+      % handle variable number of arguments
+      switch numel(varargin)
+        case 0
+          % find credentials
+          [hostname, database, username] = cm.selectDatabase([cm.credentials{:}]);
+          conn = cm.getConnection(hostname, database, username);
+
+        case 1
+          % find credentials
+          cred = cm.findCredentials(varargin{:});
+          if numel(cred) == 0
+            cred = utils.credentials(varargin{:});
+          end
+          [hostname, database, username] = cm.selectDatabase(cred);
+          conn = cm.getConnection(hostname, database, username);
+
+        case 2
+          % find credentials
+          cred = cm.findCredentials(varargin{:});
+          switch numel(cred)
+            case 0
+              conn = cm.getConnection(varargin{1}, varargin{2}, []);
+            case 1
+              conn = cm.getConnection(cred.hostname, cred.database, cred.username);
+            otherwise
+              [hostname, database, username] = cm.selectDatabase(cred);
+              conn = cm.getConnection(hostname, database, username);
+          end
+
+        case 3
+          % find credentials
+          cred = cm.findCredentials(varargin{1}, varargin{2}, varargin{3});
+          if numel(cred) == 0
+            % no credentials found
+            usernames = { varargin{3} };
+            if isempty(varargin{3})
+              % use usernames for same hostname
+              tmp = cm.findCredentials(varargin{1});
+              if ~isempty(tmp)
+                usernames = { tmp(:).username };
+              end
+            end
+            % build credentials objects
+            tmp = {};
+            for kk = 1:numel(usernames)
+              tmp{kk} = utils.credentials(varargin{1}, varargin{2}, usernames{kk});
+            end
+            % convert from cell array to array
+            cred = [tmp{:}];
+          else
+            % credentials in cache
+            utils.helper.msg(msg.PROC1, 'use cached credentials');
+          end
+
+          cache = false;
+          if (numel(cred) > 1) || ~cred.complete
+            % ask for password
+            [username, password, cache] = cm.inputCredentials(cred, cm.userMessage);
+
+            % cache credentials
+            cred = utils.credentials(varargin{1}, varargin{2}, username);
+            cm.cacheCredentials(cred);
+
+            % add password to credentials
+            cred.password = password;
+          end
+
+          % try to connect
+          try
+            conn = utils.mysql.connect(cred.hostname, cred.database, cred.username, cred.password);
+          catch ex
+            % look for access denied errors
+            if strcmp(ex.identifier, 'utils:mysql:connect:AccessDenied')
+              % ask for new new credentials
+              utils.helper.msg(msg.IMPORTANT, ex.message);
+              cm.userMessage = 'Authentication error!';
+              conn = cm.getConnection(varargin{1}, varargin{2}, varargin{3});
+            else
+              % error out
+              throw(ex);
+            end
+          end
+
+          % cache password
+          if cache
+            utils.helper.msg(msg.PROC1, 'cache password');
+            cm.cacheCredentials(cred);
+          end
+
+        case 4
+          % connect
+          conn = utils.mysql.connect(varargin{1}, varargin{2}, varargin{3}, varargin{4});
+
+          if cm.cachePassword == 1
+            % cache credentials with password
+            cred = utils.credentials(varargin{1}, varargin{2}, varargin{3}, varargin{4});
+          else
+            % cache credentials without password
+            cred = utils.credentials(varargin{1}, varargin{2}, varargin{3});
+          end
+          cm.cacheCredentials(cred);
+
+        otherwise
+          error('### invalid call')
+      end
+
+    end
+
+
+    function ids = findCredentialsId(cm, varargin)
+    % FINDCREDENTIALSID Find credentials in the cache and returns their IDs.
+
+      import utils.const.*
+      ids = [];
+
+      for kk = 1:numel(cm.credentials)
+        % invalidate expired passwords
+        if expired(cm.credentials{kk})
+          utils.helper.msg(msg.PROC1, 'cache entry id=%d expired', kk);
+          cm.credentials{kk}.password = [];
+          cm.credentials{kk}.expiry = 0;
+        end
+
+        % match input with cache
+        if match(cm.credentials{kk}, varargin{:})
+          ids = [ ids kk ];
+        end
+      end
+    end
+
+
+    function cred = findCredentials(cm, varargin)
+    % FINDCREDENTIALS Find credentials in the cache and returns them in a list.
+
+      % default
+      cred = [];
+
+      % search
+      ids = findCredentialsId(cm, varargin{:});
+
+      % return a credentials objects array
+      if ~isempty(ids)
+        cred = [cm.credentials{ids}];
+      end
+    end
+
+
+    function cacheCredentials(cm, c)
+    % CACHECREDENTIALS Adds to or updates the credentials cache.
+
+      import utils.const.*
+
+      % find entry to update
+      ids = findCredentialsId(cm, c.hostname, c.database, c.username);
+
+      % set password expiry time
+      if ischar(c.password)
+        c.expiry = double(time()) + cm.credentialsExpiry;
+      end
+
+      if isempty(ids)
+        % add at the end
+        utils.helper.msg(msg.PROC1, 'add cache entry %s', char(c));
+        cm.credentials{end+1} = c;
+      else
+        for id = ids
+          % update only if the cached informations are less than the one we have
+          if length(c) > length(cm.credentials{id})
+            utils.helper.msg(msg.PROC1, 'update cache entry id=%d %s', id, char(c));
+            cm.credentials{id} = c;
+          else
+            % always update expiry time
+            cm.credentials{id}.expiry = c.expiry;
+          end
+        end
+      end
+    end
+
+
+    function [username, password, cache] = inputCredentials(cm, cred, msg)
+    % INPUTCREDENTIALS Queries the user for database username and password.
+
+      % msg is an optional argument
+      if nargin < 3
+        msg = [];
+      end
+
+      % build a cell array of usernames
+      users = {};
+      for id = 1:numel(cred)
+        if ~isempty(cred(id).username)
+          users = [ users { cred(id).username } ];
+        end
+      end
+      users = sort(unique(users));
+
+      parent = com.mathworks.mde.desk.MLDesktop.getInstance().getMainFrame();
+      dialog = javaObjectEDT('connectionmanager.CredentialsDialog', ...
+          parent, cred(1).hostname, cred(1).database, users, cm.cachePassword, msg);
+      dialog.show();
+      if dialog.cancelled
+        throw(MException('utils:mysql:connect:UserCancelled', '### user cancelled'));
+      end
+      username = char(dialog.username);
+      password = char(dialog.password);
+      cache    = logical(dialog.cache);
+    end
+
+
+    function [hostname, database, username] = selectDatabase(cm, credentials)
+    % SELECTDATABASE Makes the user choose to which database connect to.
+
+      parent = com.mathworks.mde.desk.MLDesktop.getInstance().getMainFrame();
+      dialog = javaObjectEDT('connectionmanager.DatabaseSelectorDialog', parent);
+      for c = credentials
+        dialog.add(c.hostname, c.database, c.username);
+      end
+      dialog.show();
+      if dialog.cancelled
+        throw(MException('utils:mysql:connect:UserCancelled', '### user cancelled'));
+      end
+      hostname = char(dialog.hostname);
+      database = char(dialog.database);
+      username = char(dialog.username);
+      if isempty(username)
+        username = [];
+      end
+    end
+
+  end % private methods
+
+end % classdef
--- a/m-toolbox/classes/@LTPDARepositoryManager/LTPDARepositoryManager.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-% LTPDARepositoryManager creates the LTPDA Repository Manager.
-%
-% CALL:
-%         >> LTPDARepositoryManager
-%
-% M Hewitson 08-01-10
-%
-% $Id: LTPDARepositoryManager.m,v 1.14 2011/02/03 13:46:23 ingo Exp $
-%
-
-
-classdef LTPDARepositoryManager < handle
-  %------------------------------------------------
-  %---------- Private read-only Properties --------
-  %------------------------------------------------
-  properties (SetAccess = private, GetAccess = public)
-    manager         = [];
-    gui             = [];
-    selector        = [];
-    timerDisconnect = [];
-    timerClearPass  = [];
-    h1;
-    h2;
-    h3;
-    h4;
-    h5;
-    h6;
-    h7;
-    h8;
-    h9;
-  end
-  
-  properties (Constant = true, GetAccess = private)
-    DISCONNECT = 60;
-  end
-  
-  %-----------------------------------------
-  %  Public methods
-  %-----------------------------------------
-  methods
-    
-    %-----------------------------------------
-    %  Constructor
-    %-----------------------------------------
-    function wb = LTPDARepositoryManager(varargin)
-      
-      twb = getappdata(0, 'LTPDARepositoryManager');
-      
-      if isa(twb, mfilename)
-        
-        wb = twb;
-        
-      else
-        
-        switch nargin
-          case 0
-            % Create a new repository manager
-            wb.manager = mpipeline.repository.RepositoryManager();
-            % Create timer which disconnects the open connections
-            wb.timerDisconnect = LTPDARepositoryManager.startTimer('LTPDA_disconnectConnections', @LTPDARepositoryManager.cb_timerDisconnect, wb.DISCONNECT);
-            % Create timer which clears the password
-            prefs = getappdata(0, 'LTPDApreferences');
-            expiry = double(prefs.getRepoPrefs.getExpiry);
-            wb.timerClearPass = LTPDARepositoryManager.startTimer('LTPDA_clearPassword', @LTPDARepositoryManager.cb_timerClearPassord, expiry);
-            pause(0.1);
-        end
-        
-        % Store the manager in the application workspace
-        setappdata(0, 'LTPDARepositoryManager', wb);
-        
-        wb.updatePrefs();
-        
-      end
-    end % End constructor
-    
-    %-----------------------------------------
-    %  Destructor
-    %-----------------------------------------
-    function delete(h)
-      disp('*** Deleting repository manager')
-      if ~isempty(h)
-        disp('  - closing repository connections')
-        h.manager.closeAllConnections();
-        h.deleteTimer('timerClearPass');
-        h.deleteTimer('timerDisconnect');
-        % close gui
-        if ~isempty(h.gui)
-          h.gui.dispose();
-        end
-      end
-    end
-    
-    
-    function initGUI(wb)
-      
-      % Create a new GUI
-      wb.gui     = mpipeline.repository.RepositoryManagerGUI([], wb.manager);
-      % Create new selector
-      wb.selector = mpipeline.repository.ConnectionSelector([], wb.manager);
-      
-      %--- called when window is closed
-      wb.h1 = handle(wb.gui, 'callbackproperties');
-      wb.h1.WindowClosedCallback = @LTPDARepositoryManager.cb_guiClosed;
-      
-      
-    end
-    
-  end % End public methods
-  
-  methods
-    varargout = display(varargin)
-    varargout = updatePrefs(varargin)
-    varargout = restartTimers(varargin)
-    varargout = showGui(varargin)
-    varargout = listConnections(varargin)
-    
-    varargout = deleteTimer(varargin)
-  end
-  
-  methods (Static=true)
-    
-    % Callback methods
-    varargout = cb_timerDisconnect(varargin)
-    varargout = cb_timerClearPassord(varargin)
-    varargout = cb_newConnection(varargin)
-    varargout = cb_guiClosed(varargin)
-    
-    % Timer methods
-    varargout = startTimer(varargin)
-    varargout = resetTimer(varargin)
-    
-    % Helper Methods
-    varargout = getSinfo(varargin)
-    varargout = executeQuery(varargin)
-    varargout = copyObjects(varargin)
-    
-    function ii = getInfo(varargin)
-      ii = utils.helper.generic_getInfo(varargin{:}, 'LTPDARepositoryManager');
-    end
-    
-    % Return the plist for a particular parameter set
-    function out = getDefaultPlist(set)
-      out = plist();
-    end
-    
-    function out = VEROUT()
-      out = '$Id: LTPDARepositoryManager.m,v 1.14 2011/02/03 13:46:23 ingo Exp $';
-    end
-    
-    function out = SETS()
-      out = {'Default'};
-    end
-    
-    function obj = initObjectWithSize(n,m)
-      obj = LTPDARepositoryManager.newarray([n m]);
-    end
-    
-  end
-  %------------------------------------------------
-  % Private static methods
-  %------------------------------------------------
-  methods(Access=private, Static=true)
-  end
-  
-end
-
--- a/m-toolbox/classes/@LTPDARepositoryManager/addConnection.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-% ADDCONNECTION adds a new managed connection to the repository manager.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: addconnection adds a new managed connection to the
-%              repository manager.
-%              this method still adds a new connection. it doesn't open by
-%              default the connection and for this reason it is not
-%              necessary to define a password yet.
-%
-% call:        conn = rm.addconnection(pl);
-%              conn = rm.addconnection('hostname');
-%              conn = rm.addconnection('hostname', 'database');
-%              conn = rm.addconnection('hostname', 'database', 'username');
-%              conn = rm.addconnection('hostname', 'database', 'username', 'password');
-%
-% <a href="matlab:web(ltpdarepositorymanager.getinfo('addconnection').tohtml, '-helpbrowser')">parameter sets</a>
-%
-% version:    $Id: addConnection.m,v 1.6 2011/03/28 12:45:44 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = addConnection(varargin)
-  
-  % check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getinfo(varargin{3});
-    return
-  end
-  
-  import utils.const.*
-  utils.helper.msg(utils.const.msg.MNAME , 'running %s/%s', mfilename('class'), mfilename);
-  
-  % get the repository manager - there should only be one!
-  [rm, invars, rest] = utils.helper.collect_objects(varargin(:), 'LTPDARepositoryManager');
-  
-  % collect all plists
-  [pl, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
-  
-  pl = combine(pl, getdefaultplist);
-  hostname = pl.find('hostname');
-  database = pl.find('database');
-  username = pl.find('username');
-  password = pl.find('password');
-  autoconnect = pl.find('connect');
-  
-  % check through 'rest'
-  if numel(rest) > 0
-    hostname = rest{1};
-  end
-  if numel(rest) > 1
-    database = rest{2};
-  end
-  if numel(rest) > 2
-    username = rest{3};
-  end
-  if numel(rest) > 3
-    password = rest{4};
-  end
-  
-  conn = mpipeline.repository.RepositoryConnection([]);
-  conn.setHostname(hostname);
-  conn.setDatabase(database);
-  conn.setUsername(username);
-  conn.setPassword(password);
-  
-  if ~isempty(password) && autoconnect
-    conn.openconnection();
-  end
-  
-  rm.manager.addConnection(conn);
-  if ~isempty(rm.gui)
-    rm.gui.reloadConnectionTable();
-  end
-  
-  if nargout == 1
-    varargout{1} = conn;
-  end
-  
-end
-
-%--------------------------------------------------------------------------
-% get info object
-%--------------------------------------------------------------------------
-function ii = getinfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'none')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'default'};
-    pl   = getdefaultplist;
-  end
-  % build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.gui, '$id: psd.m,v 1.53 2009/12/17 08:04:43 mauro exp $', sets, pl);
-end
-
-%--------------------------------------------------------------------------
-% get default plist
-%--------------------------------------------------------------------------
-function pl = getdefaultplist()
-  
-  % initialise plist
-  pl = plist();
-  
-  % hostname
-  p = param({'hostname', 'the hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database
-  p = param({'database', 'the database on the repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username
-  p = param({'username', 'the username to connect with.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % password
-  p = param({'password', 'the password to connect with. leave this empty to be prompted on connection.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % auto connect
-  p = param({'connect', '''true'' or ''false'' if the repository manager should open the connection.'}, paramValue.FALSE_TRUE);
-  pl.append(p);
-  
-end
-
--- a/m-toolbox/classes/@LTPDARepositoryManager/basic_newConnection.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-% basic_newConnection basic method which creates a new connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: basic_newConnection basic method which creates a new
-%              connection.
-%
-% version:     $Id: basic_newConnection.m,v 1.6 2010/08/16 18:04:36 ingo Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = basic_newConnection(rm, dbhost, dbname, dbuser, dbpass)
-  
-  % Build a new connection
-  conn = mpipeline.repository.RepositoryConnection([]);
-  conn.setUsername(dbuser);
-  conn.setPassword(dbpass);
-  conn.setDatabase(dbname);
-  conn.setHostname(dbhost);
-  
-  % Don't show the GUI if the connection have all information
-  if  ~isempty(dbhost) && ...
-      ~isempty(dbname) && ...
-      ~isempty(dbuser)
-    if ~isempty(char(conn.getPassword))
-      conn.openConnection();
-    end
-  else
-    % Open connection GUI
-    prefs = getappdata(0, 'LTPDApreferences');
-    hosts = prefs.getRepoPrefs.getHostnames;
-    
-    % Build connection dialog
-    warning('off', 'MATLAB:JavaEDTAutoDelegation');
-    rcd = mpipeline.repository.RepositoryConnectionDialog([], true, hosts, conn);
-    rcd.setVisible(true);
-    warning('on', 'MATLAB:JavaEDTAutoDelegation');
-    
-    conn = rcd.getRepositoryConnection;
-    
-    if rcd.isCancelled
-      disp('operation cancelled');
-      conn = [];
-    else
-      if ~isempty(char(conn.getPassword))
-        conn.openConnection();
-      end
-    end
-    
-  end
-  
-  % Add valid connection to the Repository Manager
-  if isa(conn, 'mpipeline.repository.RepositoryConnection')
-    rm.manager.addConnection(conn);
-    if ~isempty(rm.gui)
-      rm.gui.reloadConnectionTable();
-    end
-  else
-    conn = [];
-  end
-  
-  varargout{1} = conn;
-  
-end
-
-
--- a/m-toolbox/classes/@LTPDARepositoryManager/cb_guiClosed.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-% cb_guiClosed will be called if the repository manager GUI is closed.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: cb_guiClosed will be called if the repository manager GUI is
-%              closed.
-%
-% version:     $Id: cb_guiClosed.m,v 1.2 2010/01/22 12:23:02 ingo Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function cb_guiClosed(varargin)
-  disp('*** Goodbye from the LTPDA Repository Manager GUI');
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/cb_newConnection.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-% cb_newConnection callback method which creates a new connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: cb_newConnection callback method which creates a new
-%              connection.
-%
-% version:     $Id: cb_newConnection.m,v 1.2 2010/01/22 12:23:02 ingo Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function cb_newConnection(varargin)
-  
-  rm = getappdata(0, 'LTPDARepositoryManager');
-  if ~isa(rm, 'LTPDARepositoryManager')
-    rm = LTPDARepositoryManager();
-  end
-  
-  rm.newConnection;
-  
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/cb_timerClearPassord.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-% cb_timerClearPassord callback method which disconnects the connection and clears the password
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: cb_timerClearPassord callback method which disconnects the
-%              connection and clears the password
-%
-% version:     $Id: cb_timerClearPassord.m,v 1.6 2010/08/16 18:04:36 ingo Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = cb_timerClearPassord(varargin)
-  
-  prefs = getappdata(0, 'LTPDApreferences');
-  
-  rm    = LTPDARepositoryManager();
-  conns = rm.manager.getConnections();
-  
-  if ~isempty(conns)
-    
-    for ii=1:conns.size
-      conn = conns.get(ii-1);
-      
-      % Clear the password only if the connection is not locked
-      if ~conn.isLocked
-        if conn.isConnected
-          conn.closeConnection();
-        end
-        
-        if (conn.agePassword > double(prefs.getRepoPrefs.getExpiry))
-          conn.setPassword('');
-        end
-      end
-      
-    end
-    
-  end
-  if ~isempty(rm.gui)
-    rm.gui.reloadConnectionTable();
-  end
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/cb_timerDisconnect.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-% cb_timerDisconnect callback method which disconnects the connections
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: callback method which disconnects the connections
-%
-% version:     $Id: cb_timerDisconnect.m,v 1.5 2010/06/25 08:55:52 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = cb_timerDisconnect(varargin)
-  
-  rm    = LTPDARepositoryManager();
-  conns = rm.manager.getConnections();
-  
-  if ~isempty(conns)
-    
-    for ii=1:conns.size
-      conn = conns.get(ii-1);
-      
-      % Clear the password only if the connection is not locked
-      if ~conn.isLocked
-        if (conn.ageConnected > rm.DISCONNECT)
-          conn.closeConnection();
-          if ~isempty(rm.gui)
-            rm.gui.reloadConnectionTable();
-          end
-        end
-      end
-    end
-    
-  end
-  
-end
-
-
--- a/m-toolbox/classes/@LTPDARepositoryManager/copyObjects.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,177 +0,0 @@
-% COPYOBJECTS This function copies objects from one repository to another.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: This static function copies objects from one repository to another.
-%
-% call:        LTPDARepositoryManager.copyObjects(pl);
-%              LTPDARepositoryManager.copyObjects([1 2 3],
-%                                                 'hostname1',
-%                                                 'database1',
-%                                                 'username1',
-%                                                 'hostname2',
-%                                                 'database2',
-%                                                 'username2');
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('LTPDARepositoryManager.copyObjects').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% version:    $Id: copyObjects.m,v 1.5 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = copyObjects(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Collect all plists
-  [pl, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist');
-  
-  pl = combine(pl, getDefaultPlist);
-  ids      = pl.find('ids');
-  hostname1 = pl.find('hostname1');
-  database1 = pl.find('database1');
-  username1 = pl.find('username1');
-  hostname2 = pl.find('hostname2');
-  database2 = pl.find('database2');
-  username2 = pl.find('username2');
-  
-  % Check through 'rest'
-  if numel(rest) > 0
-    ids = rest{1};
-  end
-  if numel(rest) > 1
-    hostname1 = rest{2};
-  end
-  if numel(rest) > 2
-    database1 = rest{3};
-  end
-  if numel(rest) > 3
-    username1 = rest{4};
-  end
-  if numel(rest) > 4
-    hostname2 = rest{5};
-  end
-  if numel(rest) > 5
-    database2 = rest{6};
-  end
-  if numel(rest) > 6
-    username2 = rest{7};
-  end
-  
-  % Some plausibility checks
-  if isempty(ids)
-    error('### This method needs at least one object id which you want to copy.');
-  end
-  
-  % Get the repository manager - there should only be one!
-  rm = LTPDARepositoryManager();
-  
-  % Get connection
-  conn1 = rm.findConnections(hostname1, database1, username1);
-  if numel(conn1) == 0
-    conn1 = rm.newConnection(hostname1, database1, username1);
-  elseif numel(conn1) > 1
-    conn1 = rm.manager.selectConnection([]);
-  end
-  
-  if isempty(conn1)
-    error('### It is necessary to create or select a connection.');
-  end
-  
-  % open connection
-  conn1.openConnection();
-  if ~conn1.isConnected()
-    error('### Can not open the connection.');
-  end
-  
-  try
-    
-    objs = ltpda_uo.retrieve(conn1, ids);
-    if ~iscell(objs)
-      objs = {objs};
-    end
-    sinfo = LTPDARepositoryManager.getSinfo(ids, ...
-      char(conn1.getHostname), char(conn1.getDatabase), char(conn1.getUsername));
-    
-    pl = plist('hostname', hostname2, 'database', database2, 'username', username2, 'no dialog', true);
-    for oo = 1:numel(objs)
-      obj = objs{oo};
-      obj.submit(sinfo(oo), pl);
-    end
-  catch Exception
-    disp(Exception.message);
-    error('### Copying failed.');
-  end
-  
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                               Local Functions                               %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FUNCTION:    getInfo
-%
-% DESCRIPTION: Returns the method-info object
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.helper, '$Id: copyObjects.m,v 1.5 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FUNCTION:    getDefaultPlist
-%
-% DESCRIPTION: Returns the default PLIST
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function pl = getDefaultPlist()
-  
-  % Initialise plist
-  pl = plist();
-  
-  % ids
-  p = param({'ids', 'Object identifications of which you want to copy.'}, paramValue.EMPTY_DOUBLE);
-  pl.append(p);
-  
-  % hostname1
-  p = param({'hostname1', 'The hostname of the ''old'' repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database1
-  p = param({'database1', 'The database of the ''old'' repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username1
-  p = param({'username1', 'The username for the ''old'' repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % hostname2
-  p = param({'hostname2', 'The hostname of the ''new'' repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database2
-  p = param({'database2', 'The database of the ''new'' repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username2
-  p = param({'username2', 'The username for the ''new'' repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/deleteTimer.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-% DELETETIMER delets the input timer.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: DELETETIMER delets the input timer.
-%
-% call:        deleteTimer(rm, t)
-%
-% inputs       rm - Repository manager
-%              t  - Property name of a timer.
-%
-% version:     $Id: deleteTimer.m,v 1.4 2011/02/03 13:44:45 ingo Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function deleteTimer(rm, tName)
-  
-  if isa(rm.(tName), 'timer')
-    stop(rm.(tName));
-    delete(rm.(tName));
-  end
-  
-  rm.(tName) = [];
-  
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/display.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-% DISPLAY implement terminal display for the repository manager.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: DISPLAY implement terminal display for the repository
-%              manager.
-%
-% CALL:        display(rm)
-%              rm                     % without a semicolon
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('display').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:     $Id: display.m,v 1.3 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = display(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  rm = varargin{1};
-  rm.manager
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.output, '$Id: display.m,v 1.3 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-  ii.setModifier(false);
-  ii.setOutmin(0);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  pl = plist();
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/executeQuery.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,289 +0,0 @@
-% EXECUTEQUERY query a LTPDA repository database.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: EXECUTEQUERY query a LTPDA repository database.
-%
-% CALL:        info = executeQuery(pl);
-%              info = executeQuery(query);
-%              info = executeQuery(table, query);
-%              info = executeQuery(query, hostname, database, username);
-%              info = executeQuery(table, query, hostname, database, username);
-%
-% INPUTS:      pl       - a PLIST object.
-%              query    - a valid MySQL query string
-%              table    - a table name
-%              hostname - hostname of the LTPDA database
-%              database - LTPDA database
-%              username - user name
-%
-% OUTPUTS:     info - the returned 'info' structure contains the fields
-%              from each matching record.
-%
-% REMARK:      If you don't specify a hostname, database and user name then
-%              do this method the following:
-%              The repository manager have the following numer of connections:
-%                 0:  A GUI will open for creating a new connection.
-%                 1:  The method will use this connection.
-%                >1:  A GUI will open where you have to select a connection
-%
-% EXAMPLES:
-%
-%   >> info  = LTPDARepositoryManager.executeQuery('select * from objmeta where id>1000 and id<2000');
-%   >> info  = LTPDARepositoryManager.executeQuery('ao',           'id>1000 and id<2000');
-%   >> info  = LTPDARepositoryManager.executeQuery('objmeta',      'name like "x12"');
-%   >> info  = LTPDARepositoryManager.executeQuery('users',        'username="aouser"');
-%   >> info  = LTPDARepositoryManager.executeQuery('collections',  'id=3');
-%   >> info  = LTPDARepositoryManager.executeQuery('collections',  'obj_id="1,2"');
-%   >> info  = LTPDARepositoryManager.executeQuery('transactions', 'user_id=3');
-%   >> info  = LTPDARepositoryManager.executeQuery('transactions', 'obj_id=56');
-%
-%   The 'info' cell-array will contain the results from the SQL query.
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('LTPDARepositoryManager.executeQuery').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:     $Id: executeQuery.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = executeQuery(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Get the repository manager - there should only be one!
-  rm = LTPDARepositoryManager();
-  
-  % Collect all plists
-  [pl, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist');
-  
-  pl = combine(pl, getDefaultPlist);
-  query    = pl.find('query');
-  table    = pl.find('table');
-  hostname = pl.find('hostname');
-  database = pl.find('database');
-  username = pl.find('username');
-  
-  % Check through 'rest'
-  if (numel(rest) == 1) && (ischar(rest{1}))
-    query = rest{1};
-  elseif numel(rest) == 2
-    table = rest{1};
-    query = rest{2};
-  elseif numel(rest) == 4
-    query = rest{1};
-    hostname = rest{2};
-    database = rest{3};
-    username = rest{4};
-  elseif numel(rest) == 5
-    table    = rest{1};
-    query    = rest{2};
-    hostname = rest{3};
-    database = rest{4};
-    username = rest{5};
-  end
-  
-  % Get connection
-  conn = rm.findConnections(hostname, database, username);
-  if numel(conn) == 0
-    conn = rm.newConnection(hostname, database, username);
-  elseif numel(conn) > 1
-    conn = rm.manager.selectConnection([]);
-  end
-  
-  if isempty(conn)
-    error('### It is necessary to create or select a connection.');
-  end
-  
-  % open connection
-  conn.openConnection();
-  if ~conn.isConnected()
-    error('### Can not open the connection.');
-  end
-  
-  % make sure 
-  try
-    mustUnlock = ~conn.isLocked();
-    
-    % Lock connection
-    conn.setLocked(true);
-    
-    if isempty(table) && ~isempty(query)
-      % execute query
-      info = simpleQuery(conn, query);
-    elseif ~isempty(query) && ~isempty(table)
-      % query a table
-      info = runQuery(conn, table, query);
-    else
-      error('### Incorrect inputs. Please specify at least a query and/or a table.');
-    end
-  catch Exception
-    if (mustUnlock)
-      conn.setLocked(false);
-    end
-    error(Exception.message);
-  end
-  
-  if (mustUnlock)
-    conn.setLocked(false);
-  end
-  
-  varargout{1} = info;
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                               Local Functions                               %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get table list
-function info = getTableList(conn)
-  
-  info = {};
-  
-  % open a connection
-  try
-    q = 'show tables';
-    results = conn.query(q);
-    while results.next
-      info = [info {char(results.getString(1))}];
-    end
-  catch Exception
-    disp(Exception.message);
-    error('### Failed to get table list.');
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get field list
-function info = getFieldList(conn, table)
-  
-  info = {};
-  try
-    q = ['describe ' table];
-    results = conn.query(q);
-    while results.next
-      info = [info {char(results.getObject(1))}];
-    end
-  catch Exception
-    disp(Exception.message);
-    error('### Failed to get field list.');
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Get field list
-function info = simpleQuery(conn, q)
-  
-  % open a connection
-  info = {};
-  try
-    results = conn.query(q);
-    mt = results.getMetaData;
-    Ncols = mt.getColumnCount;
-    row = 1;
-    while results.next
-      for kk=1:Ncols
-        info{row,kk} = convertValue(results.getObject(kk));
-      end
-      row = row + 1;
-    end
-    
-  catch Exception
-    disp(Exception.message);
-    error('### Failed to execute query.');
-  end
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% Run a query
-function info = runQuery(conn, table, query)
-  
-  % Run query
-  info = {};
-  
-  fields = getFieldList(conn, table);
-  f = '';
-  fs = {};
-  for j=1:length(fields)
-    % special cases
-    f  = [f fields{j} ',' ];
-    fs = [fs fields(j)];
-  end
-  q = sprintf('select %s  from %s where %s', f(1:end-1), table, query);
-  disp(['** QUERY: ' q]);
-  try
-    info = simpleQuery(conn, q);
-  catch Exception
-    disp(Exception.message);
-    error('### Failed to query table.');
-  end
-end
-
-function val = convertValue(val)
-  
-  switch class(val)
-    case 'java.sql.Timestamp'
-      val = char(val);
-    otherwise
-  end
-end
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FUNCTION:    getInfo
-%
-% DESCRIPTION: Returns the method-info object
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.helper, '$Id: executeQuery.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FUNCTION:    getDefaultPlist
-%
-% DESCRIPTION: Returns the default PLIST
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function pl = getDefaultPlist()
-  
-  % Initialise plist
-  pl = plist();
-  
-  % query
-  p = param({'query', 'A valid MySQL query string.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % table
-  p = param({'table', 'A table name.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % hostname
-  p = param({'hostname', 'The hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database
-  p = param({'database', 'The database on the repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username
-  p = param({'username', 'The username to connect with.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/findConnections.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-% FINDCONNECTIONS finds a managed connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: FINDCONNECTIONS finds a managed connection.
-%
-% CALL:        conns = rm.findConnections(pl);
-%              conns = rm.findConnections('hostname');
-%              conns = rm.findConnections('hostname', 'database');
-%              conns = rm.findConnections('hostname', 'database', 'username');
-%
-% findConneciton finds all connections which match the given input fields.
-% If no matching connections are found then the method returns an emtpy
-% array. To search for all 'hostnames' for a given 'username', enter an
-% empty string. For example:
-%
-% 1) Find all connections for user 'bob'
-%
-%     pl = plist('username', 'bob');
-%     conns = rm.findConnections(pl);
-%
-%  or
-%
-%     conns = rm.findConnections('', '', 'bob');
-%
-% 2) Find all connection to 'localhost' for database 'foo'
-%
-%    pl    = plist('hostname', 'localhost', 'database', 'foo')
-%    conns = rm.findConnections(pl);
-%
-%  or
-%
-%    conns = rm.findConnections('localhost', 'foo');
-%
-% 3) Find all connections to 'localhost' for user 'bob'
-%
-%    conns = rm.findConnections('localhost', '', 'bob');
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('findConnections').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:    $Id: findConnections.m,v 1.7 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = findConnections(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Get the repository manager - there should only be one!
-  [rm, invars, rest] = utils.helper.collect_objects(varargin(:), 'LTPDARepositoryManager');
-  
-  % Collect all plists
-  [pl, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
-  
-  
-  pl = combine(pl, getDefaultPlist);
-  hostname = pl.find('hostname');
-  database = pl.find('database');
-  username = pl.find('username');
-  
-  % Check through 'rest'
-  if numel(rest) > 0
-    hostname = rest{1};
-  end
-  if numel(rest) > 1
-    database = rest{2};
-  end
-  if numel(rest) > 2
-    username = rest{3};
-  end
-  
-  % make sure that username are strings because JAVA interprets an empty
-  % array [] as a null-pointer.
-  if isempty(hostname), hostname = ''; end
-  if isempty(database), database = ''; end
-  if isempty(username), username = ''; end
-  
-  conns = rm.manager.findConnections(hostname, database, username);
-  
-  mconns = [];
-  for i=1:conns.size
-    mconns = [mconns conns.get(i-1)];
-  end
-  
-%   if isempty(mconns)
-%     mconns = rm.newConnection(hostname, database, username);
-%   end
-%   
-  utils.helper.msg(utils.const.msg.PROC1, 'Matched %d managed connections', numel(mconns));
-  
-  if nargout > 0
-    varargout{1} = mconns;
-  end
-  
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.gui, '$Id: findConnections.m,v 1.7 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  
-  % Initialise plist
-  pl = plist();
-  
-  % hostname
-  p = param({'hostname', 'The hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database
-  p = param({'database', 'The database on the repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username
-  p = param({'username', 'The username to connect with.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-end
-% END
--- a/m-toolbox/classes/@LTPDARepositoryManager/getConnection.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-% GETCONNECTION makes a new managed repository connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETCONNECTION makes a new managed repository connection.
-%
-% CALL:        conn = rm.getConnection(pl);
-%              conn = rm.getConnection('hostname');
-%              conn = rm.getConnection('hostname', 'database');
-%              conn = rm.getConnection('hostname', 'database', 'username');
-%              conn = rm.getConnection('hostname', 'database', 'username', 'password');
-%
-% If all required connection fields are input, the connection will be
-% silently created and added to the manager. Otherwise, a connection dialog
-% will be presented and the resulting connection added to the manager.
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('getConnection').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:    $Id: getConnection.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = getConnection(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  varargout{1} = newConnection(varargin{:});
-
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.gui, '$Id: getConnection.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  
-  % Initialise plist
-  pl = plist();
-  
-  % hostname
-  p = param({'hostname', 'The hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database
-  p = param({'database', 'The database on the repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username
-  p = param({'username', 'The username to connect with.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % password
-  p = param({'password', 'The password to connect with. Leave this empty to be prompted on connection.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-end
-% END
--- a/m-toolbox/classes/@LTPDARepositoryManager/getSinfo.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-% GETSINFO gets the submission information of an object in the repository.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: GETSINFO gets the submission information of an object in the
-%              repository.
-%
-% CALL:        sinfo = LTPDARepositoryManager.getSinfo(pl);
-%              sinfo = LTPDARepositoryManager.getSinfo(ids);
-%              sinfo = LTPDARepositoryManager.getSinfo(ids, 'hostname');
-%              sinfo = LTPDARepositoryManager.getSinfo(ids, 'hostname', 'database');
-%              sinfo = LTPDARepositoryManager.getSinfo(ids, 'hostname', 'database', 'username');
-%
-% If all required connection fields are input, the connection will be
-% silently created and added to the manager. Otherwise, a connection dialog
-% will be presented and the resulting connection added to the manager.
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('LTPDARepositoryManager.getSinfo').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:    $Id: getSinfo.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = getSinfo(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Collect all plists
-  [pl, invars, rest] = utils.helper.collect_objects(varargin(:), 'plist');
-
-  pl = combine(pl, getDefaultPlist);
-  ids      = pl.find('ids');
-  hostname = pl.find('hostname');
-  database = pl.find('database');
-  username = pl.find('username');
-
-  % Check through 'rest'  
-  if numel(rest) > 0
-    ids = rest{1};
-  end
-  if numel(rest) > 1
-    hostname = rest{2};
-  end
-  if numel(rest) > 2
-    database = rest{3};
-  end
-  if numel(rest) > 3
-    username = rest{4};
-  end
-  
-  % Some plausibility checks
-  if isempty(ids)
-    error('### This method needs at least one object id.');
-  end
-  if nargout == 0
-    error('### This method can not be used as a modifier method. Please give one output');
-  end
-  
-  % Get complete experiment information for each input id
-  sinfo = [];
-  for ii=1:length(ids)
-    query = ['select name,experiment_title,experiment_desc,analysis_desc,quantity, '...
-      'additional_authors,additional_comments,keywords,reference_ids FROM objmeta ' ...
-      sprintf('where objmeta.obj_id=%d',ids(ii))];
-    
-    infoall = LTPDARepositoryManager.executeQuery(query, hostname, database, username);
-    if ~isempty(infoall)
-      s.name                    = infoall{1};
-      s.experiment_title        = infoall{2};
-      s.experiment_description  = infoall{3};
-      s.analysis_description    = infoall{4};
-      s.quantity                = infoall{5};
-      s.additional_authors      = infoall{6};
-      s.additional_comments     = infoall{7};
-      s.keywords                = infoall{8};
-      s.reference_ids           = infoall{9};
-      sinfo = [sinfo s];
-    else
-      warning('!!! Doesn''t find any submission information for the object id %d', ids(ii));
-    end
-  end
-  
-  % Set output
-  varargout{1} = sinfo;
-  
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                               Local Functions                               %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FUNCTION:    getInfo
-%
-% DESCRIPTION: Returns the method-info object
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.helper, '$Id: getSinfo.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% FUNCTION:    getDefaultPlist
-%
-% DESCRIPTION: Returns the default PLIST
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function pl = getDefaultPlist()
-  
-  % Initialise plist
-  pl = plist();
-  
-  % ids
-  p = param({'ids', 'Object identifications of which you need the submission information.'}, paramValue.EMPTY_DOUBLE);
-  pl.append(p);
-  
-  % hostname
-  p = param({'hostname', 'The hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database
-  p = param({'database', 'The database on the repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username
-  p = param({'username', 'The username to connect with.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-end
-
--- a/m-toolbox/classes/@LTPDARepositoryManager/listConnections.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-% LISTCONNECTIONS list all connections in the repository manager.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: LISTCONNECTIONS list all connections in the repository
-%              manager.
-%
-% CALL:        rm.listConnections
-%              listConnections(rm)
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('listConnections').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:     $Id: listConnections.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = listConnections(varargin)
-
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  rm = varargin{1};
-  conns = rm.manager.getConnections;
-  for i=1:conns.size
-    conn = conns.get(i-1);
-    if (conn.isConnected)
-      message = sprintf('connected for %2.2f seconds', conn.ageConnected());
-    else
-      message = 'not connected';
-    end
-    disp(sprintf('%02d: %s@%s:%s [%s]', i, char(conn.getUsername), ...
-      char(conn.getHostname), char(conn.getDatabase), message));
-  end
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.internal, '$Id: listConnections.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-  ii.setModifier(false);
-  ii.setOutmin(0);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  pl = plist();
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/newConnection.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-% NEWCONNECTION makes a new managed repository connection.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: NEWCONNECTION makes a new managed repository connection.
-%
-% CALL:        conn = rm.newConnection(pl);
-%              conn = rm.newConnection('hostname');
-%              conn = rm.newConnection('hostname', 'database');
-%              conn = rm.newConnection('hostname', 'database', 'username');
-%              conn = rm.newConnection('hostname', 'database', 'username', 'password');
-%
-% If all required connection fields are input, the connection will be
-% silently created and added to the manager. Otherwise, a connection dialog
-% will be presented and the resulting connection added to the manager.
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('newConnection').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:    $Id: newConnection.m,v 1.10 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = newConnection(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  % Get the repository manager - there should only be one!
-  [rm, invars, rest] = utils.helper.collect_objects(varargin(:), 'LTPDARepositoryManager');
-  
-  % Collect all plists
-  [pl, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
-  
-  pl = combine(pl, getDefaultPlist);
-  hostname = pl.find('hostname');
-  database = pl.find('database');
-  username = pl.find('username');
-  password = pl.find('password');
-  
-  % Check through 'rest'
-  if numel(rest) > 0
-    hostname = rest{1};
-  end
-  if numel(rest) > 1
-    database = rest{2};
-  end
-  if numel(rest) > 2
-    username = rest{3};
-  end
-  if numel(rest) > 3
-    password = rest{4};
-  end
-  
-  conn = rm.manager.findExactConnection(hostname, database, username);
-  
-  if ~isempty(conn)
-    if ~isempty(password) && isempty(char(conn.getPassword))
-      conn.setPassword(password);
-    end
-  else
-    conn = rm.basic_newConnection(hostname, database, username, password);
-  end
-  
-  % my be it is necessary to update the GUI table
-  if ~isempty(rm.gui)
-    rm.gui.reloadConnectionTable();
-  end
-  if ~isempty(rm.selector)
-    rm.selector.reloadConnectionTable();
-  end
-  varargout{1} = conn;
-  
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.gui, '$Id: newConnection.m,v 1.10 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  
-  % Initialise plist
-  pl = plist();
-  
-  % hostname
-  p = param({'hostname', 'The hostname of the repository to connect to.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % database
-  p = param({'database', 'The database on the repository.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % username
-  p = param({'username', 'The username to connect with.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-  % password
-  p = param({'password', 'The password to connect with. Leave this empty to be prompted on connection.'}, paramValue.EMPTY_STRING);
-  pl.append(p);
-  
-end
-
--- a/m-toolbox/classes/@LTPDARepositoryManager/resetTimer.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-% RESETTIMER resets the input timer.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: RESETTIMER resets the input timer.
-%
-% call:        resetTimer(t)
-%
-% inputs       t - timer object or the name of a timer.
-%
-% version:     $Id: resetTimer.m,v 1.3 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function resetTimer(inputTimer, conn)
-  
-  if ischar(inputTimer)
-    inputTimer = timerfind('name', inputTimer);
-  end
-  
-  if isa(inputTimer, 'timer')
-    stop(inputTimer);
-    start(inputTimer);
-  end
-  
-  newTime = java.lang.System.currentTimeMillis();
-  if nargin == 2 && isa(conn, 'mpipeline.repository.RepositoryConnection')
-    conn.setConnectedAt(newTime);
-    conn.setPasswordSetAt(newTime);
-  else
-    rm = LTPDARepositoryManager();
-    conns = rm.manager.getConnections();
-    for ii=1:conns.size
-      conn = conns.get(ii-1);
-      conn.setConnectedAt(newTime);
-      conn.setPasswordSetAt(newTime);
-    end
-  end
-  
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/showGui.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-% SHOWGUI opens a GUI which displays the repository manager.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% DESCRIPTION: SHOWGUI opens a GUI which displays the repository manager.
-%
-% CALL:        rm.showGui
-%              showGui(rm)
-%
-% <a href="matlab:web(LTPDARepositoryManager.getInfo('showGui').tohtml, '-helpbrowser')">Parameters Description</a>
-%
-% VERSION:     $Id: showGui.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function varargout = showGui(varargin)
-
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
-  rm = varargin{1};
-  if isempty(rm.gui)
-    rm.initGUI;
-  end
-  awtinvoke(rm.gui, 'setVisible', 'true');
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.gui, '$Id: showGui.m,v 1.4 2011/04/08 08:56:35 hewitson Exp $', sets, pl);
-  ii.setModifier(false);
-  ii.setOutmin(0);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  pl = plist();
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/startTimer.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-% STARTTIMER returns a started timer.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: STARTTIMER returns a started timer.
-%
-% call:        t = startTimer(name, fcn, period)
-%
-% inputs:      name   - name of the timer
-%              fcn    - call back function of the timer
-%              period - period of the timer
-%
-% outputs:     t      - new timer object.
-%
-% version:     $Id: startTimer.m,v 1.3 2011/02/03 13:44:02 ingo Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function t = startTimer(name, fcn, period)
-  
-  t = timerfind('name', name);
-  
-  if isempty(t) || (isa(t, 'timer') && ~isvalid(t))
-    
-    t = timer(...
-      'TimerFcn',       fcn, ...
-      'StartDelay',     period, ...
-      'Period',         period, ...
-      'ExecutionMode', 'fixedRate', ...
-      'Name',           name);
-  end
-  
-  % start the timer
-  if ~strcmp(get(t,'Running'), 'on')
-    start(t);
-  end
-  
-end
--- a/m-toolbox/classes/@LTPDARepositoryManager/updatePrefs.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-% UPDATEPREFS updates the Repository Manager depending on the preferences.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% description: updates the Repository Manager depending on the preferences.
-%
-% call:        rm = updatePrefs(rm, pl)
-%
-% version:     $Id: updatePrefs.m,v 1.6 2011/03/28 12:45:45 hewitson Exp $
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-function rm = updatePrefs(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    rm = getInfo(varargin{3});
-    return
-  end
-    
-  utils.helper.msg(utils.const.msg.PROC1, 'Update expiry login time.');  
-  rm = varargin{1};
-
-  % Get timer for login expiry password
-  t = rm.timerClearPass;
-  
-  % Get pointer to the preferences
-  prefs = getappdata(0, 'LTPDApreferences');
-  expiryTime = double(prefs.getRepoPrefs.getExpiry());
-  
-  % Set the new expiry time to the repository manager
-  if isa(t, 'timer')
-    
-    % Check if the user have changed the expire time
-    if (t.Period ~= expiryTime)
-    
-      if strcmp(get(t,'Running'), 'on')
-        stop(t);
-      end
-      set(t, 'Period', expiryTime);
-      set(t, 'StartDelay', expiryTime);
-      start(t);
-      
-    else
-      % Do nothing if the user didn'T change the exire time
-    end
-      
-  else
-    t = LTPDARepositoryManager.startTimer('LTPDA_clearPassword', @LTPDARepositoryManager.cb_clearPassord, expiryTime);
-    rm.timerClearPass = t;
-  end
-  
-  % Set the host-names to the repository manager
-  jhosts = prefs.getRepoPrefs.getHostnames;
-  rm.manager.setRepoHosts(jhosts);
-  
-  % Resets the timers if a user make some changes to the preferences.
-  conns = rm.manager.getConnections;
-  for ii=1:conns.size
-    conn = conns.get(ii-1);
-    LTPDARepositoryManager.resetTimer(rm.timerClearPass, conn);
-    LTPDARepositoryManager.resetTimer(rm.timerDisconnect, conn);
-  end
-end
-
-%--------------------------------------------------------------------------
-% Get Info Object
-%--------------------------------------------------------------------------
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'LTPDARepositoryManager', 'ltpda', utils.const.categories.internal, '$Id: updatePrefs.m,v 1.6 2011/03/28 12:45:45 hewitson Exp $', sets, pl);
-end
-
-%--------------------------------------------------------------------------
-% Get Default Plist
-%--------------------------------------------------------------------------
-function pl = getDefaultPlist()
-  pl = plist();
-end
--- a/m-toolbox/classes/@LTPDAprefs/cb_guiClosed.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@LTPDAprefs/cb_guiClosed.m	Tue Dec 06 19:07:22 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/classes/@LTPDAprefs/loadPrefs.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@LTPDAprefs/loadPrefs.m	Tue Dec 06 19:07:22 2011 +0100
@@ -10,7 +10,6 @@
 %
 
 function loadPrefs(varargin)
-  fprintf('Loading LTPDA preferences from %s ...\n', LTPDAprefs.preffile);
   v = ver('LTPDA');
   nv = utils.helper.ver2num(v(1).Version);
   prefs = mpipeline.ltpdapreferences.LTPDAPreferences.loadFromDisk(LTPDAprefs.preffile, nv);
--- a/m-toolbox/classes/@LTPDAworkbench/LTPDAworkbench.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@LTPDAworkbench/LTPDAworkbench.m	Tue Dec 06 19:07:22 2011 +0100
@@ -80,13 +80,7 @@
               pause(0.1);
               save(libfile, 'lib')
             end
-            
-            % Set the repository manager to the workbench
-            rm = LTPDARepositoryManager();
-            awtinvoke(wb.mp, 'setRepositoryManager', rm.manager);
-%             javaMethodEDT('setRepositoryManager', wb.mp, rm.manager);
-            pause(0.1);
-            
+                        
             % refresh library tree
             awtinvoke(wb.mp, 'refreshLibraryTree');
 %             javaMethodEDT('refreshLibraryTree', wb.mp);
@@ -184,8 +178,8 @@
         set(h, 'ActionPerformedCallback', {@wb.cb_launchLTPDApreferences});
         
         %---- 'LTPDA Repository GUI' menu item
-        h = handle(wb.mp.getLtpdaRepoGuiMenuItem, 'callbackproperties');
-        set(h, 'ActionPerformedCallback', {@wb.cb_launchRepogui});
+        %h = handle(wb.mp.getLtpdaRepoGuiMenuItem, 'callbackproperties');
+        %set(h, 'ActionPerformedCallback', {@wb.cb_launchRepogui});
         
         %---- 'Spectral Window Viewer' menu item
         h = handle(wb.mp.getLtpdaSpecwinViewerMenuItem, 'callbackproperties');
@@ -244,8 +238,8 @@
         set(h, 'ActionPerformedCallback', {@wb.cb_submitObjects});
         
         %----Open repository manager
-        h = handle(wb.mp.getRepoConnectTBB, 'callbackproperties');
-        set(h, 'ActionPerformedCallback', {@wb.cb_openRepoManagerGUI});
+        h = handle(wb.mp.getRepoSearchTBB, 'callbackproperties');
+        set(h, 'ActionPerformedCallback', {@wb.cb_queryRepository});
         
         %%%%%%%%%%   other    %%%%%%%%%%
         
@@ -382,7 +376,7 @@
     
     % Repository Buttons
     varargout = cb_submitObjects(varargin)
-    varargout = cb_openRepoManagerGUI(varargin)
+    varargout = cb_queryRepository(varargin)
     
     % other
     varargout = cb_guiClosed(varargin)
--- a/m-toolbox/classes/@LTPDAworkbench/cb_launchRepogui.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@LTPDAworkbench/cb_launchRepogui.m	Tue Dec 06 19:07:22 2011 +0100
@@ -6,7 +6,6 @@
 %
 function cb_launchRepogui(varargin)
   
-  rm = LTPDARepositoryManager();
-  rm.showGui();
+  LTPDADatabaseConnectionManager().connect();
   
 end
--- a/m-toolbox/classes/@LTPDAworkbench/cb_openRepoManagerGUI.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@LTPDAworkbench/cb_openRepoManagerGUI.m	Tue Dec 06 19:07:22 2011 +0100
@@ -8,9 +8,7 @@
 %
 function cb_openRepoManagerGUI(varargin)
   
-  rm = LTPDARepositoryManager();
-  rm.showGui();
-  rm.gui.toFront();
+  LTPDADatabaseConnectionManager().connect();
   
 end
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/@LTPDAworkbench/cb_queryRepository.m	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,9 @@
+function varargout = cb_queryRepository(varargin)
+  
+  wb = varargin{1};
+  conn = LTPDADatabaseConnectionManager().connect();
+  
+  rqd = javaObjectEDT('mpipeline.repository.RepositoryQueryDialog', wb.mp, false, conn, true);
+  rqd.setVisible(true);
+  
+end
--- a/m-toolbox/classes/@LTPDAworkbench/cb_submitObjects.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@LTPDAworkbench/cb_submitObjects.m	Tue Dec 06 19:07:22 2011 +0100
@@ -10,6 +10,8 @@
   
   wb = varargin{1};
   
+  wb
+  
   % Get all selected blocks
   sbs = awtinvoke(wb.mp, 'getSelectedBlocks');
   
@@ -49,6 +51,9 @@
   end
   
   cmd = [cmd 'sinfo, plist(''hostname'', ''''));'];
+
+  disp(sinfo)
+  disp(cmd)
   
   assignin('base', 'sinfo', sinfo);
   try
--- a/m-toolbox/classes/@ao/ao.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ao/ao.m	Tue Dec 06 19:07:22 2011 +0100
@@ -580,7 +580,7 @@
           %%%%%%%%%%%%%%%%%%%%%%%%%%%   two inputs   %%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           
-          if isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')
+          if isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')
             %%%%%%%%%%   ao(database-object, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.PROC1, 'constructing from database object');
             pl = plist('conn', varargin{1}, 'id', varargin{2});
--- a/m-toolbox/classes/@collection/collection.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@collection/collection.m	Tue Dec 06 19:07:22 2011 +0100
@@ -155,7 +155,7 @@
             inObjs = [num2cell(reshape(varargin{1}, 1, [])), num2cell(reshape(varargin{2}, 1, []))];
             obj = obj.fromInput(plist('objs', inObjs));
             
-          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  f = collection(<database-object>, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
--- a/m-toolbox/classes/@collection/fromRepository.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@collection/fromRepository.m	Tue Dec 06 19:07:22 2011 +0100
@@ -12,121 +12,74 @@
 % VERSION:     $Id: fromRepository.m,v 1.8 2010/10/29 16:09:11 ingo Exp $
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function coll = fromRepository(coll, pli)
-  
+function coll = fromRepository(coll, pl)
+
   VERSION = '$Id: fromRepository.m,v 1.8 2010/10/29 16:09:11 ingo Exp $';
-  
+
   % get object info
   ii = collection.getInfo('collection', 'From Repository');
   % Set the method version string in the minfo object
   ii.setMversion([VERSION '-->' ii.mversion]);
-  
-  % Check if the user supplied a DB connection
-  conn = find(pli, 'conn');
-  
-  % Add default values if necessary
-  if isempty(conn)
-    pl = combine(pli, ii.plists);
-  else
-    pl = pli;
-  end
+
   plh = copy(pl, 1);
-  
+
   % Get parameters
-  hostname = find(pl, 'hostname');
-  database = find(pl, 'database');
-  user     = find(pl, 'user');
-  passwd   = find(pl, 'passwd');
   ids      = find(pl, 'id');
   cids     = find(pl, 'cid');
   bin      = find(pl, 'binary');
-  
+
   collFound  = false;
-  
-  %%% check if using binary or not: 'yes'/'no' or true/false or
-  %%% 'true'/'false'
+
+  % check if using binary download
   bin = utils.prog.yes2true(bin);
-  
-  % do we have a connection?
-  closeConn = 0;
-  if isempty(conn)
-    closeConn = 1;
-    % Connect to repository
-    % Connect to repository
-    if ~isempty(user) && ~isempty(passwd)
-      conn = utils.jmysql.connect(hostname, database, user, passwd);
-    else
-      conn = utils.jmysql.connect(hostname, database);
-    end
-  end
-  if ~isa(conn, 'database') && ~isa(conn, 'mpipeline.repository.RepositoryConnection')
-    error('### connection to the database failed.');
-  end
-  
+
+  % database connection
+  conn = LTPDADatabaseConnectionManager().connect(pl);
+
   if ~isempty(cids)
     for kk=1:numel(cids)
       cid = cids(kk);
-      if isa(conn, 'database')
-        % get the ids from the cid
-        ids = [ids utils.mysql.getObjIds(conn,cid)];
-      else
-        c_ids = mpipeline.repository.MySQLUtils.getObjectIDsFromCollectionID(conn, cid);
-        ids = [ids c_ids.'];
-      end
+      ids = utils.repository.getCollectionIDs(conn, cid);
     end
   end
-  
+
   % Get each ID
   Nids     = length(ids);
   collObjs = {};
-  
+
   for kk=1:Nids
-    
+
     %---- copy the input plist because each object should get an other plist
     plh = copy(pl, 1);
-    
+
     %---- This id
     id = ids(kk);
     utils.helper.msg(utils.const.msg.OPROC2, 'retrieving ID %d', id);
-    
+
     try
       %---- call database constructor
       if bin
-        try
-          robj = ltpda_uo.retrieve(conn, 'binary', id);
-        catch
-          warning('!!! Unable to do binary retrieval for object %d; trying to retrieve XML instead.', id);
-          robj = ltpda_uo.retrieve(conn, id);
-        end
+        robj = ltpda_uo.retrieve(conn, 'binary', id);
       else
         robj = ltpda_uo.retrieve(conn, id);
       end
-      
-      %  - remove connection object from plist first
-      if isempty(hostname) || isempty(database)
-        txt = textscan(conn.URL, '%s', 'Delimiter', '/', 'CollectOutput', 1);
-        plc = plist('hostname', txt{1}{3}, 'database', txt{1}{4});
-        plh = combine(pli, plc);
-      end
-      
-      %---- remove the connection from the history plist
-      if plh.isparam('conn')
-        plh.remove('conn');
-      end
-      
+
+      %---- Set connection parameters in the plist
+      utils.repository.adjustPlist(conn, plh);
+
       %---- Set only the ID of the current object to the plist
       plh.pset('ID', id);
-      
+
       %---- Add history
       robj.addHistoryWoChangingUUID(robj.getInfo(class(robj), 'From Repository'), plh, [], robj.hist);
-      
+
       %---- Add to output array
       if isa(robj, 'collection')
         if numel(ids) == 1
           coll = robj;
           return
         end
-        
+
         if numel(robj.objs)>0
           collFound = true;
           collObjs = [collObjs; robj.objs(:)];
@@ -134,24 +87,22 @@
       else
         collObjs = [collObjs; {robj}];
       end
-    catch Exception
-      if closeConn
-        close(conn);
+    
+    catch ex
+      % close connection if we own it
+      if isempty(find(pl, 'conn'))
+        conn.close();
       end
-      throw(Exception)
+      throw(ex)
     end
-    
+
   end
-  
-  % close connection
-  if closeConn
-    if isa(conn, 'database')
-      close(conn);
-    else
-      conn.closeConnection;
-    end
+
+  % close connection if we own it
+  if isempty(find(pl, 'conn'))
+    conn.close();
   end
-  
+
   if collFound
     warning(sprintf(['!!! The output collection contains the contents of at least one retrieved collection.' ...
       '\nThe history of those collection objects is discarded. The internal objects of those ' ...
@@ -160,15 +111,14 @@
   if isempty(collObjs)
     warning('!!! No objects were retrieved from the ids %s and/or collection id %s', mat2str(ids), mat2str(cid));
   end
-  
+
   % Define collection-plist for the history
-  plh.pset('id', pli.find('id'));
-  plh.pset('cid', pli.find('cid'));
-  
+  plh.pset('id', pl.find('id'));
+  plh.pset('cid', pl.find('cid'));
+
   % Set properties from the plist
   coll.setProperties(pl);
   coll.objs = collObjs;
   coll.addHistory(ii, plh, [], []);
-  
+
 end
-
--- a/m-toolbox/classes/@filterbank/filterbank.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@filterbank/filterbank.m	Tue Dec 06 19:07:22 2011 +0100
@@ -130,7 +130,7 @@
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%   two input   %%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  mdl = filterbank(<database-object>, [IDs])   %%%%%%%%%%
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
             
--- a/m-toolbox/classes/@ltpda_uo/fromRepository.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ltpda_uo/fromRepository.m	Tue Dec 06 19:07:22 2011 +0100
@@ -12,34 +12,20 @@
 % VERSION:     $Id: fromRepository.m,v 1.4 2010/03/16 19:16:20 ingo Exp $
 %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-function [objs, plhout, ii] = fromRepository(obj, pli, ii)
-  
+function [objs, plhout, ii] = fromRepository(obj, pl, ii)
+
   VERSION = 'ltpda_uo: $Id: fromRepository.m,v 1.4 2010/03/16 19:16:20 ingo Exp $';
-  
+
   requested_class = class(obj);
-  
+
   % Set the method version string in the minfo object
   ii.setMversion([VERSION '-->' ii.mversion]);
-  
-  % Check if the user supplied a DB connection
-  conn = find(pli, 'conn');
-  
-  % Add default values if necessary
-  if isempty(conn)
-    pl = combine(pli, ii.plists.pset('HOSTNAME', ''));
-  else
-    pl = pli;
-  end
-  
+
   % Get parameters
-  hostname = find(pl, 'hostname');
-  database = find(pl, 'database');
-  user     = find(pl, 'username');
-  passwd   = find(pl, 'password');
   ids      = find(pl, 'id');
   cids     = find(pl, 'cid');
   bin      = find(pl, 'binary');
-  
+
   % Make sure that 'ids' or 'cids' are empty arrays if they are empty.
   % It might be that the GUI return an empty string.
   if isempty(ids)
@@ -48,111 +34,78 @@
   if isempty(cids)
     cids = [];
   end
-  
+
   % Check if some ID is defined
   if isempty(ids) && isempty(cids)
     error('### Please define at least one object ID or connection ID');
   end
-  
-  %%% check if using binary or not: 'yes'/'no' or true/false or
-  %%% 'true'/'false'
+
+  % check if using binary download
   bin = utils.prog.yes2true(bin);
-  
-  % do we have a connection?
-  closeConn = 0;
-  if isempty(conn)
-    closeConn = 1;
-    % Connect to repository
-    conn = utils.jmysql.connect(hostname, database, user, passwd);
-  end
-  if ~isa(conn, 'database') && ~isa(conn, 'mpipeline.repository.RepositoryConnection')
-    error('### connection to the database failed.');
-  end
-  
+
+  % database connection
+  conn = LTPDADatabaseConnectionManager().connect(pl);
+
   if ~isempty(cids)
     for kk=1:numel(cids)
       cid = cids(kk);
-      if isa(conn, 'database')
-        % get the ids from the cid
-        ids = [ids utils.mysql.getObjIds(conn,cid)];
-      else
-        c_ids = double(mpipeline.repository.MySQLUtils.getObjectIDsFromCollectionID(conn, cid));
-        ids = [ids c_ids.'];
-      end
+      % get the ids from the cid
+      ids = [ids utils.repository.getCollectionIDs(conn, cid)];
     end
   end
-  
+
   % Get each ID
   Nids = length(ids);
   objs = [];
   plhout = [];
-  
+
   for kk=1:Nids
-    
+
     %---- copy the input plist because each object should get an other plist
     plh = copy(pl, 1);
-    
+
     %---- This id
     id = ids(kk);
     utils.helper.msg(utils.const.msg.OPROC2, 'retrieving ID %d', id);
-    
-    %---- call database constructor
-    if bin
-      try
+
+    try
+      %---- call database constructor
+      if bin
         obj = ltpda_uo.retrieve(conn, 'binary', id);
-        
-      catch
-        
-        if ~conn.isConnected()
-          error('### There is something wrong with the connection.')
-        end
-        
-        warning('!!! Unable to do binary retrieval for object %d; trying to retrieve XML instead.', id);
+      else
         obj = ltpda_uo.retrieve(conn, id);
       end
-    else
-      obj = ltpda_uo.retrieve(conn, id);
-    end
-    
-    if ~strcmp(class(obj), requested_class)
-      error('### You have used the constructor ''%s'' but the object with id=%d is of class ''%s''', requested_class, id, class(obj));
-    end
-    
-    %  - remove connection object from plist first
-    if isempty(hostname) || isempty(database)
-      if isa(conn, 'database')
-        txt = textscan(conn.URL, '%s', 'Delimiter', '/', 'CollectOutput', 1);
-        plc = plist('hostname', txt{1}{3}, 'database', txt{1}{4});
-      else
-        plc = plist('hostname', char(conn.getHostname), 'database', char(conn.getDatabase));
+
+      if ~strcmp(class(obj), requested_class)
+        error('### You have used the constructor ''%s'' but the object with id=%d is of class ''%s''', requested_class, id, class(obj));
       end
-      plh = combine(pli, plc);
+
+      %---- Set connection parameters in the plist
+      utils.repository.adjustPlist(conn, plh);
+
+      %---- Set only the ID of the current object to the plist
+      plh.pset('id', id);
+
+      %---- Add history-plist to output array
+      plhout = [plhout plh];
+
+      %---- Add to output array
+      objs = [objs obj];
+
+    catch ex
+      % close connection if we own it
+      if isempty(find(pl, 'conn'))
+        conn.close();
+      end
+      throw(ex)
     end
-    
-    %---- remove the connection from the history plist
-    if plh.isparam('conn')
-      plh.remove('conn');
-    end
-    
-    %---- Set only the ID of the current object to the plist
-    plh.pset('ID', id);
-    
-    %---- Add history-plist to output array
-    plhout = [plhout plh];
-    
-    %---- Add to output array
-    objs = [objs obj];
-    
+
   end
-  
-  % close connection
-  if closeConn
-    if isa(conn, 'database')
-      close(conn);
-    else
-      conn.closeConnection;
-    end
+
+  % close connection if we own it
+  if isempty(find(pl, 'conn'))
+    conn.close();
   end
-  
+
 end
 
--- a/m-toolbox/classes/@ltpda_uo/retrieve.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ltpda_uo/retrieve.m	Tue Dec 06 19:07:22 2011 +0100
@@ -33,122 +33,88 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 function varargout = retrieve(varargin)
-  
-  % Check if this is a call for parameters
-  if utils.helper.isinfocall(varargin{:})
-    varargout{1} = getInfo(varargin{3});
-    return
-  end
-  
+
   import utils.const.*
-  utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
-  if nargin == 0
-    help(mfilename);
-    error('### Incorrect inputs');
+  utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
+
+  if numel(varargin) < 2
+    error('### invalid usage');
   end
-  
-  objs = [];
+
+  % connection
   conn = varargin{1};
-  if ~isa(conn, 'mpipeline.repository.RepositoryConnection')
-    error('### the first argument should be a mpipeline.repository.RepositoryConnection connection object.');
+  varargin = varargin(2:end);
+  if ~isa(conn, 'java.sql.Connection')
+    error('### the first argument should be a java.sql.Connection object');
   end
-  
-  % Unlock the connection only if the connection was not locked
-  unlockConnection = ~conn.isLocked();
-  
-  rm = LTPDARepositoryManager;
-  
-  try
-    
-    if ~conn.isConnected
-      if isempty(conn.openConnection());
-        return
-      end
+
+  binary = false;
+  if ischar(varargin{1}) && strcmpi(varargin{1}, 'binary')
+    % binary
+    binary = true;
+    varargin = varargin(2:end);
+    utils.helper.msg(msg.PROC1, 'binary retrieve');
+  end
+
+  if ischar(varargin{1}) && strcmpi(varargin{1}, 'collection')
+    % collection
+    cid = varargin{2};
+    varargin = varargin(3:end);
+    if ~isempty(varargin)
+      error('### wrong number of arguments');
     end
-    
-    conn.setLocked(true);
-    
-    % reload connection table if we have a GUI
-    if ~isempty(rm.gui)
-      rm.gui.reloadConnectionTable();
-    end
+    utils.helper.msg(msg.PROC1, 'retrieving collection %d', cid);
+
+    % get list of object IDs from the collection ID
+    ids = utils.repository.getCollectionIDs(conn, cid);
     
-    % Get username and user id
-    username = char(conn.getUsername);
-    userid   = utils.jmysql.getUserID(conn, username);
-    
-    if ~isempty(userid)
-      utils.helper.msg(msg.PROC1, 'got user id %d for user: %s', userid, username);
-      if userid < 1 || isnan(userid)  || strcmp(userid, 'No Data') || ischar(userid)
-        error('### Unknown username.');
-      end
+  else
+    % IDs list
+    if isnumeric([varargin{:}])
+      ids = [varargin{:}];
     else
-      error('### Could not determine user id. Can not proceed.');
+      error('### invalid usage');
     end
-    
-    binary = false;
-    if nargin >= 3 && ischar(varargin{2}) && strcmpi(varargin{2}, 'binary')
-      %%%  retrieve(conn, 'binary', obj_id_1, obj_id_2)
-      %%%  retrieve(conn, 'binary', 'Collection', coll_id)
-      binary = true;
-      if nargin == 4 && ischar(varargin{3}) && strcmpi(varargin{3}, 'Collection') && isnumeric(varargin{4}) && numel(varargin{4}) == 1
-        cid = varargin{4};
-        % Get a list of object IDs from the collection ID
-        ids = mpipeline.repository.MySQLUtils.getObjectIDsFromCollectionID(conn, cid);
-      elseif nargin >= 3 && isnumeric([varargin{3:end}])
-        ids = [varargin{3:end}];
-      else
-        help(mfilename)
-        error('### Incorrect usage');
-      end
-      
-    elseif nargin == 3 && ischar(varargin{2}) && strcmpi(varargin{2}, 'Collection') && isnumeric(varargin{3}) && numel(varargin{3}) == 1
-      %%%  retrieve(conn, 'Collection', coll_id)
-      cid = varargin{3};
-      % Get a list of object IDs from the collection ID
-      ids = mpipeline.repository.MySQLUtils.getObjectIDsFromCollectionID(conn, cid);
-      
-    elseif nargin >= 2 && isnumeric([varargin{2:end}])
-      %%%  retrieve(conn, obj_id_1, obj_id_2)
-      ids = [varargin{2:end}];
-      
-    else
-      help(mfilename)
-      error('### Incorrect usage');
-    end
-    
-    utils.helper.msg(msg.PROC1, ['retrieving objects ' utils.xml.mat2str(ids)]);
-    
+  end
+
+  utils.helper.msg(msg.PROC1, ['retrieving objects' sprintf(' %d', ids)]);
+
+  % output vector
+  objs = [];
+
+  try
+
+    % get username and user id
+    [username, userid] = utils.repository.getUser(conn);
+
     v = ver('LTPDA');
     for j=1:length(ids)
 
-      % It is only possible to download the object if the object in the
-      % database was submitted with the same or lower LTPDA version as the
-      % current version.
-      q = sprintf('SELECT version FROM objmeta WHERE obj_id=%d', ids(j));
-      try
-      vDb = utils.jmysql.dbquery(conn, q);
-      catch ME
-        disp(ME);
-      end
-      if utils.helper.ver2num(v.Version) < utils.helper.ver2num(vDb{1})
-        error('### The object with the ID %d was submitted with a higher LTPDA version than you use %s. Please update your LTPDA version.', ids(j), vDb{1});
+      rows = utils.mysql.execute(conn, 'SELECT version, obj_type FROM objmeta WHERE obj_id = ?', ids(j));
+      if isempty(rows)
+        error('### object %d not found', ids(j));
       end
-      
-      % Get object
+      objver = rows{1};
+      objtype = rows{2};
+
+      % it is only possible to download the object if the object in the
+      % database was submitted with the same or lower LTPDA version as
+      % the current version
+      if utils.helper.ver2num(v.Version) < utils.helper.ver2num(objver)
+        error(['### object %d was submitted with newer LTPDA version (%s) '...
+               'than this one (%s). please update'], ids(j), objver, v.Version);
+      end
+
       if binary
+        % binary download
+
         % Retrieve the bytes
-        q =  sprintf('select mat from bobjs where obj_id="%d"', ids(j));
-        results = conn.query(q);
-%         dd = '';
-        while results.next
-          dd = results.getObject(1);
+        rows = utils.mysql.execute(conn, 'SELECT mat FROM bobjs WHERE obj_id = ?', ids(j));
+        if isempty(rows)
+          error('### failed to get binary data for object %d', ids(j));
         end
-        
-        if strcmp(dd, 'No Data') || isempty(dd)
-          error('Failed to get binary data for object %d', ids(j));
-        end
+        dd = rows{1};
+
         % Write bytes out to a temp MAT file
         fname = [tempname '.mat'];
         fd = fopen(fname, 'w+');
@@ -160,64 +126,54 @@
         delete(fname);
         % Get the struct out
         obj = obj.objs;
-        % Get the object class
-        scl = char(mpipeline.repository.MySQLUtils.getObjectTypeForID(conn, ids(j)));
 
         % Check if the retrieved object is a struct
         if isstruct(obj)
           % Call the constructor with this struct
-          fcn_name   = [scl '.update_struct'];
+          fcn_name   = [objtype '.update_struct'];
           obj = feval(fcn_name, obj, obj.tbxver);
-          obj = feval(scl, obj);
+          obj = feval(objtype, obj);
         end
         % Add tyo object array
         objs = [objs {obj}];
+
       else
-        xdoc = utils.jmysql.getXdoc(conn, ids(j));
-        if ~isempty(xdoc)
-          obj = utils.xml.xmlread(xdoc);
-          if j==1
-            objs = {obj};
-          else
-            objs = [objs {obj}];
-          end
-          
-          % make transaction entry
-          t     = time();
-          tdate = t.format('yyyy-mm-dd HH:MM:SS');
-          try
-            message = utils.jmysql.insert(conn, ...
-              'transactions',...
-              'obj_id', ids(j),...
-              'user_id', userid,...
-              'transdate', tdate,...
-              'direction', 'out'...
-              );
-            
-            utils.helper.msg(msg.PROC1, 'updated transactions table');
-          catch
-            error('### Failed to make entry in transactions table');
-          end
-        else
-          warning('!!! Error retrieving object: %d', ids(j));
-        end % End empty Xdoc
-      end % End binary
-    end % End id loop
-    
-  catch ME
-    fprintf(2, [ME.message, '\n\n']);
-    conn.setLocked(false);
-    rethrow(ME)
+        % xml download
+
+        % get xml
+        rows = utils.mysql.execute(conn, 'SELECT xml FROM objs WHERE id = ?', ids(j));
+        if isempty(rows)
+          error('### failed to get data for object %d', ids(j));
+        end
+
+        % check xml
+        if strcmp(rows{1}(1:13), 'binary submit')
+          error('### object %d has binary representation only', ids(j));
+        end
+        
+        % parse xml        
+        stream = java.io.StringBufferInputStream(java.lang.String(rows{1}));
+        builder = javax.xml.parsers.DocumentBuilderFactory.newInstance.newDocumentBuilder();
+        xdoc = builder.parse(stream);
+        obj = utils.xml.xmlread(xdoc);
+
+        % add to output array
+        objs = [objs {obj}];
+
+        % make transaction entry
+        t = time().format('yyyy-mm-dd HH:MM:SS', 'UTC');
+        utils.mysql.execute(conn, ['INSERT INTO transactions (obj_id, user_id, transdate, direction) ' ...
+                                   'VALUES (?, ?, ?, ?)'], ids(j), userid, t, 'out');
+        utils.helper.msg(msg.PROC1, 'updated transactions table');
+      end
+
+    end
+
+  catch ex
+    utils.helper.msg(msg.PROC1, '### retrieve error');
+    rethrow(ex)
   end
-  
-  if unlockConnection
-    conn.setLocked(false);
-  end
-  
-  % reset Timer
-  LTPDARepositoryManager.resetTimer(rm.timerClearPass, conn);
-  LTPDARepositoryManager.resetTimer(rm.timerDisconnect, conn);
-      
+
   % Set outputs
   if nargout == 1
     if length(objs) == 1
@@ -231,45 +187,3 @@
     end
   end
 end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                               Local Functions                               %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-function ii = getInfo(varargin)
-  if nargin == 1 && strcmpi(varargin{1}, 'None')
-    sets = {};
-    pl   = [];
-  else
-    sets = {'Default'};
-    pl   = getDefaultPlist;
-  end
-  % Build info object
-  ii = minfo(mfilename, 'ltpda_uo', 'ltpda', utils.const.categories.internal, '$Id: retrieve.m,v 1.29 2011/11/30 06:49:01 hewitson Exp $', sets, pl);
-  ii.setModifier(false);
-end
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-function plout = getDefaultPlist()
-  persistent pl;  
-  if exist('pl', 'var')==0 || isempty(pl)
-    pl = buildplist();
-  end
-  plout = pl;  
-end
-
-function plo = buildplist()
-  plo = plist();
-  
-  p = param({'conn', 'A database object'}, paramValue.EMPTY_DOUBLE);
-  plo.append(p);
-  
-  p = param({'ids', 'IDs which should be collected'}, paramValue.EMPTY_DOUBLE);
-  plo.append(p);
-end
-
-
-
--- a/m-toolbox/classes/@ltpda_uo/submit.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ltpda_uo/submit.m	Tue Dec 06 19:07:22 2011 +0100
@@ -42,25 +42,25 @@
 % then we call validate on the object before submitting. If validate is
 % true, then we set the validated flag in the database after submission if
 % it passes.
-% 
-% 
+%
+%
 
 
 function varargout = submit(varargin)
-  
+
   % check if this is a call for parameters
   if utils.helper.isinfocall(varargin{:})
     varargout{1} = getInfo(varargin{3});
     return
   end
-  
+
   import utils.const.*
   utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
-  
+
   % collect all AOs
   [pls,   invars, rest] = utils.helper.collect_objects(varargin(:), 'plist');
   [sinfo, invars, objs] = utils.helper.collect_objects(rest(:),    'struct');
-  
+
   % identify plists which are only used for the submission process
   mask = false(numel(pls), 1);
   for ii = 1:numel(pls)
@@ -77,22 +77,22 @@
   if sum(~mask)
     pls = combine(pls(~mask));
   end
-  
+
   % rearrange nested objects lists into a single cell array
   objs = flatten(objs);
-  
+
   if isempty(objs)
     error('### input at least one object to submit to the repository');
   end
-  
+
   % combine user plist with default
   pls = fixPlist(pls);
   dpl = getDefaultPlist();
   pls = combine(pls, dpl.pset('HOSTNAME', ''));
-  
+
   % for backwards compatibility convert any user supplied sinfo-structure into a plist
   pls = ltpda_uo.convertSinfo2Plist(pls, sinfo);
-  
+
   % read XML submission informations file
   filename = pls.find('sinfo filename');
   if ~isempty(filename)
@@ -103,106 +103,48 @@
       error('### unable to read specified file: %s', filename);
     end
   end
-  
+
   % collect additional informations
   sinfo = ltpda_uo.submitDialog(pls);
   if isempty(sinfo)
     [varargout{1}, varargout{2}] = userCanceled();
     return
   end
-  
+
   % check completeness of user supplied informations
   sinfo = checkSinfo(sinfo);
-  
-  % user supplied connection
-  conn = find(pls, 'conn');
-  
-  % obtain a connection from the connection manager
-  rm = LTPDARepositoryManager();
-  
-  if isempty(conn)
-    connections = rm.findConnections(pls);
-    if isempty(connections)
-      % no connection found. create a new one
-      conn = rm.newConnection(pls);
-      if isempty(conn)
-        [varargout{1}, varargout{2}] = userCanceled();
-        return
-      end
-    elseif numel(connections) == 1 && ~utils.prog.yes2true(pls.find('use selector'))
-      % found only one connection and we are not forcing the use of the selector
-      conn = connections(1);
-    else
-      % make the user select the desired database connection
-      conn = rm.manager.selectConnection([]);
-      if isempty(conn)
-        [varargout{1}, varargout{2}] = userCanceled();
-        return
-      end
-    end
-  end
-  
-  % avoid to ask for a password if one was specified in the plist
-  if isjava(conn) && ~conn.isConnected()
-    passwd = pls.find('password');
-    if ~isempty(passwd)
-      conn.setPassword(passwd);
-    end
-  end
-  
-  % connect to the database
-  if isempty(conn.openConnection())
-    error('### unable to connect to the database')
-  end
-  
+
+  % database connection
+  c = LTPDADatabaseConnectionManager().connect(pls);
+
   utils.helper.msg(msg.PROC1, 'submitting %d objects to repository', numel(objs));
-  
+
   try
-    % lock connection to avoid expire during processing
-    conn.setLocked(true);
-    
-    % reload connection table if we have a GUI
-    if ~isempty(rm.gui)
-      rm.gui.reloadConnectionTable();
-    end
-    
-    % look-up user id
-    userid   = utils.jmysql.getUserID(conn);
-    username = conn.getUsername();
-    
-    utils.helper.msg(msg.PROC1, 'got user id %d for user: %s', userid, char(username));
-    if userid < 1 || isnan(userid)  || strcmp(userid, 'No Data') || ischar(userid)
-      error('### Unknown username.');
-    end
+    % get username and userid
+    [username, userid] = utils.repository.getUser(c);
 
     % author of the data: let's take the username
     author = username;
-    
+
     % date for the transaction.transdata and objmeta.submitted columns as UTC time string
     t     = time();
     tdate = format(t, 'yyyy-mm-dd HH:MM:SS', 'UTC');
-    
+
     % machine details
     prov = provenance();
-    
-    utils.helper.msg(msg.IMPORTANT, 'submitting to %s@%s:%s', ...
-      char(conn.getUsername), char(conn.getHostname), char(conn.getDatabase));
-    
-    % obtain the underlying connection
-    c = conn.getConn();
-    
+
     % start a transaction. either we submitt all objects or we roll back all changes
     c.setAutoCommit(false);
-    
+
     % process each object and collect id numbers
     ids = zeros(numel(objs), 1); cid = [];
     for kk = 1:numel(objs)
-      
+
       % this object
       obj = objs{kk};
-      
+
       utils.helper.msg(msg.PROC1, 'submitting object: %s / %s', class(obj), obj.name);
-      
+
       % format object creation time as UTC time string
       if isa(obj, 'plist')
         % plist-objects stores creatins time as milli secs since the epoch
@@ -210,13 +152,13 @@
       else
         created = obj.created.format('yyyy-mm-dd HH:MM:SS', 'UTC');
       end
-      
+
       % Set the UUID if it is empty. This should only happen for PLIST
       % objects.
       if isempty(obj.UUID)
         obj.UUID = char(java.util.UUID.randomUUID);
       end
-      
+
       % create an XML representaion of the object
       if utils.prog.yes2true(pls.find('binary'));
         utils.helper.msg(msg.PROC2, 'binary submit');
@@ -225,16 +167,16 @@
         utils.helper.msg(msg.PROC2, 'xml submit');
         otxt = utils.prog.obj2xml(obj);
       end
-      
+
       % create an MD5 hash of the xml representation
       md5hash = utils.prog.hash(otxt, 'MD5');
-      
+
       % create a binary representaion of the object
       bobj = utils.prog.obj2binary(obj);
       if isempty(bobj)
         error('### failed to obtain a binary representation');
       end
-      
+
       % submit object to objs table
       stmt = c.prepareStatement(...
         'INSERT INTO objs (xml, hash, uuid) VALUES (?, ?, ?)');
@@ -242,7 +184,7 @@
       stmt.setObject(2, char(md5hash));
       stmt.setObject(3, obj.UUID);
       stmt.executeUpdate();
-      
+
       % obtain object id
       rs = stmt.getGeneratedKeys();
       if rs.next()
@@ -252,7 +194,7 @@
       end
       rs.close();
       stmt.close();
-      
+
       % insert binary representation
       stmt = c.prepareStatement(...
         'INSERT INTO bobjs (obj_id, mat) VALUES (?,?)');
@@ -260,14 +202,14 @@
       stmt.setObject(2, bobj);
       stmt.execute();
       stmt.close();
-      
+
       % reference IDs are stored in a CSV string
       if ischar(sinfo.reference_ids)
         refids = sinfo.reference_ids;
       else
         refids = utils.prog.csv(sinfo.reference_ids);
       end
-      
+
       % insert object meta data
       stmt = c.prepareStatement(...
         [ 'INSERT INTO objmeta (obj_id, obj_type, name, created, version, ' ...
@@ -294,18 +236,18 @@
       stmt.setObject(18, java.lang.String(author));
       stmt.execute();
       stmt.close();
-      
+
       % update other meta-data tables
-      cols = utils.jmysql.execute(c, 'SHOW COLUMNS FROM tsdata');
+      cols = utils.mysql.execute(c, 'SHOW COLUMNS FROM tsdata');
       if utils.helper.ismember('obj_id',  cols(:,1))
         % the tsdata table contains an obj id column. use the new database schema
-        utils.jmysql.insertObjMetadata(c, obj, objid);
+        utils.repository.insertObjMetadata(c, obj, objid);
       else
         % otherwise use the old one
         utils.helper.msg(msg.PROC2, 'using back-compatibility code');
-        utils.jmysql.insertObjMetadataV1(c, obj, objid);
+        utils.repository.insertObjMetadataV1(c, obj, objid);
       end
-      
+
       % update transactions table
       stmt = c.prepareStatement(...
         'INSERT INTO transactions (obj_id, user_id, transdate, direction) VALUES (?, ?, ?, ?)');
@@ -315,21 +257,21 @@
       stmt.setObject(4, java.lang.String('in'));
       stmt.execute();
       stmt.close();
-      
+
       % collect the id of the submitted object
       ids(kk) = objid;
     end
-    
+
     % make collection entry
     if numel(objs) > 1
-      
+
       % insert record into collections table
       stmt = c.prepareStatement(...
         'INSERT INTO collections (nobjs, obj_ids) VALUES (?, ?)');
       stmt.setObject(1, length(ids));
       stmt.setObject(2, java.lang.String(utils.prog.csv(ids)));
       stmt.executeUpdate();
-      
+
       % obtain collection id
       rs = stmt.getGeneratedKeys();
       if rs.next()
@@ -339,35 +281,32 @@
       end
       rs.close();
       stmt.close();
-      
+
     end
-    
+
   catch ex
     utils.helper.msg(msg.IMPORTANT, 'submission error. no object submitted')
     c.close()
-    conn.setLocked(false);
     rethrow(ex)
   end
-  
+
   % commit the transaction
   c.commit();
-  
+
+  % close the connection if we own it
+  if isempty(find(pls, 'conn'))
+    c.close();
+  end
+
   % report IDs of the inserted objects
   for kk = 1:numel(objs)
-    utils.helper.msg(msg.IMPORTANT, 'submitted %s object with ID: %d, UUID: %s, name: %s', ...
+    utils.helper.msg(msg.IMPORTANT, 'submitted %s object with ID: %d UUID: %s name: %s', ...
       class(objs{kk}), ids(kk), objs{kk}.UUID, objs{kk}.name);
   end
   if ~isempty(cid)
     utils.helper.msg(msg.IMPORTANT, 'made collection entry with ID: %d', cid);
   end
-  
-  % unlock connection expire
-  conn.setLocked(false);
-  
-  % reset timer
-  LTPDARepositoryManager.resetTimer(rm.timerClearPass, conn);
-  LTPDARepositoryManager.resetTimer(rm.timerDisconnect, conn);
-  
+
   % pass back outputs
   if nargout > 0
     varargout{1} = ids;
@@ -389,23 +328,23 @@
 
 function sinfo = checkSinfo(sinfo)
   % check sinfo structure
-  
+
   import utils.const.*
-  
+
   % fieldnames
   mainfields = {'experiment_title', 'experiment_description', 'analysis_description'};
   extrafields = {'quantity', 'keywords', 'reference_ids', 'additional_comments', 'author', 'additional_authors'};
-  
+
   % fieldnames of the input structure
   fnames = fieldnames(sinfo);
-  
+
   % check mandatory fields
   for jj = 1:length(mainfields)
     if ~ismember(fnames, mainfields{jj})
       error('### the sinfo structure should contain a ''%s'' field', mainfields{jj});
     end
   end
-  
+
   % check extra fields
   for jj = 1:length(extrafields)
     if ~ismember(fnames, extrafields{jj})
@@ -413,7 +352,7 @@
       sinfo.(extrafields{jj}) = '';
     end
   end
-  
+
   % additional checks
   if length(sinfo.experiment_title) < 5
     error('### ''experiment title'' should be at least 5 characters long');
@@ -424,7 +363,7 @@
   if length(sinfo.analysis_description) < 10
     error('### ''analysis description'' should be at least 10 characters long');
   end
-  
+
 end
 
 
@@ -451,12 +390,12 @@
 end
 
 function plo = buildplist()
-  
+
   plo = plist.TO_REPOSITORY_PLIST;
-  
+
   p = param({'sinfo filename', 'Path to an XML file containing submission metadata'}, paramValue.EMPTY_STRING);
   plo.append(p);
-  
+
   p = param({'binary', 'Submit only binary version of the objects'}, paramValue.FALSE_TRUE);
   plo.append(p);
 end
@@ -474,23 +413,23 @@
 
 function flat = flatten(objs)
   % flatten nested lists into a single cell array
-  
+
   flat = {};
-  
+
   while iscell(objs) && numel(objs) == 1
     objs = objs{1};
   end
-  
+
   if numel(objs) == 1
     flat = {objs};
     return;
   end
-  
+
   for jj = 1:numel(objs)
     obj = flatten(objs(jj));
     for kk = 1:numel(obj)
       flat = [ flat obj(kk) ];
     end
   end
-  
+
 end
--- a/m-toolbox/classes/@ltpda_uo/submitDialog.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ltpda_uo/submitDialog.m	Tue Dec 06 19:07:22 2011 +0100
@@ -55,7 +55,6 @@
   if ~isempty(sinfo.additional_comments), jsinfo.setAdditionalComments(sinfo.additional_comments); end
   if ~isempty(sinfo.additional_authors), jsinfo.setAdditionalAuthors(sinfo.additional_authors); end
   
-%   sid = awtcreate('mpipeline.repository.SubmitInfoDialog', 'Lmpipeline.main.MainWindow;Lmpipeline.repository.SubmissionInfo;', [], jsinfo);
   sid = javaObjectEDT('mpipeline.repository.SubmitInfoDialog', [], jsinfo);
   
   h1 = handle(sid.getLoadBtn,'callbackproperties');
--- a/m-toolbox/classes/@ltpda_uo/update.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ltpda_uo/update.m	Tue Dec 06 19:07:22 2011 +0100
@@ -74,60 +74,14 @@
   else
     sinfo = [];
   end
-  
-  % user supplied connection
-  conn = find(pls, 'conn');
+
+  % database connection
+  c = LTPDADatabaseConnectionManager().connect(pls);
   
-  if isempty(conn)
-    % obtain a connection from the connection manager
-    rm = LTPDARepositoryManager();
-    connections = rm.findConnections(pls);
-    if isempty(connections)
-      % no connection found. create a new one
-      conn = rm.newConnection(pls);
-      if isempty(conn)
-        [varargout{1}, varargout{2}] = userCanceled();
-        return
-      end
-    elseif numel(connections) == 1 && ~utils.prog.yes2true(pls.find('use selector'))
-      % found only one connection and we are not forcing the use of the selector
-      conn = connections(1);
-    else
-      % make the user select the desired database connection
-      conn = rm.manager.selectConnection([]);
-      if isempty(conn)
-        [varargout{1}, varargout{2}] = userCanceled();
-        return
-      end
-    end
-  end
-  
-  % avoid to ask for a password if one was specified in the plist
-  if isjava(conn) && ~conn.isConnected()
-    passwd = pls.find('password');
-    if ~isempty(passwd)
-      conn.setPassword(passwd);
-    end
-  end
-  
-  % connect to the database
-  if isempty(conn.openConnection())
-    error('### unable to connect to the database')
-  end
-  
-  try
-    % lock connection to avoid expire during processing
-    conn.setLocked(true);
-    
+  try    
     % look-up user id
-    userid   = utils.jmysql.getUserID(conn);
-    username = conn.getUsername();
-    
-    utils.helper.msg(msg.PROC1, 'got user id %d for user: %s', userid, char(username));
-    if userid < 1 || isnan(userid)  || strcmp(userid, 'No Data') || ischar(userid)
-      error('### Unknown username.');
-    end
-    
+    [username, userid] = utils.repository.getUser(c);
+
     % author of the data: let's take the username
     author = username;
     
@@ -137,13 +91,7 @@
     
     % machine details
     prov = provenance();
-    
-    utils.helper.msg(msg.IMPORTANT, 'submitting to %s@%s:%s', ...
-      char(conn.getUsername), char(conn.getHostname), char(conn.getDatabase));
-    
-    % obtain the underlying connection
-    c = conn.getConn();
-    
+            
     % start a transaction. either we submitt all objects or we roll back all changes
     c.setAutoCommit(false);
     
@@ -252,32 +200,31 @@
     end
     
     % update other meta-data tables
-    cols = utils.jmysql.execute(c, 'SHOW COLUMNS FROM tsdata');
+    cols = utils.mysql.execute(c, 'SHOW COLUMNS FROM tsdata');
     if utils.helper.ismember('obj_id',  cols(:,1))
       % the tsdata table contains an obj id column. use the new database schema
-      utils.jmysql.updateObjMetadata(c, obj, objid);
+      utils.repository.updateObjMetadata(c, obj, objid);
     else
       % otherwise use the old one
       utils.helper.msg(msg.PROC2, 'using back-compatibility code');
-      utils.jmysql.updateObjMetadataV1(c, obj, objid);
+      utils.repository.updateObjMetadataV1(c, obj, objid);
     end
     
   catch ex
-    utils.helper.msg(msg.IMPORTANT, 'update error. no object updated')
-    c.close()
-    conn.setLocked(false);
+    % close connection if we own it
+    if isempty(find(pls, 'conn'))
+      c.close();
+    end
     rethrow(ex)
   end
   
   % commit the transaction
   c.commit();
   
-  conn.setLocked(false);
-  
-  % reset timer
-  rm = LTPDARepositoryManager();
-  LTPDARepositoryManager.resetTimer(rm.timerClearPass, conn);
-  LTPDARepositoryManager.resetTimer(rm.timerDisconnect, conn);
+  % close connection if we own it
+  if isempty(find(pls, 'conn'))
+    c.close();
+  end
   
 end
 
--- a/m-toolbox/classes/@matrix/matrix.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@matrix/matrix.m	Tue Dec 06 19:07:22 2011 +0100
@@ -151,7 +151,7 @@
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
             obj = obj.fromInput(plist('objs', varargin), callerIsMethod);
             
-          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) ...
+          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) ...
               && isnumeric(varargin{2})
             %%%%%%%%%%  f = matrix(<database-object>, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
--- a/m-toolbox/classes/@mfir/mfir.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@mfir/mfir.m	Tue Dec 06 19:07:22 2011 +0100
@@ -222,7 +222,7 @@
             utils.helper.msg(msg.OPROC1, 'constructing from AO %s', varargin{1}.name);
             obj = fromAO(obj, pset(varargin{2}, 'AO', varargin{1}));
             
-          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) ...
+          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) ...
               && isnumeric(varargin{2})
             %%%%%%%%%%  f = mfir(<database-object>, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
--- a/m-toolbox/classes/@miir/miir.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@miir/miir.m	Tue Dec 06 19:07:22 2011 +0100
@@ -248,7 +248,7 @@
           plf = combine(plist('parfrac', varargin{1}),varargin{2});
           obj =  fromParfrac(obj, plf);
           
-        elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+        elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
           %%%%%%%%%%  f = miir(<database-object>, [IDs])   %%%%%%%%%%
           utils.helper.msg(msg.OPROC1, 'retrieve from repository');
           obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
--- a/m-toolbox/classes/@parfrac/parfrac.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@parfrac/parfrac.m	Tue Dec 06 19:07:22 2011 +0100
@@ -202,7 +202,7 @@
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%% Two inputs %%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  f = parfrac(<database-object>, [IDs])   %%%%%%%%%%
             % parfrac(<database-object>, [IDs])
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
--- a/m-toolbox/classes/@pest/pest.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@pest/pest.m	Tue Dec 06 19:07:22 2011 +0100
@@ -305,7 +305,7 @@
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%   two input   %%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  obj = pest(<database-object>, [IDs])   %%%%%%%%%%
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
             
--- a/m-toolbox/classes/@plist/plist.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@plist/plist.m	Tue Dec 06 19:07:22 2011 +0100
@@ -163,7 +163,7 @@
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%   two inputs   %%%%%%%%%%%%%%%%%%%%%%%%%%%%
         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
         
-        if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection'))
+        if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection'))
           %%%%%%%%%%%   From DATABASE   %%%%%%%%%%%
           utils.helper.msg(msg.OPROC1, 'constructing from database object');
           pl = pl.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
@@ -318,20 +318,9 @@
     % user-object constructor default plists for the 'From Repository' set.
     function pl = FROM_REPOSITORY_PLIST
       pl = plist();
-      
-      % get repository list
-      prefs = getappdata(0, 'LTPDApreferences');
-      hostNames = prefs.getRepoPrefs.getHostnames;
-      repos = {};
-      for ii=0:hostNames.size()-1
-        repos = [repos {hostNames.get(ii)}];
-      end
-      
+            
       % Hostname
-      if isempty(repos)
-        repos = {'localhost'};
-      end
-      p = param({'hostname','The repository hostname'}, {1, repos, paramValue.SINGLE});
+      p = param({'hostname','The repository hostname'},  paramValue.EMPTY_STRING);
       pl.append(p);
       
       % ID
@@ -365,19 +354,8 @@
     function pl = TO_REPOSITORY_PLIST
       pl = plist();
       
-      % get repository list
-      prefs = getappdata(0, 'LTPDApreferences');
-      hostNames = prefs.getRepoPrefs.getHostnames;
-      repos = {};
-      for ii=0:hostNames.size()-1
-        repos = [repos {hostNames.get(ii)}];
-      end
-      
       % Hostname
-      if isempty(repos)
-        repos = {'localhost'};
-      end
-      p = param({'hostname', 'Repository server hostname'}, {1, repos, paramValue.SINGLE});
+      p = param({'hostname', 'Repository server hostname'},  paramValue.EMPTY_STRING);
       pl.append(p);
       
       % Database
@@ -427,9 +405,6 @@
       p = param({'no dialog', 'Do not use of the submission form. Mandatory fields must be supplied in the plist.'}, paramValue.FALSE_TRUE);
       pl.append(p);
       
-      p = param({'use selector', 'Allow to select to which database to connect'}, paramValue.TRUE_FALSE);
-      pl.append(p);
-      
     end
     
     % Plist for Welch-based, linearly spaced spectral estimators.
--- a/m-toolbox/classes/@pzmodel/pzmodel.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@pzmodel/pzmodel.m	Tue Dec 06 19:07:22 2011 +0100
@@ -191,7 +191,7 @@
           %%%%%%%%%%%%% Two inputs %%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           
-          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  f = pzmodel(<database-object>, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
--- a/m-toolbox/classes/@rational/rational.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@rational/rational.m	Tue Dec 06 19:07:22 2011 +0100
@@ -180,7 +180,7 @@
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%% Two inputs %%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  f = rational(<database-object>, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
--- a/m-toolbox/classes/@smodel/smodel.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@smodel/smodel.m	Tue Dec 06 19:07:22 2011 +0100
@@ -311,7 +311,7 @@
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%   two input   %%%%%%%%%%%%%%%%%%%%%%%%%%%
           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          if (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  mdl = smodel(<database-object>, [IDs])   %%%%%%%%%%
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
             
--- a/m-toolbox/classes/@ssm/ssm.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@ssm/ssm.m	Tue Dec 06 19:07:22 2011 +0100
@@ -617,7 +617,7 @@
               s.validate();
             end
             
-          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  s = ssm(<database-object>, [IDs])   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
             s = s.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
--- a/m-toolbox/classes/@timespan/timespan.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@timespan/timespan.m	Tue Dec 06 19:07:22 2011 +0100
@@ -215,7 +215,7 @@
             pli = plist('startT', varargin{1}, 'endT', varargin{2});
             obj = obj.fromTimespanDef(pli);
 
-          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'mpipeline.repository.RepositoryConnection')) && isnumeric(varargin{2})
+          elseif (isa(varargin{1}, 'database') || isa(varargin{1}, 'java.sql.Connection')) && isnumeric(varargin{2})
             %%%%%%%%%%  f = timespan(database, IDs)   %%%%%%%%%%
             utils.helper.msg(msg.OPROC1, 'retrieve from repository');
             obj = obj.fromRepository(plist('conn', varargin{1}, 'id', varargin{2}));
--- a/m-toolbox/classes/@workspaceBrowser/cb_query.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@workspaceBrowser/cb_query.m	Tue Dec 06 19:07:22 2011 +0100
@@ -9,27 +9,19 @@
 function cb_query(varargin)
   
   wb = getappdata(0, 'WorkspaceBrowser');
-  
-  % Get a connection from the repository manager
-  rm = LTPDARepositoryManager;
-  conn = rm.manager.selectConnection([]);
+    
+  % Get a connection from the database connection manager
+  conn = LTPDADatabaseConnectionManager().connect();
+
+  % Get submission info from the user
+  rqd = awtcreate('mpipeline.repository.RepositoryQueryDialog', 'Lmpipeline.main.MainWindow;ZLjava.sql.Connection;Z', [], false, conn, false);
+  awtinvoke(rqd, 'setVisible', 'true');
+    
+  hExec = handle(rqd.getExecuteBtn(),'callbackproperties');
+  hExec.ActionPerformedCallback = @cb_executeQuery;
   
-  if ~isempty(conn)
-    % Update
-    if ~isempty(rm.gui)
-      awtinvoke(rm.gui, 'reloadConnectionTable()');
-    end
-    % Get submission info from the user
-    rqd = awtcreate('mpipeline.repository.RepositoryQueryDialog', 'Lmpipeline.main.MainWindow;ZLmpipeline.repository.RepositoryConnection;Z', [], false, conn, false);
-    awtinvoke(rqd, 'setVisible', 'true');
-    
-    hExec = handle(rqd.getExecuteBtn(),'callbackproperties');
-    hExec.ActionPerformedCallback = @cb_executeQuery;
-    
-    hGuiCloses1 = handle(rqd, 'callbackproperties');
-    hGuiCloses1.WindowClosedCallback = @cb_guiClosed1;
-    
-  end
+  hGuiCloses1 = handle(rqd, 'callbackproperties');
+  hGuiCloses1.WindowClosedCallback = @cb_guiClosed1;
   
   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   function cb_guiClosed1(varargin)
@@ -53,37 +45,27 @@
     jQueryTextField = awtinvoke(rqd, 'getQueryTxtField()');
     jQuery = awtinvoke(jQueryTextField, 'getText()');
     
-    if ~(awtinvoke(conn, 'isConnected()'))
-      awtinvoke(conn, 'openConnection()');
-    end
-    
-    if (awtinvoke(conn, 'isConnected()'))
+    jStmt = awtinvoke(conn, 'createStatement()');
       
-      % lock connection
-      awtinvoke(conn, 'setLocked(Z)', true);
-      jStmt = awtinvoke(conn, 'createStatement()');
-      
-      try
-        
-        jResult = awtinvoke(jStmt, 'executeQuery(Ljava.lang.String;)', jQuery);
+    try
         
-        % pass to query results table
-        qrt = awtcreate('mpipeline.repository.QueryResultsTableDialog', 'Lmpipeline.main.MainWindow;ZLjava.sql.ResultSet;Ljava.lang.String;Z', [], false, jResult, jQuery, false);
-        awtinvoke(qrt, 'setUsedConn(Lmpipeline.repository.RepositoryConnection;)', conn);
-        awtinvoke(qrt, 'setVisible(Z)', 'true');
-        
-        hRetrieve = handle(qrt.getCreateConstructors,'callbackproperties');
-        hRetrieve.ActionPerformedCallback = @cb_retrieveObjectsFromTable;
-        
-        hGuiCloses2 = handle(qrt, 'callbackproperties');
-        hGuiCloses2.WindowClosedCallback = @cb_guiClosed2;
-        
-      catch err
-        fprintf(2, [err.message, '\n']);
-      end
-      awtinvoke(conn, 'setLocked(Z)', false);
+      jResult = awtinvoke(jStmt, 'executeQuery(Ljava.lang.String;)', jQuery);
+      
+      % pass to query results table
+      qrt = awtcreate('mpipeline.repository.QueryResultsTableDialog', 'Lmpipeline.main.MainWindow;ZLjava.sql.ResultSet;Ljava.lang.String;Z', [], false, jResult, jQuery, false);
+      awtinvoke(qrt, 'setUsedConn(Ljava.sql.Connection;)', conn);
+      awtinvoke(qrt, 'setVisible(Z)', 'true');
       
+      hRetrieve = handle(qrt.getCreateConstructors,'callbackproperties');
+      hRetrieve.ActionPerformedCallback = @cb_retrieveObjectsFromTable;
+      
+      hGuiCloses2 = handle(qrt, 'callbackproperties');
+      hGuiCloses2.WindowClosedCallback = @cb_guiClosed2;
+      
+    catch err
+      fprintf(2, [err.message, '\n']);
     end
+      
     
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     function cb_guiClosed2(varargin)
--- a/m-toolbox/classes/@workspaceBrowser/cb_retrieve.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@workspaceBrowser/cb_retrieve.m	Tue Dec 06 19:07:22 2011 +0100
@@ -10,28 +10,16 @@
   
   wb = getappdata(0, 'WorkspaceBrowser');
   
-  % Get a connection from the repository manager
-  rm = LTPDARepositoryManager;
-  conn = rm.manager.selectConnection([]);
+  % Get a connection from the database connection manager
+  conn = LTPDADatabaseConnectionManager().connect();
   
-  if ~isempty(conn) && conn.isConnected
-    try
-      % Get submission info from the user
+  warning('off', 'MATLAB:JavaEDTAutoDelegation');
+  qb = mpipeline.repository.RepositoryRetrieveDialog([], true);
+  qb.setVisible(true);
+  warning('on', 'MATLAB:JavaEDTAutoDelegation');
       
-      warning('off', 'MATLAB:JavaEDTAutoDelegation');
-      qb = mpipeline.repository.RepositoryRetrieveDialog([], true);
-      qb.setVisible(true);
-      warning('on', 'MATLAB:JavaEDTAutoDelegation');
-      
-      if ~qb.isCancelled
-        
-        workspaceBrowser.retrieveObjectsFromDialog(qb, conn);
-        
-      end
-      
-    catch err
-      fprintf(2, [err.message, '\n']);
-    end
+  if ~qb.isCancelled        
+    workspaceBrowser.retrieveObjectsFromDialog(qb, conn);
   end
   
 end
--- a/m-toolbox/classes/@workspaceBrowser/retrieveObjectsFromDialog.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@workspaceBrowser/retrieveObjectsFromDialog.m	Tue Dec 06 19:07:22 2011 +0100
@@ -6,8 +6,8 @@
   if ~isa(varargin{1}, 'mpipeline.repository.RepositoryRetrieveDialog')
     error('### The first input must be a mpipeline.repository.RepositoryRetrieveDialog');
   end
-  if ~isa(varargin{2}, 'mpipeline.repository.RepositoryConnection')
-    error('### The first input must be a mpipeline.repository.RepositoryConnection');
+  if ~isa(varargin{2}, 'java.sql.Connection')
+    error('### The first input must be a java.sql.Connection');
   end
     
   qb   = varargin{1};
@@ -75,9 +75,9 @@
     disp(sprintf('+ retrieving object %d', ids(j)));
     
     % determine object type
-    tt = char(mpipeline.repository.MySQLUtils.getObjectTypeForID(conn, ids(j)));
-    
-    if isempty(tt) || strcmp(tt, 'No Data')
+    try
+      tt = utils.repository.getObjectType(conn, ids(j));
+    catch
       utils.helper.errorDlg('Object type is unknown. Does this object really exist?');
       return
     end
@@ -89,13 +89,9 @@
     obj_names = [obj_names {objname}];
     
     % Retrieve object
-    hostname = char(conn.getHostname);
-    db = char(conn.getDatabase);
-    % add history
-    pl = plist('hostname', hostname, 'database', db, 'ID', ids(j), 'conn', conn);
+    pl = plist('id', ids(j), 'conn', conn);
     if retrieveBinary
-      pl.append('Binary', 'yes');
-      disp(sprintf('*** performing binary retrieval.'));
+      pl.append('binary', 'yes');
     end
     obj = eval(sprintf('%s(pl);', tt));
     
@@ -107,27 +103,17 @@
   for k=1:length(cids)
     
     % get Ids from Cid
-    ids = mpipeline.repository.MySQLUtils.getObjectIDsFromCollectionID(conn, cids(k));
+    ids = utils.repository.getCollectionIDs(conn, cids(k));
     if isempty(ids)
       error('### This collection doesn''t seem to exist.');
     end
     
     for j=1:length(ids)
       disp(sprintf('+ retrieving collection %d : %d', cids(k), ids(j)));
-      tt = char(mpipeline.repository.MySQLUtils.getObjectTypeForID(conn, ids(j)));
+      tt = utils.repository.getObjectType(conn, ids(j));
       if ismember(tt, utils.helper.ltpda_userclasses)
         % Retrieve object
-        if isa(conn, 'database')
-          ipbits = regexp(conn.URL, '([0-9]+)', 'match');
-          ip = [ipbits{1} '.' ipbits{2} '.' ipbits{3} '.' ipbits{4}];
-          db = regexp(conn.URL, '/', 'split');
-          db = db{end};
-        else
-          ip = conn.getHostname;
-          db = conn.getDatabase;
-        end
-        % add history
-        pl = plist('hostname', ip, 'database', db, 'ID', ids(j), 'conn', conn);
+        pl = plist('id', ids(j), 'conn', conn);
         obj = eval(sprintf('%s(pl);', tt));
         
         objname = sprintf('%sC%03d_%03d', prefix, cids(k), ids(j));
--- a/m-toolbox/classes/@workspaceBrowser/workspaceBrowser.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/@workspaceBrowser/workspaceBrowser.m	Tue Dec 06 19:07:22 2011 +0100
@@ -97,11 +97,7 @@
         %--- Retrieve button
         wb.h9 = handle(wb.hdl.getRetrieveBtn,'callbackproperties');
         wb.h9.ActionPerformedCallback = @workspaceBrowser.cb_retrieve;
-        
-        %--- repository Manager button
-        wb.h10 = handle(wb.hdl.getRepositoryManagerBtn,'callbackproperties');
-        wb.h10.ActionPerformedCallback = @workspaceBrowser.cb_repoManager;
-        
+                
         % Store the java gui in the application workspace
         setappdata(0, 'WorkspaceBrowser', wb);
         
--- a/m-toolbox/classes/tests/@ltpda_test_runner/run_test_list.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/@ltpda_test_runner/run_test_list.m	Tue Dec 06 19:07:22 2011 +0100
@@ -30,7 +30,7 @@
 %         fprintf('\b pass\n');
       catch Me
         runner.appendErrorResult(t.utp, mth, Me);
-        fprintf(2,'%s\n', Me.message);
+        fprintf(2,'%s\n', Me.getReport());
       end
       
     end
--- a/m-toolbox/classes/tests/database/@ltpda_ao_table/test_ao_data_id.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_ao_table/test_ao_data_id.m	Tue Dec 06 19:07:22 2011 +0100
@@ -31,8 +31,8 @@
         dataID1 = getDataIdFromAoTable(utp, utp.objIds(nn));
         
         % Create query to get the field 'id' from the data table (e.g. 'fsdata')
-        query   = sprintf('SELECT id FROM %s ORDER BY id DESC LIMIT 0,1', class(utp.testData(nn).data));
-        dataID2 = executeQuery(utp, query);
+        query = sprintf('SELECT id FROM %s ORDER BY id DESC LIMIT 0,1', class(utp.testData(nn).data));
+        dataID2 = utils.mysql.execute(utp.conn, query);
         
         % ATTENTION: This test assumes that we have committed only one AO
         %            with each data-type.
@@ -41,7 +41,7 @@
         
       end
     catch Me
-      throw(Me);
+      rethrow(Me);
     end
     
     varargout{1} = sprintf('Test the field ''%s'' of the database table ''%s'' with the database %s ', tableField, dbTable, utp.testRunner.repositoryPlist.find('database'));
--- a/m-toolbox/classes/tests/database/@ltpda_cdata_table/getTableEntry.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_cdata_table/getTableEntry.m	Tue Dec 06 19:07:22 2011 +0100
@@ -18,8 +18,8 @@
       assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID));
       
       % Create query to get the field 'xunits' from the 'cdata' table
-      query = sprintf('SELECT %s FROM %s WHERE %s.id=%d', tableField, dbTable, dbTable, dataID{1});
-      val   = executeQuery(utp, query);
+      query = sprintf('SELECT %s FROM %s WHERE %s.id = ?', tableField, dbTable, dbTable);
+      val = utils.mysql.execute(utp.conn, query, dataID{1});
     catch Me
       rethrow(Me);
     end
@@ -29,7 +29,5 @@
   else
     throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.'));
   end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+
 end
--- a/m-toolbox/classes/tests/database/@ltpda_database/executeQuery.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_database/executeQuery.m	Tue Dec 06 19:07:22 2011 +0100
@@ -1,22 +1,11 @@
 %
 % DESCRIPTION: Returns the result for a given query.
 %
+% DEPRECATED! Use utils.mysql.execute instead.
+%
 % VERSION:     $Id: executeQuery.m,v 1.1 2011/05/25 16:20:25 ingo Exp $
 %
 function val = executeQuery(utp, query)
-  
-  utp.conn.setLocked(true);
-  utp.conn.openConnection();
-  c = utp.conn.getConn();
-  
-  try
-    val = utils.jmysql.execute(c, query);
-  catch Me
-    utp.conn.setLocked(false);
-    utp.conn.closeConnection();
-    rethrow(Me);
-  end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+  warning('!!! Deprecated! Use utils.mysql.execute instead');
+  val = utils.mysql.execute(utp.conn, query);
 end
--- a/m-toolbox/classes/tests/database/@ltpda_database/getDataIdFromAoTable.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_database/getDataIdFromAoTable.m	Tue Dec 06 19:07:22 2011 +0100
@@ -5,20 +5,8 @@
 % VERSION:     $Id: getDataIdFromAoTable.m,v 1.1 2011/05/25 16:23:53 ingo Exp $
 %
 function val = getDataIdFromAoTable(utp, objID)
-  
-  utp.conn.setLocked(true);
-  utp.conn.openConnection();
-  c = utp.conn.getConn();
-  
-  q = sprintf('SELECT data_id FROM ao WHERE ao.obj_id=%d', objID);
-  try
-    val = utils.jmysql.execute(c, q);
-  catch Me
-    utp.conn.setLocked(false);
-    utp.conn.closeConnection();
-    rethrow(Me);
-  end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+
+  q = sprintf('SELECT data_id FROM ao WHERE ao.obj_id = ?');
+  val = utils.mysql.execute(utp.conn, q, objID);
+
 end
--- a/m-toolbox/classes/tests/database/@ltpda_database/getTableEntry.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_database/getTableEntry.m	Tue Dec 06 19:07:22 2011 +0100
@@ -5,20 +5,8 @@
 % VERSION:     $Id: getTableEntry.m,v 1.2 2011/05/25 16:20:37 ingo Exp $
 %
 function val = getTableEntry(utp, dbTable, tableField, objID)
-  
-  utp.conn.setLocked(true);
-  utp.conn.openConnection();
-  c = utp.conn.getConn();
-  
-  q = sprintf('SELECT %s.%s FROM %s WHERE %s.obj_id=%d', dbTable, tableField, dbTable, dbTable, objID);
-  try
-    val = utils.jmysql.execute(c, q);
-  catch Me
-    utp.conn.setLocked(false);
-    utp.conn.closeConnection();
-    rethrow(Me);
-  end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+
+  q = sprintf('SELECT %s.%s FROM %s WHERE %s.obj_id = ?', dbTable, tableField, dbTable, dbTable);
+  val = utils.mysql.execute(utp.conn, q, objID);
+
 end
--- a/m-toolbox/classes/tests/database/@ltpda_database/init.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_database/init.m	Tue Dec 06 19:07:22 2011 +0100
@@ -19,16 +19,9 @@
   
   if ~utp.testRunner.skipRepoTests()
     
-    % Get the connection from the repository manager
-    rm = LTPDARepositoryManager();
-    conn = rm.findConnections(utp.testRunner.repositoryPlist);
-    if isempty(conn)
-      conn = rm.newConnection(utp.testRunner.repositoryPlist);
-    end
-    
-    % Check that we get only one connection
-    assert(numel(conn) == 1, sprintf('Found more than one connection in the repository manager for the PLIST: %s', char(utp.testRunner.repositoryPlist)));
-    
+    % Get database connection
+    conn = LTPDADatabaseConnectionManager().connect(utp.testRunner.repositoryPlist);
+
     % Store the connection
     utp.conn = conn;
     
--- a/m-toolbox/classes/tests/database/@ltpda_database/ltpda_database.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_database/ltpda_database.m	Tue Dec 06 19:07:22 2011 +0100
@@ -44,11 +44,8 @@
     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     function delete(varargin)
       utp = varargin{1};
-      % Make sure that we remove the connection from the object and that it
-      % is not locked.
-      if isa(utp.conn, 'mpipeline.repository.RepositoryConnection')
-        utp.conn.setLocked(false);
-      end
+      % Close connection
+      utp.conn.close();
       utp.conn = [];
     end
   end
--- a/m-toolbox/classes/tests/database/@ltpda_fsdata_table/getTableEntry.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_fsdata_table/getTableEntry.m	Tue Dec 06 19:07:22 2011 +0100
@@ -18,8 +18,8 @@
       assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID));
       
       % Create query to get the field 'xunits' from the 'cdata' table
-      query = sprintf('SELECT %s FROM %s WHERE %s.id=%d', tableField, dbTable, dbTable, dataID{1});
-      val   = executeQuery(utp, query);
+      query = sprintf('SELECT %s FROM %s WHERE %s.id = ?', tableField, dbTable, dbTable);
+      val = utils.mysql.execute(utp.conn, query, dataID{1});
     catch Me
       rethrow(Me);
     end
@@ -29,7 +29,5 @@
   else
     throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.'));
   end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+
 end
--- a/m-toolbox/classes/tests/database/@ltpda_tsdata_table/getTableEntry.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_tsdata_table/getTableEntry.m	Tue Dec 06 19:07:22 2011 +0100
@@ -18,8 +18,8 @@
       assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID));
       
       % Create query to get the field 'xunits' from the 'cdata' table
-      query = sprintf('SELECT %s FROM %s WHERE %s.id=%d', tableField, dbTable, dbTable, dataID{1});
-      val   = executeQuery(utp, query);
+      query = sprintf('SELECT %s FROM %s WHERE %s.id = ?', tableField, dbTable, dbTable);
+      val = utils.mysql.execute(utp.conn, query, dataID{1});
     catch Me
       rethrow(Me);
     end
@@ -29,7 +29,5 @@
   else
     throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.'));
   end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+
 end
--- a/m-toolbox/classes/tests/database/@ltpda_xydata_table/getTableEntry.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/classes/tests/database/@ltpda_xydata_table/getTableEntry.m	Tue Dec 06 19:07:22 2011 +0100
@@ -18,8 +18,8 @@
       assert(numel(dataID)==1, sprintf('Found more than one data ID for the given object ID %d', objID));
       
       % Create query to get the field 'xunits' from the 'cdata' table
-      query = sprintf('SELECT %s FROM %s WHERE %s.id=%d', tableField, dbTable, dbTable, dataID{1});
-      val   = executeQuery(utp, query);
+      query = sprintf('SELECT %s FROM %s WHERE %s.id = ?', tableField, dbTable, dbTable);
+      val = utils.mysql.execute(utp.conn, query, dataID{1});
     catch Me
       rethrow(Me);
     end
@@ -29,7 +29,5 @@
   else
     throw(MException('ltpda_cdata_table:getTableEntry', 'Unknown database layout.'));
   end
-  
-  utp.conn.setLocked(false);
-  utp.conn.closeConnection();
+
 end
--- a/m-toolbox/m/built_in_models/ao/ao_model_retrieve_in_timespan.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/m/built_in_models/ao/ao_model_retrieve_in_timespan.m	Tue Dec 06 19:07:22 2011 +0100
@@ -145,10 +145,6 @@
 
   % Get parameters
   names    = pl.find('names');
-  hostname = pl.find('hostname');
-  database = pl.find('database');
-  username = pl.find('username');
-  password = pl.find('password');
   binary   = utils.prog.yes2true(pl.find('binary'));
   constraints = pl.find('constraints');
   fstol    = pl.find('fstol');
@@ -177,15 +173,7 @@
     start = time(start);
     stop = time(time(start) + nsecs);
   end
-  
-  if ~isRow(start)
-    start = start';
-  end
-  
-  if ~isRow(stop)
-    stop = stop';
-  end
-  
+    
   ts = timespan(start, stop);
   
   % prepare output
@@ -196,10 +184,8 @@
     names = {names};
   end
   
-  % get a connection
-  conn = utils.jmysql.connect(hostname, database, username, password);
-  conn.openConnection();
-  c = conn.getConn();
+  % get database connection
+  conn = LTPDADatabaseConnectionManager().connect(pl);
   
   % loop over the channels
   for jj = 1:length(names)
@@ -231,13 +217,12 @@
     % execute query
     try
       utils.helper.msg(msg.PROC2, 'running query: %s', q);
-      rows = utils.jmysql.execute(c, q, name, ...
+      rows = utils.mysql.execute(conn, q, name, ...
         format(ts.startT, 'yyyy-mm-dd HH:MM:SS', 'UTC'), ...
         format(ts.endT,   'yyyy-mm-dd HH:MM:SS', 'UTC'));
     catch ex
       % close connection
-      c.close();
-      conn.setLocked(false);
+      conn.close();
       
       % back-compatibility
       if isempty(find(pl, 'bbb'))
@@ -287,18 +272,15 @@
     
   end % end loop over channels
   
-  % close connection
-  c.close();
-  conn.setLocked(false);
+  % close connection if we own it
+  if isempty(find(pl, 'conn'))
+    conn.close();
+  end;
   
   varargout{1} = a;
   
 end
 
-function res = isRow(in)
-  res = (size(in,1) == 1 && size(in,2) ~= 1);  
-end
-
 %--------------------------------------------------------------------------
 % AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE
 %--------------------------------------------------------------------------
--- a/m-toolbox/m/etc/ltpda_startup.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/m/etc/ltpda_startup.m	Tue Dec 06 19:07:22 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/LTPDARepositoryManagerGui.m	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-function rm = LTPDARepositoryManagerGui()
-  rm = LTPDARepositoryManager;
-  rm.showGui;
-end
\ No newline at end of file
--- a/m-toolbox/m/helper/mc.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/m/helper/mc.m	Tue Dec 06 19:07:22 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
--- a/m-toolbox/makeToolbox.m	Tue Dec 06 18:42:11 2011 +0100
+++ b/m-toolbox/makeToolbox.m	Tue Dec 06 19:07:22 2011 +0100
@@ -93,6 +93,9 @@
 
   %% Install latest jar files
 
+  % ConnectionManager
+  copyfile(fullfile('..', 'src', 'ConnectionManager', 'dist', 'ConnectionManager.jar'), fullfile('jar', 'ConnectionManager.jar'));
+  
   % MPipeline
   copyfile(fullfile('..', 'src', mpipelineSrc, 'dist', [mpipelineSrc '.jar']), fullfile('jar', 'MPipeline.jar'));
   ddir = fullfile('jar', 'lib');
@@ -148,16 +151,11 @@
     'ssm', 'ssmport', 'ssmblock', ...
     'smodel', 'msym',  ...
     'sigBuilder', 'constructor', 'specwinViewer', ...
-    'LTPDAprefs', 'LTPDAworkbench', 'LTPDARepositoryManager', 'workspaceBrowser', ...
+    'LTPDAprefs', 'LTPDAworkbench', 'LTPDADatabaseConnectionManager', 'workspaceBrowser', ...
     'LTPDAModelBrowser', ...
     'matrix', 'collection', ...
     };
 
-%   'LTPDAHelper'
-  %     'stattest', ...
-%     'plotter', 'plotterFactory', ...
-%     'aoplotter', 'tsplotter' ...
-
   for c = classes
     cdir = fullfile('classes', sprintf('@%s', char(c)));
     mkdir(toolboxDir, cdir);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/build.xml	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- You may freely edit this file. See commented blocks below for -->
+<!-- some examples of how to customize the build. -->
+<!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
+<project name="ConnectionManager" default="default" basedir=".">
+    <description>Builds, tests, and runs the project ConnectionManager.</description>
+    <import file="nbproject/build-impl.xml"/>
+    <!--
+
+    There exist several targets which are by default empty and which can be 
+    used for execution of your tasks. These targets are usually executed 
+    before and after some main targets. They are: 
+
+      -pre-init:                 called before initialization of project properties
+      -post-init:                called after initialization of project properties
+      -pre-compile:              called before javac compilation
+      -post-compile:             called after javac compilation
+      -pre-compile-single:       called before javac compilation of single file
+      -post-compile-single:      called after javac compilation of single file
+      -pre-compile-test:         called before javac compilation of JUnit tests
+      -post-compile-test:        called after javac compilation of JUnit tests
+      -pre-compile-test-single:  called before javac compilation of single JUnit test
+      -post-compile-test-single: called after javac compilation of single JUunit test
+      -pre-jar:                  called before JAR building
+      -post-jar:                 called after JAR building
+      -post-clean:               called after cleaning build products
+
+    (Targets beginning with '-' are not intended to be called on their own.)
+
+    Example of inserting an obfuscator after compilation could look like this:
+
+        <target name="-post-compile">
+            <obfuscate>
+                <fileset dir="${build.classes.dir}"/>
+            </obfuscate>
+        </target>
+
+    For list of available properties check the imported 
+    nbproject/build-impl.xml file. 
+
+
+    Another way to customize the build is by overriding existing main targets.
+    The targets of interest are: 
+
+      -init-macrodef-javac:     defines macro for javac compilation
+      -init-macrodef-junit:     defines macro for junit execution
+      -init-macrodef-debug:     defines macro for class debugging
+      -init-macrodef-java:      defines macro for class execution
+      -do-jar-with-manifest:    JAR building (if you are using a manifest)
+      -do-jar-without-manifest: JAR building (if you are not using a manifest)
+      run:                      execution of project 
+      -javadoc-build:           Javadoc generation
+      test-report:              JUnit report generation
+
+    An example of overriding the target for project execution could look like this:
+
+        <target name="run" depends="ConnectionManager-impl.jar">
+            <exec dir="bin" executable="launcher.exe">
+                <arg file="${dist.jar}"/>
+            </exec>
+        </target>
+
+    Notice that the overridden target depends on the jar target and not only on 
+    the compile target as the regular run target does. Again, for a list of available 
+    properties which you can use, check the target you are overriding in the
+    nbproject/build-impl.xml file. 
+
+    -->
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/dist/README.TXT	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,32 @@
+========================
+BUILD OUTPUT DESCRIPTION
+========================
+
+When you build an Java application project that has a main class, the IDE
+automatically copies all of the JAR
+files on the projects classpath to your projects dist/lib folder. The IDE
+also adds each of the JAR files to the Class-Path element in the application
+JAR files manifest file (MANIFEST.MF).
+
+To run the project from the command line, go to the dist folder and
+type the following:
+
+java -jar "ConnectionManager.jar" 
+
+To distribute this project, zip up the dist folder (including the lib folder)
+and distribute the ZIP file.
+
+Notes:
+
+* If two JAR files on the project classpath have the same name, only the first
+JAR file is copied to the lib folder.
+* Only JAR files are copied to the lib folder.
+If the classpath contains other types of files or folders, these files (folders)
+are not copied.
+* If a library on the projects classpath also has a Class-Path element
+specified in the manifest,the content of the Class-Path element has to be on
+the projects runtime path.
+* To set a main class in a standard Java project, right-click the project node
+in the Projects window and choose Properties. Then click Run and enter the
+class name in the Main Class field. Alternatively, you can manually type the
+class name in the manifest Main-Class element.
Binary file src/ConnectionManager/dist/lib/swing-layout-1.0.4.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/.cvsignore	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,1 @@
+private
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/build-impl.xml	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,1042 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
+***         EDIT ../build.xml INSTEAD         ***
+
+For the purpose of easier reading the script
+is divided into following sections:
+
+  - initialization
+  - compilation
+  - jar
+  - execution
+  - debugging
+  - javadoc
+  - junit compilation
+  - junit execution
+  - junit debugging
+  - applet
+  - cleanup
+
+        -->
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="ConnectionManager-impl">
+    <fail message="Please build using Ant 1.7.1 or higher.">
+        <condition>
+            <not>
+                <antversion atleast="1.7.1"/>
+            </not>
+        </condition>
+    </fail>
+    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
+    <!-- 
+                ======================
+                INITIALIZATION SECTION 
+                ======================
+            -->
+    <target name="-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init" name="-init-private">
+        <property file="nbproject/private/config.properties"/>
+        <property file="nbproject/private/configs/${config}.properties"/>
+        <property file="nbproject/private/private.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private" name="-init-user">
+        <property file="${user.properties.file}"/>
+        <!-- The two properties below are usually overridden -->
+        <!-- by the active platform. Just a fallback. -->
+        <property name="default.javac.source" value="1.4"/>
+        <property name="default.javac.target" value="1.4"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
+        <property file="nbproject/configs/${config}.properties"/>
+        <property file="nbproject/project.properties"/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
+        <available file="${manifest.file}" property="manifest.available"/>
+        <condition property="splashscreen.available">
+            <and>
+                <not>
+                    <equals arg1="${application.splash}" arg2="" trim="true"/>
+                </not>
+                <available file="${application.splash}"/>
+            </and>
+        </condition>
+        <condition property="main.class.available">
+            <and>
+                <isset property="main.class"/>
+                <not>
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class">
+            <and>
+                <isset property="manifest.available"/>
+                <isset property="main.class.available"/>
+            </and>
+        </condition>
+        <condition property="do.archive">
+            <not>
+                <istrue value="${jar.archive.disabled}"/>
+            </not>
+        </condition>
+        <condition property="do.mkdist">
+            <and>
+                <isset property="do.archive"/>
+                <isset property="libs.CopyLibs.classpath"/>
+                <not>
+                    <istrue value="${mkdist.disabled}"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="manifest.available+main.class+mkdist.available">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <isset property="do.mkdist"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available">
+            <and>
+                <isset property="manifest.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+main.class.available">
+            <and>
+                <isset property="main.class.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+splashscreen.available">
+            <and>
+                <isset property="splashscreen.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available+main.class">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="manifest.available-mkdist.available">
+            <or>
+                <istrue value="${manifest.available}"/>
+                <isset property="do.mkdist"/>
+            </or>
+        </condition>
+        <condition property="manifest.available+main.class-mkdist.available">
+            <or>
+                <istrue value="${manifest.available+main.class}"/>
+                <isset property="do.mkdist"/>
+            </or>
+        </condition>
+        <condition property="have.tests">
+            <or>
+                <available file="${test.src.dir}"/>
+            </or>
+        </condition>
+        <condition property="have.sources">
+            <or>
+                <available file="${src.dir}"/>
+            </or>
+        </condition>
+        <condition property="netbeans.home+have.tests">
+            <and>
+                <isset property="netbeans.home"/>
+                <isset property="have.tests"/>
+            </and>
+        </condition>
+        <condition property="no.javadoc.preview">
+            <and>
+                <isset property="javadoc.preview"/>
+                <isfalse value="${javadoc.preview}"/>
+            </and>
+        </condition>
+        <property name="run.jvmargs" value=""/>
+        <property name="javac.compilerargs" value=""/>
+        <property name="work.dir" value="${basedir}"/>
+        <condition property="no.deps">
+            <and>
+                <istrue value="${no.dependencies}"/>
+            </and>
+        </condition>
+        <property name="javac.debug" value="true"/>
+        <property name="javadoc.preview" value="true"/>
+        <property name="application.args" value=""/>
+        <property name="source.encoding" value="${file.encoding}"/>
+        <property name="runtime.encoding" value="${source.encoding}"/>
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
+            <and>
+                <isset property="javadoc.encoding"/>
+                <not>
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
+                </not>
+            </and>
+        </condition>
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
+        <property name="includes" value="**"/>
+        <property name="excludes" value=""/>
+        <property name="do.depend" value="false"/>
+        <condition property="do.depend.true">
+            <istrue value="${do.depend}"/>
+        </condition>
+        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+            <length length="0" string="${endorsed.classpath}" when="greater"/>
+        </condition>
+        <condition else="false" property="jdkBug6558476">
+            <and>
+                <matches pattern="1\.[56]" string="${java.specification.version}"/>
+                <not>
+                    <os family="unix"/>
+                </not>
+            </and>
+        </condition>
+        <property name="javac.fork" value="${jdkBug6558476}"/>
+        <property name="jar.index" value="false"/>
+        <property name="jar.index.metainf" value="${jar.index}"/>
+        <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
+    </target>
+    <target name="-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
+        <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
+        <fail unless="build.dir">Must set build.dir</fail>
+        <fail unless="dist.dir">Must set dist.dir</fail>
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
+        <fail unless="dist.jar">Must set dist.jar</fail>
+    </target>
+    <target name="-init-macrodef-property">
+        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${@{value}}"/>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <mkdir dir="@{apgeneratedsrcdir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <compilerarg value="-processorpath"/>
+                    <compilerarg path="@{processorpath}:${empty.dir}"/>
+                    <compilerarg line="${ap.processors.internal}"/>
+                    <compilerarg line="${annotation.processing.processor.options}"/>
+                    <compilerarg value="-s"/>
+                    <compilerarg path="@{apgeneratedsrcdir}"/>
+                    <compilerarg line="${ap.proc.none.internal}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <sequential>
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </depend>
+            </sequential>
+        </macrodef>
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <sequential>
+                <fail unless="javac.includes">Must set javac.includes</fail>
+                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
+                    <path>
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
+                    </path>
+                    <globmapper from="*.java" to="*.class"/>
+                </pathconvert>
+                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
+                <delete>
+                    <files includesfile="${javac.includesfile.binary}"/>
+                </delete>
+                <delete>
+                    <fileset file="${javac.includesfile.binary}"/>
+                </delete>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-junit">
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="**" name="testincludes"/>
+            <sequential>
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
+                    <batchtest todir="${build.test.results.dir}">
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
+                            <filename name="@{testincludes}"/>
+                        </fileset>
+                    </batchtest>
+                    <classpath>
+                        <path path="${run.test.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="test-sys-prop."/>
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <formatter type="brief" usefile="false"/>
+                    <formatter type="xml"/>
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-ea"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                </junit>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
+    <target name="-profile-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-profile-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-profile-init-macrodef-profile">
+        <macrodef name="resolve">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${env.@{value}}"/>
+            </sequential>
+        </macrodef>
+        <macrodef name="profile">
+            <attribute default="${main.class}" name="classname"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property environment="env"/>
+                <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
+                <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+                    <jvmarg value="${profiler.info.jvmargs.agent}"/>
+                    <jvmarg line="${profiler.info.jvmargs}"/>
+                    <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+                    <arg line="${application.args}"/>
+                    <classpath>
+                        <path path="${run.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
+        <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
+        <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="name"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <attribute default="" name="stopclassname"/>
+            <sequential>
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                </nbjpdastart>
+            </sequential>
+        </macrodef>
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${build.classes.dir}" name="dir"/>
+            <sequential>
+                <nbjpdareload>
+                    <fileset dir="@{dir}" includes="${fix.classes}">
+                        <include name="${fix.includes}*.class"/>
+                    </fileset>
+                </nbjpdareload>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-debug-args">
+        <property name="version-output" value="java version &quot;${ant.java.version}"/>
+        <condition property="have-jdk-older-than-1.4">
+            <or>
+                <contains string="${version-output}" substring="java version &quot;1.0"/>
+                <contains string="${version-output}" substring="java version &quot;1.1"/>
+                <contains string="${version-output}" substring="java version &quot;1.2"/>
+                <contains string="${version-output}" substring="java version &quot;1.3"/>
+            </or>
+        </condition>
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
+            <istrue value="${have-jdk-older-than-1.4}"/>
+        </condition>
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+            <os family="windows"/>
+        </condition>
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+            <isset property="debug.transport"/>
+        </condition>
+    </target>
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${debug.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg line="${debug-args-line}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-java">
+        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <attribute default="${main.class}" name="classname"/>
+            <attribute default="${run.classpath}" name="classpath"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
+                    <jvmarg line="${run.jvmargs}"/>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-macrodef-copylibs">
+        <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${manifest.file}" name="manifest"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+                <pathconvert property="run.classpath.without.build.classes.dir">
+                    <path path="${run.classpath}"/>
+                    <map from="${build.classes.dir.resolved}" to=""/>
+                </pathconvert>
+                <pathconvert pathsep=" " property="jar.classpath">
+                    <path path="${run.classpath.without.build.classes.dir}"/>
+                    <chainedmapper>
+                        <flattenmapper/>
+                        <globmapper from="*" to="lib/*"/>
+                    </chainedmapper>
+                </pathconvert>
+                <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+                <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                    <fileset dir="${build.classes.dir}"/>
+                    <manifest>
+                        <attribute name="Class-Path" value="${jar.classpath}"/>
+                        <customize/>
+                    </manifest>
+                </copylibs>
+            </sequential>
+        </macrodef>
+    </target>
+    <target name="-init-presetdef-jar">
+        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
+            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
+                <j2seproject1:fileset dir="${build.classes.dir}"/>
+            </jar>
+        </presetdef>
+    </target>
+    <target name="-init-ap-cmdline-properties">
+        <property name="annotation.processing.enabled" value="true"/>
+        <property name="annotation.processing.processors.list" value=""/>
+        <property name="annotation.processing.processor.options" value=""/>
+        <property name="annotation.processing.run.all.processors" value="true"/>
+        <property name="javac.processorpath" value="${javac.classpath}"/>
+        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+        <condition property="ap.supported.internal" value="true">
+            <not>
+                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+            <isfalse value="${annotation.processing.run.all.processors}"/>
+        </condition>
+        <condition else="" property="ap.proc.none.internal" value="-proc:none">
+            <isfalse value="${annotation.processing.enabled}"/>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+        <property name="ap.cmd.line.internal" value=""/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
+    <!--
+                ===================
+                COMPILATION SECTION
+                ===================
+            -->
+    <target name="-deps-jar-init" unless="built-jar.properties">
+        <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
+        <delete file="${built-jar.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
+        <echo level="warn" message="Cycle detected: ConnectionManager was already built"/>
+    </target>
+    <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-jar.properties}" verbose="false"/>
+        <property file="${built-jar.properties}" prefix="already.built.jar."/>
+        <antcall target="-warn-already-built-jar"/>
+        <propertyfile file="${built-jar.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+    <target depends="init" name="-check-automatic-build">
+        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+    </target>
+    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+        <antcall target="clean"/>
+    </target>
+    <target depends="init,deps-jar" name="-pre-pre-compile">
+        <mkdir dir="${build.classes.dir}"/>
+    </target>
+    <target name="-pre-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-depend">
+        <pathconvert property="build.generated.subdirs">
+            <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="*"/>
+            </dirset>
+        </pathconvert>
+        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
+        <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
+        <copy todir="${build.classes.dir}">
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target if="has.persistence.xml" name="-copy-persistence-xml">
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy todir="${build.classes.dir}/META-INF">
+            <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
+        </copy>
+    </target>
+    <target name="-post-compile">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+    <target name="-pre-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile/>
+        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
+    </target>
+    <target name="-post-compile-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+    <!--
+                ====================
+                JAR BUILDING SECTION
+                ====================
+            -->
+    <target depends="init" name="-pre-pre-jar">
+        <dirname file="${dist.jar}" property="dist.jar.dir"/>
+        <mkdir dir="${dist.jar.dir}"/>
+    </target>
+    <target name="-pre-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
+        <j2seproject1:jar/>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
+        <j2seproject1:jar manifest="${manifest.file}"/>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
+        <j2seproject1:jar manifest="${manifest.file}">
+            <j2seproject1:manifest>
+                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
+            </j2seproject1:manifest>
+        </j2seproject1:jar>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <pathconvert property="run.classpath.with.dist.jar">
+            <path path="${run.classpath}"/>
+            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
+        </pathconvert>
+        <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+    </target>
+    <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <touch file="${tmp.manifest.file}" verbose="false"/>
+    </target>
+    <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
+    </target>
+    <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+        </manifest>
+    </target>
+    <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen">
+        <basename file="${application.splash}" property="splashscreen.basename"/>
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
+        </manifest>
+    </target>
+    <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack">
+        <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
+        <echo level="info">java -jar "${dist.jar.resolved}"</echo>
+    </target>
+    <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">
+        <delete>
+            <fileset file="${tmp.manifest.file}"/>
+        </delete>
+    </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/>
+    <target name="-post-jar">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
+    <!--
+                =================
+                EXECUTION SECTION
+                =================
+            -->
+    <target depends="init,compile" description="Run a main class." name="run">
+        <j2seproject1:java>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <target name="-do-not-recompile">
+        <property name="javac.includes.binary" value=""/>
+    </target>
+    <target depends="init,compile-single" name="run-single">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}"/>
+    </target>
+    <target depends="init,compile-test-single" name="run-test-with-main">
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
+        <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
+    </target>
+    <!--
+                =================
+                DEBUGGING SECTION
+                =================
+            -->
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
+        <j2seproject1:nbjpdastart name="${debug.class}"/>
+    </target>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
+    </target>
+    <target depends="init,compile" name="-debug-start-debuggee">
+        <j2seproject3:debug>
+            <customize>
+                <arg line="${application.args}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
+        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
+    </target>
+    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}"/>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+    <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
+        <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+    <target depends="init" name="-pre-debug-fix">
+        <fail unless="fix.includes">Must set fix.includes</fail>
+        <property name="javac.includes" value="${fix.includes}.java"/>
+    </target>
+    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
+        <j2seproject1:nbjpdareload/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
+    <!--
+                =================
+                PROFILING SECTION
+                =================
+            -->
+    <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile/>
+    </target>
+    <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
+        <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="${profile.class}"/>
+    </target>
+    <!--
+                =========================
+                APPLET PROFILING  SECTION
+                =========================
+            -->
+    <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </profile>
+    </target>
+    <!--
+                =========================
+                TESTS PROFILING  SECTION
+                =========================
+            -->
+    <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
+            <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg line="${profiler.info.jvmargs}"/>
+            <test name="${profile.class}"/>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+            <syspropertyset>
+                <propertyref prefix="test-sys-prop."/>
+                <mapper from="test-sys-prop.*" to="*" type="glob"/>
+            </syspropertyset>
+            <formatter type="brief" usefile="false"/>
+            <formatter type="xml"/>
+        </junit>
+    </target>
+    <!--
+                ===============
+                JAVADOC SECTION
+                ===============
+            -->
+    <target depends="init" if="have.sources" name="-javadoc-build">
+        <mkdir dir="${dist.javadoc.dir}"/>
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
+            <classpath>
+                <path path="${javac.classpath}"/>
+            </classpath>
+            <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/*.java"/>
+                <exclude name="*.java"/>
+            </fileset>
+        </javadoc>
+        <copy todir="${dist.javadoc.dir}">
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/doc-files/**"/>
+            </fileset>
+        </copy>
+    </target>
+    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
+    </target>
+    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
+    <!--
+                =========================
+                JUNIT COMPILATION SECTION
+                =========================
+            -->
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
+        <mkdir dir="${build.test.classes.dir}"/>
+    </target>
+    <target name="-pre-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target if="do.depend.true" name="-compile-test-depend">
+        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+    </target>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
+    <target name="-pre-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
+        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+        <copy todir="${build.test.classes.dir}">
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+        </copy>
+    </target>
+    <target name="-post-compile-test-single">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
+    <!--
+                =======================
+                JUNIT EXECUTION SECTION
+                =======================
+            -->
+    <target depends="init" if="have.tests" name="-pre-test-run">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
+        <j2seproject3:junit testincludes="**/*Test.java"/>
+    </target>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init" if="have.tests" name="test-report"/>
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
+        <mkdir dir="${build.test.results.dir}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
+        <j2seproject3:junit excludes="" includes="${test.includes}"/>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
+        <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
+    </target>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <!--
+                =======================
+                JUNIT DEBUGGING SECTION
+                =======================
+            -->
+    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
+        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
+        <delete file="${test.report.file}"/>
+        <mkdir dir="${build.test.results.dir}"/>
+        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
+            <customize>
+                <syspropertyset>
+                    <propertyref prefix="test-sys-prop."/>
+                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
+                </syspropertyset>
+                <arg value="${test.class}"/>
+                <arg value="showoutput=true"/>
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
+    </target>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
+        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
+    </target>
+    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
+    <!--
+                =========================
+                APPLET EXECUTION SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" name="run-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject1:java classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject1:java>
+    </target>
+    <!--
+                =========================
+                APPLET DEBUGGING  SECTION
+                =========================
+            -->
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
+        <j2seproject3:debug classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </j2seproject3:debug>
+    </target>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
+    <!--
+                ===============
+                CLEANUP SECTION
+                ===============
+            -->
+    <target name="-deps-clean-init" unless="built-clean.properties">
+        <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
+        <delete file="${built-clean.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
+        <echo level="warn" message="Cycle detected: ConnectionManager was already built"/>
+    </target>
+    <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-clean.properties}" verbose="false"/>
+        <property file="${built-clean.properties}" prefix="already.built.clean."/>
+        <antcall target="-warn-already-built-clean"/>
+        <propertyfile file="${built-clean.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
+    <target depends="init" name="-do-clean">
+        <delete dir="${build.dir}"/>
+        <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
+    </target>
+    <target name="-post-clean">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+    <target name="-check-call-dep">
+        <property file="${call.built.properties}" prefix="already.built."/>
+        <condition property="should.call.dep">
+            <not>
+                <isset property="already.built.${call.subproject}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
+        <ant antfile="${call.script}" inheritall="false" target="${call.target}">
+            <propertyset>
+                <propertyref prefix="transfer."/>
+                <mapper from="transfer.*" to="*" type="glob"/>
+            </propertyset>
+        </ant>
+    </target>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/genfiles.properties	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=ec3fbd9f
+build.xml.script.CRC32=1b3d25dd
+build.xml.stylesheet.CRC32=28e38971@1.44.1.45
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=ec3fbd9f
+nbproject/build-impl.xml.script.CRC32=4fce1b85
+nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/private/private.properties	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,7 @@
+compile.on.save=true
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+jaxbwiz.endorsed.dirs=/Applications/NetBeans/NetBeans 6.8.app/Contents/Resources/NetBeans/ide12/modules/ext/jaxb/api
+user.properties.file=/home/daniele/.netbeans/7.0/build.properties
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/private/private.xml	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/project.properties	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,70 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.run.all.processors=true
+application.title=ConnectionManager
+application.vendor=daniele
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+    ${run.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/ConnectionManager.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=\
+    ${libs.swing-layout.classpath}
+# Space-separated list of extra javac options
+javac.compilerargs=-Xlint:unchecked
+javac.deprecation=false
+javac.processorpath=\
+    ${javac.classpath}
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
+main.class=connectionmanager.CredentialsDialog
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
+# or test-sys-prop.name=value to set system properties for unit tests):
+run.jvmargs=
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/nbproject/project.xml	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.java.j2seproject</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
+            <name>ConnectionManager</name>
+            <source-roots>
+                <root id="src.dir"/>
+            </source-roots>
+            <test-roots>
+                <root id="test.src.dir"/>
+            </test-roots>
+        </data>
+    </configuration>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/src/connectionmanager/CredentialsDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,132 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Database connection"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <Events>
+    <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="closeDialog"/>
+  </Events>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="titleLabel" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
+                          <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
+                      </Group>
+                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <Group type="103" groupAlignment="0" attributes="0">
+                          <Component id="passwordField" alignment="0" pref="240" max="32767" attributes="1"/>
+                          <Component id="usernameField" alignment="0" pref="240" max="32767" attributes="0"/>
+                      </Group>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="cacheCheckBox" min="-2" pref="190" max="-2" attributes="0"/>
+                      <EmptySpace pref="12" max="32767" attributes="1"/>
+                      <Component id="cancelButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" max="-2" attributes="0"/>
+                      <Component id="okButton" min="-2" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" max="-2" attributes="0">
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+              <Component id="titleLabel" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="usernameField" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="passwordField" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" max="-2" attributes="0">
+                  <Component id="cacheCheckBox" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Connect"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="titleLabel">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Credentials for mysql://%s/%s/"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JPasswordField" name="passwordField">
+    </Component>
+    <Component class="javax.swing.JCheckBox" name="cacheCheckBox">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Remember this password"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="usernameField">
+      <Properties>
+        <Property name="editable" type="boolean" value="true"/>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="0"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="usernameFieldActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Password:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Username:"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/src/connectionmanager/CredentialsDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,187 @@
+package connectionmanager;
+
+public class CredentialsDialog extends javax.swing.JDialog {
+
+  public boolean cancelled = true;
+  public boolean cache = true;
+  public String username = null;
+  public String password = null;
+
+  public CredentialsDialog(javax.swing.JDialog parent, String hostname, String[] usernames) {
+    super(parent, true);
+    initComponents();
+    super.setLocationRelativeTo(parent);
+    this.cacheCheckBox.setVisible(false);
+    titleLabel.setText(String.format("Credentials for mysql://%s/", hostname));
+    if ((usernames != null) && (usernames.length > 0)) {
+      usernameField.setModel(new javax.swing.DefaultComboBoxModel(usernames));
+      passwordField.requestFocus();
+    }
+    super.getRootPane().setDefaultButton(okButton);
+  }
+  
+  public CredentialsDialog(java.awt.Frame parent, String hostname, String database, String[] usernames, int cache, String msg) {
+    super(parent, true);
+    initComponents();
+    super.setLocationRelativeTo(parent);
+
+    switch (cache) {
+      case 0:
+        this.cache = false;
+        this.cacheCheckBox.setVisible(false);
+        break;
+      case 1:
+        this.cache = true;
+        this.cacheCheckBox.setVisible(false);
+        break;
+      case 2:
+        this.cache = true;
+        this.cacheCheckBox.setVisible(true);
+        break;
+    }
+
+    if (msg != null) {
+      titleLabel.setText(String.format("%s mysql://%s/%s/", msg, hostname, database));
+    } else {
+      titleLabel.setText(String.format("Credentials for mysql://%s/%s/", hostname, database));
+    }
+    if ((usernames != null) && (usernames.length > 0)) {
+      usernameField.setModel(new javax.swing.DefaultComboBoxModel(usernames));
+      passwordField.requestFocus();
+    }
+    super.getRootPane().setDefaultButton(okButton);
+  }
+
+  @SuppressWarnings("unchecked")
+  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+  private void initComponents() {
+
+    okButton = new javax.swing.JButton();
+    cancelButton = new javax.swing.JButton();
+    titleLabel = new javax.swing.JLabel();
+    passwordField = new javax.swing.JPasswordField();
+    cacheCheckBox = new javax.swing.JCheckBox();
+    usernameField = new javax.swing.JComboBox();
+    jLabel2 = new javax.swing.JLabel();
+    jLabel1 = new javax.swing.JLabel();
+
+    setTitle("Database connection");
+    addWindowListener(new java.awt.event.WindowAdapter() {
+      public void windowClosing(java.awt.event.WindowEvent evt) {
+        closeDialog(evt);
+      }
+    });
+
+    okButton.setText("Connect");
+    okButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        okButtonActionPerformed(evt);
+      }
+    });
+
+    cancelButton.setText("Cancel");
+    cancelButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        cancelButtonActionPerformed(evt);
+      }
+    });
+
+    titleLabel.setText("Credentials for mysql://%s/%s/");
+
+    cacheCheckBox.setText("Remember this password");
+
+    usernameField.setEditable(true);
+    usernameField.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        usernameFieldActionPerformed(evt);
+      }
+    });
+
+    jLabel2.setText("Password:");
+
+    jLabel1.setText("Username:");
+
+    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+    getContentPane().setLayout(layout);
+    layout.setHorizontalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+          .add(titleLabel)
+          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+              .add(jLabel1)
+              .add(jLabel2))
+            .add(18, 18, 18)
+            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+              .add(passwordField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
+              .add(usernameField, 0, 240, Short.MAX_VALUE)))
+          .add(layout.createSequentialGroup()
+            .add(cacheCheckBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 190, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
+            .add(cancelButton)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(okButton)))
+        .addContainerGap())
+    );
+    layout.setVerticalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(layout.createSequentialGroup()
+        .addContainerGap()
+        .add(titleLabel)
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(usernameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel1))
+        .add(12, 12, 12)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(passwordField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel2))
+        .add(18, 18, 18)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE, false)
+          .add(cacheCheckBox)
+          .add(okButton)
+          .add(cancelButton))
+        .addContainerGap())
+    );
+
+    pack();
+  }// </editor-fold>//GEN-END:initComponents
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+      cancelled = false;
+      username = (String) usernameField.getSelectedItem();
+      password = new String(passwordField.getPassword());
+      cache = cacheCheckBox.isSelected();
+      doClose();
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+      cancelled = true;
+      doClose();
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
+      cancelled = true;
+      doClose();
+    }//GEN-LAST:event_closeDialog
+
+    private void usernameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameFieldActionPerformed
+}//GEN-LAST:event_usernameFieldActionPerformed
+
+  private void doClose() {
+    setVisible(false);
+    dispose();
+  }
+  // Variables declaration - do not modify//GEN-BEGIN:variables
+  private javax.swing.JCheckBox cacheCheckBox;
+  private javax.swing.JButton cancelButton;
+  private javax.swing.JLabel jLabel1;
+  private javax.swing.JLabel jLabel2;
+  private javax.swing.JButton okButton;
+  private javax.swing.JPasswordField passwordField;
+  private javax.swing.JLabel titleLabel;
+  private javax.swing.JComboBox usernameField;
+  // End of variables declaration//GEN-END:variables
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/src/connectionmanager/DatabaseDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,136 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Database connection"/>
+    <Property name="locationByPlatform" type="boolean" value="true"/>
+    <Property name="modal" type="boolean" value="true"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="jLabel9" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+                      <Component id="hostnameCombo" pref="240" max="32767" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="jLabel10" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
+                      <Component id="databaseCombo" pref="240" max="32767" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="listButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace pref="134" max="32767" attributes="0"/>
+                      <Component id="cancelButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="okButton" min="-2" max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="hostnameCombo" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="databaseCombo" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Group type="103" alignment="1" groupAlignment="3" attributes="0">
+                      <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                      <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Component id="listButton" alignment="1" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel10">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Database:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel9">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Hostname:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="databaseCombo">
+      <Properties>
+        <Property name="editable" type="boolean" value="true"/>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="0"/>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Ok"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="hostnameCombo">
+      <Properties>
+        <Property name="editable" type="boolean" value="true"/>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="0"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="hostnameComboActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="listButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="List databases"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="listButtonActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/src/connectionmanager/DatabaseDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,223 @@
+package connectionmanager;
+
+import java.util.HashSet;
+import java.util.ArrayList;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.table.TableModel;
+
+public class DatabaseDialog extends javax.swing.JDialog {
+
+  public boolean cancelled = true;
+  public String hostname;
+  public String database;
+  private TableModel model;
+
+  public DatabaseDialog(javax.swing.JDialog parent, TableModel model) {
+    super(parent, true);
+    this.model = model;
+    initComponents();
+    initHostnameCombo();
+    initDatabaseCombo();
+    super.setLocationRelativeTo(parent);
+    super.getRootPane().setDefaultButton(okButton);
+    if (hostnameCombo.getModel().getSize() == 1) {
+      databaseCombo.requestFocus();
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+  private void initComponents() {
+
+    jLabel10 = new javax.swing.JLabel();
+    jLabel9 = new javax.swing.JLabel();
+    databaseCombo = new javax.swing.JComboBox();
+    okButton = new javax.swing.JButton();
+    cancelButton = new javax.swing.JButton();
+    hostnameCombo = new javax.swing.JComboBox();
+    listButton = new javax.swing.JButton();
+
+    setTitle("Database connection");
+    setLocationByPlatform(true);
+    setModal(true);
+    setResizable(false);
+
+    jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+    jLabel10.setText("Database:");
+
+    jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+    jLabel9.setText("Hostname:");
+
+    databaseCombo.setEditable(true);
+
+    okButton.setText("Ok");
+    okButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        okButtonActionPerformed(evt);
+      }
+    });
+
+    cancelButton.setText("Cancel");
+    cancelButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        cancelButtonActionPerformed(evt);
+      }
+    });
+
+    hostnameCombo.setEditable(true);
+    hostnameCombo.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        hostnameComboActionPerformed(evt);
+      }
+    });
+
+    listButton.setText("List databases");
+    listButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        listButtonActionPerformed(evt);
+      }
+    });
+
+    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+    getContentPane().setLayout(layout);
+    layout.setHorizontalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+          .add(layout.createSequentialGroup()
+            .add(jLabel9)
+            .add(18, 18, 18)
+            .add(hostnameCombo, 0, 240, Short.MAX_VALUE))
+          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+            .add(jLabel10)
+            .add(21, 21, 21)
+            .add(databaseCombo, 0, 240, Short.MAX_VALUE))
+          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+            .add(listButton)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 134, Short.MAX_VALUE)
+            .add(cancelButton)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(okButton)))
+        .addContainerGap())
+    );
+    layout.setVerticalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(hostnameCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel9))
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(databaseCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel10))
+        .add(30, 30, 30)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+          .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+            .add(okButton)
+            .add(cancelButton))
+          .add(listButton))
+        .addContainerGap())
+    );
+
+    pack();
+  }// </editor-fold>//GEN-END:initComponents
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+      cancelled = true;
+      doClose();
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+      cancelled = false;
+      hostname = (String) hostnameCombo.getSelectedItem();
+      database = (String) databaseCombo.getSelectedItem();
+      doClose();
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    private void hostnameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hostnameComboActionPerformed
+      initDatabaseCombo();
+    }//GEN-LAST:event_hostnameComboActionPerformed
+
+private void listButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listButtonActionPerformed
+  // selected hostname
+  hostname = (String) hostnameCombo.getSelectedItem();
+  // users for given hostname
+  HashSet<String> usernames = new HashSet<String>();
+  int rows = model.getRowCount();
+  for (int i = 0; i < rows; i++) {
+    if (model.getValueAt(i, 0).equals(hostname)) {
+      String username = (String) model.getValueAt(i, 2);
+      if (username != null) {
+        usernames.add(username);
+      }
+    }    
+  }
+  // credentials dialog
+  String[] users = new String[usernames.size()];
+  usernames.toArray(users);
+  java.util.Arrays.sort(users);
+  CredentialsDialog dialog = new CredentialsDialog(this, hostname, users);
+  dialog.setVisible(true);
+  
+  try {
+    // connect to database
+    Class.forName("com.mysql.jdbc.Driver");
+    String url = String.format("jdbc:mysql://%s/", hostname);
+    java.sql.Connection conn = java.sql.DriverManager.getConnection(url, dialog.username, dialog.password);
+    // list databases
+    java.sql.Statement stmt = conn.createStatement();
+    java.sql.ResultSet rs = stmt.executeQuery("SHOW DATABASES");
+    ArrayList<String> databases = new ArrayList<String>();
+    while (rs.next()) {
+      String db = rs.getString(1);
+      if (! db.equals("information_schema")) {
+        databases.add(db);
+      }
+    }
+    // add to combo box
+    databaseCombo.setModel(new DefaultComboBoxModel(databases.toArray()));
+    // show list
+    databaseCombo.setPopupVisible(true);
+    // give focus to list
+    databaseCombo.getEditor().getEditorComponent().requestFocus();
+  } catch (Exception ex) { }
+}//GEN-LAST:event_listButtonActionPerformed
+
+  private void initHostnameCombo() {
+    HashSet<String> hostnames = new HashSet<String>();
+    int rows = model.getRowCount();
+    for (int i = 0; i < rows; i++) {
+      hostnames.add((String) model.getValueAt(i, 0));
+    }
+    hostnameCombo.setModel(new DefaultComboBoxModel(hostnames.toArray()));
+  }
+
+  private void initDatabaseCombo() {
+    HashSet<String> databases = new HashSet<String>();
+    hostname = (String) hostnameCombo.getSelectedItem();
+    int rows = model.getRowCount();
+    for (int i = 0; i < rows; i++) {
+      if (hostname.equals((String) model.getValueAt(i, 0))) {
+        databases.add((String) model.getValueAt(i, 1));
+      }
+    }
+    databaseCombo.setModel(new DefaultComboBoxModel(databases.toArray()));
+  }
+
+  private void doClose() {
+    setVisible(false);
+    dispose();
+
+  }
+  // Variables declaration - do not modify//GEN-BEGIN:variables
+  private javax.swing.JButton cancelButton;
+  private javax.swing.JComboBox databaseCombo;
+  private javax.swing.JComboBox hostnameCombo;
+  private javax.swing.JLabel jLabel10;
+  private javax.swing.JLabel jLabel9;
+  private javax.swing.JButton listButton;
+  private javax.swing.JButton okButton;
+  // End of variables declaration//GEN-END:variables
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,138 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+    <Property name="title" type="java.lang.String" value="Database connection"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="scrollPane" alignment="0" pref="409" max="32767" attributes="0"/>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="newButton" pref="62" max="32767" attributes="0"/>
+                      <EmptySpace min="-2" pref="184" max="-2" attributes="0"/>
+                      <Component id="cancelButton" pref="77" max="32767" attributes="0"/>
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="selectButton" pref="74" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="scrollPane" pref="218" max="32767" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="2" attributes="0">
+                  <Component id="newButton" alignment="2" min="-2" max="-2" attributes="0"/>
+                  <Component id="selectButton" alignment="2" min="-2" max="-2" attributes="0"/>
+                  <Component id="cancelButton" alignment="2" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="newButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="New"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="selectButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Select"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="selectButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="scrollPane">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="databasesTable">
+          <Properties>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+              <Table columnCount="3" rowCount="0">
+                <Column editable="false" title="Hostname" type="java.lang.String"/>
+                <Column editable="false" title="Database" type="java.lang.String"/>
+                <Column editable="false" title="Username" type="java.lang.String"/>
+              </Table>
+            </Property>
+            <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
+              <TableColumnModel selectionModel="0">
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+                <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
+                  <Title/>
+                  <Editor/>
+                  <Renderer/>
+                </Column>
+              </TableColumnModel>
+            </Property>
+            <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="cc" green="cc" red="cc" type="rgb"/>
+            </Property>
+            <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[0, 0]"/>
+            </Property>
+            <Property name="rowHeight" type="int" value="24"/>
+            <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
+              <JTableSelectionModel selectionMode="0"/>
+            </Property>
+            <Property name="showVerticalLines" type="boolean" value="false"/>
+          </Properties>
+          <Events>
+            <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="tableKeyPressed"/>
+          </Events>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,244 @@
+package connectionmanager;
+
+import java.awt.Component;
+import java.awt.Point;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+
+class CellRenderer extends DefaultTableCellRenderer {
+
+  @Override
+  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+    return super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
+  }
+}
+
+public class DatabaseSelectorDialog extends javax.swing.JDialog {
+
+  public boolean cancelled = true;
+  public String hostname;
+  public String database;
+  public String username;
+
+  public DatabaseSelectorDialog(java.awt.Frame parent) {
+    super(parent, true);
+    initComponents();
+    // center in parent window
+    super.setLocationRelativeTo(parent);
+    databasesTable.setDefaultRenderer(Object.class, new CellRenderer());
+    databasesTable.addMouseListener(new MouseListenerDoubleClick());
+  }
+
+  public DatabaseSelectorDialog() {
+    super(new javax.swing.JFrame(), true);
+    initComponents();
+    databasesTable.setDefaultRenderer(Object.class, new CellRenderer());
+    databasesTable.addMouseListener(new MouseListenerDoubleClick());
+  }
+
+  private class MouseListenerDoubleClick extends MouseAdapter {
+
+    @Override
+    public void mouseClicked(MouseEvent e) {
+      if (e.getClickCount() >= 2) {
+        cancelled = false;
+        Point p = e.getPoint();
+        int row = databasesTable.rowAtPoint(p);
+        doSelect(row);
+      }
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+  private void initComponents() {
+
+    cancelButton = new javax.swing.JButton();
+    newButton = new javax.swing.JButton();
+    selectButton = new javax.swing.JButton();
+    scrollPane = new javax.swing.JScrollPane();
+    databasesTable = new javax.swing.JTable();
+
+    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+    setTitle("Database connection");
+    setResizable(false);
+
+    cancelButton.setText("Cancel");
+    cancelButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        cancelButtonActionPerformed(evt);
+      }
+    });
+
+    newButton.setText("New");
+    newButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        newButtonActionPerformed(evt);
+      }
+    });
+
+    selectButton.setText("Select");
+    selectButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        selectButtonActionPerformed(evt);
+      }
+    });
+
+    databasesTable.setModel(new javax.swing.table.DefaultTableModel(
+      new Object [][] {
+
+      },
+      new String [] {
+        "Hostname", "Database", "Username"
+      }
+    ) {
+      Class[] types = new Class [] {
+        java.lang.String.class, java.lang.String.class, java.lang.String.class
+      };
+      boolean[] canEdit = new boolean [] {
+        false, false, false
+      };
+
+      public Class getColumnClass(int columnIndex) {
+        return types [columnIndex];
+      }
+
+      public boolean isCellEditable(int rowIndex, int columnIndex) {
+        return canEdit [columnIndex];
+      }
+    });
+    databasesTable.setGridColor(new java.awt.Color(204, 204, 204));
+    databasesTable.setIntercellSpacing(new java.awt.Dimension(0, 0));
+    databasesTable.setRowHeight(24);
+    databasesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+    databasesTable.setShowVerticalLines(false);
+    databasesTable.addKeyListener(new java.awt.event.KeyAdapter() {
+      public void keyPressed(java.awt.event.KeyEvent evt) {
+        tableKeyPressed(evt);
+      }
+    });
+    scrollPane.setViewportView(databasesTable);
+
+    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+    getContentPane().setLayout(layout);
+    layout.setHorizontalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+          .add(org.jdesktop.layout.GroupLayout.LEADING, scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
+          .add(layout.createSequentialGroup()
+            .add(newButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)
+            .add(184, 184, 184)
+            .add(cancelButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+            .add(selectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE)))
+        .addContainerGap())
+    );
+    layout.setVerticalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+        .addContainerGap()
+        .add(scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
+          .add(newButton)
+          .add(selectButton)
+          .add(cancelButton))
+        .addContainerGap())
+    );
+
+    pack();
+  }// </editor-fold>//GEN-END:initComponents
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+      cancelled = true;
+      doClose();
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    private void selectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectButtonActionPerformed
+      int row = databasesTable.getSelectedRow();
+      if (row > -1) {
+        doSelect(row);
+      }
+    }//GEN-LAST:event_selectButtonActionPerformed
+
+    private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
+      DatabaseDialog dialog = new DatabaseDialog(this, databasesTable.getModel());
+      setVisible(false);
+      dialog.setVisible(true);
+      if (!dialog.cancelled) {
+        cancelled = false;
+        hostname = dialog.hostname;
+        database = dialog.database;
+        username = "";
+        doClose();
+      } else {
+        setVisible(true);
+      }
+    }//GEN-LAST:event_newButtonActionPerformed
+
+private void tableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableKeyPressed
+  if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
+    int row = databasesTable.getSelectedRow();
+    if (row > -1) {
+      doSelect(row);
+    }
+  }
+}//GEN-LAST:event_tableKeyPressed
+
+  private void doSelect(int row) {
+    cancelled = false;
+
+    DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
+    hostname = (String) model.getValueAt(row, 0);
+    database = (String) model.getValueAt(row, 1);
+    username = (String) model.getValueAt(row, 2);
+
+    if (database == null) {
+      // filter model      
+      DefaultTableModel submodel = new DefaultTableModel(0, 3);
+      int rows = model.getRowCount();
+      for (int i = 0; i < rows; i++) {
+        String h = (String) model.getValueAt(i, 0);
+        if ((h != null) && h.equals(hostname)) {
+          submodel.addRow(new Object[]{hostname,
+                                       model.getValueAt(i, 1),
+                                       model.getValueAt(i, 2)});
+        }
+      }
+      DatabaseDialog dialog = new DatabaseDialog(this, submodel);
+      setVisible(false);
+      dialog.setVisible(true);
+      if (!dialog.cancelled) {
+        cancelled = false;
+        hostname = dialog.hostname;
+        database = dialog.database;
+        username = "";
+        doClose();
+      }
+    }
+    doClose();
+  }
+
+  private void doClose() {
+    setVisible(false);
+    dispose();
+  }
+
+  public void add(String hostname, String database, String username) {
+    DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
+    model.insertRow(model.getRowCount(), new Object[]{hostname, database, username});
+    databasesTable.addRowSelectionInterval(0, 0);
+  }
+  // Variables declaration - do not modify//GEN-BEGIN:variables
+  private javax.swing.JButton cancelButton;
+  private javax.swing.JTable databasesTable;
+  private javax.swing.JButton newButton;
+  private javax.swing.JScrollPane scrollPane;
+  private javax.swing.JButton selectButton;
+  // End of variables declaration//GEN-END:variables
+}
--- a/src/MPipeline2/nbproject/build-impl.xml	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/nbproject/build-impl.xml	Tue Dec 06 19:07:22 2011 +0100
@@ -55,21 +55,84 @@
     </target>
     <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
         <available file="${manifest.file}" property="manifest.available"/>
-        <condition property="manifest.available+main.class">
+        <condition property="splashscreen.available">
             <and>
-                <isset property="manifest.available"/>
+                <not>
+                    <equals arg1="${application.splash}" arg2="" trim="true"/>
+                </not>
+                <available file="${application.splash}"/>
+            </and>
+        </condition>
+        <condition property="main.class.available">
+            <and>
                 <isset property="main.class"/>
                 <not>
                     <equals arg1="${main.class}" arg2="" trim="true"/>
                 </not>
             </and>
         </condition>
+        <condition property="manifest.available+main.class">
+            <and>
+                <isset property="manifest.available"/>
+                <isset property="main.class.available"/>
+            </and>
+        </condition>
+        <condition property="do.archive">
+            <not>
+                <istrue value="${jar.archive.disabled}"/>
+            </not>
+        </condition>
+        <condition property="do.mkdist">
+            <and>
+                <isset property="do.archive"/>
+                <isset property="libs.CopyLibs.classpath"/>
+                <not>
+                    <istrue value="${mkdist.disabled}"/>
+                </not>
+            </and>
+        </condition>
         <condition property="manifest.available+main.class+mkdist.available">
             <and>
                 <istrue value="${manifest.available+main.class}"/>
-                <isset property="libs.CopyLibs.classpath"/>
+                <isset property="do.mkdist"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available">
+            <and>
+                <isset property="manifest.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+main.class.available">
+            <and>
+                <isset property="main.class.available"/>
+                <istrue value="${do.archive}"/>
             </and>
         </condition>
+        <condition property="do.archive+splashscreen.available">
+            <and>
+                <isset property="splashscreen.available"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="do.archive+manifest.available+main.class">
+            <and>
+                <istrue value="${manifest.available+main.class}"/>
+                <istrue value="${do.archive}"/>
+            </and>
+        </condition>
+        <condition property="manifest.available-mkdist.available">
+            <or>
+                <istrue value="${manifest.available}"/>
+                <isset property="do.mkdist"/>
+            </or>
+        </condition>
+        <condition property="manifest.available+main.class-mkdist.available">
+            <or>
+                <istrue value="${manifest.available+main.class}"/>
+                <isset property="do.mkdist"/>
+            </or>
+        </condition>
         <condition property="have.tests">
             <or>
                 <available file="${test.src.dir}"/>
@@ -104,6 +167,7 @@
         <property name="javadoc.preview" value="true"/>
         <property name="application.args" value=""/>
         <property name="source.encoding" value="${file.encoding}"/>
+        <property name="runtime.encoding" value="${source.encoding}"/>
         <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
             <and>
                 <isset property="javadoc.encoding"/>
@@ -119,12 +183,22 @@
         <condition property="do.depend.true">
             <istrue value="${do.depend}"/>
         </condition>
-        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
+        <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
+        <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
+            <length length="0" string="${endorsed.classpath}" when="greater"/>
+        </condition>
+        <condition else="false" property="jdkBug6558476">
             <and>
-                <isset property="jaxws.endorsed.dir"/>
-                <available file="nbproject/jaxws-build.xml"/>
+                <matches pattern="1\.[56]" string="${java.specification.version}"/>
+                <not>
+                    <os family="unix"/>
+                </not>
             </and>
         </condition>
+        <property name="javac.fork" value="${jdkBug6558476}"/>
+        <property name="jar.index" value="false"/>
+        <property name="jar.index.metainf" value="${jar.index}"/>
+        <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
     </target>
     <target name="-post-init">
         <!-- Empty placeholder for easier customization. -->
@@ -151,11 +225,13 @@
             </sequential>
         </macrodef>
     </target>
-    <target name="-init-macrodef-javac">
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
         <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
             <attribute default="${src.dir}" name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
             <attribute default="${includes}" name="includes"/>
             <attribute default="${excludes}" name="excludes"/>
             <attribute default="${javac.debug}" name="debug"/>
@@ -165,7 +241,8 @@
             <sequential>
                 <property location="${build.dir}/empty" name="empty.dir"/>
                 <mkdir dir="${empty.dir}"/>
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
+                <mkdir dir="@{apgeneratedsrcdir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
                     <src>
                         <dirset dir="@{gensrcdir}" erroronmissingdir="false">
                             <include name="*"/>
@@ -174,11 +251,53 @@
                     <classpath>
                         <path path="@{classpath}"/>
                     </classpath>
-                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <compilerarg value="-processorpath"/>
+                    <compilerarg path="@{processorpath}:${empty.dir}"/>
+                    <compilerarg line="${ap.processors.internal}"/>
+                    <compilerarg line="${annotation.processing.processor.options}"/>
+                    <compilerarg value="-s"/>
+                    <compilerarg path="@{apgeneratedsrcdir}"/>
+                    <compilerarg line="${ap.proc.none.internal}"/>
                     <customize/>
                 </javac>
             </sequential>
         </macrodef>
+    </target>
+    <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${build.classes.dir}" name="destdir"/>
+            <attribute default="${javac.classpath}" name="classpath"/>
+            <attribute default="${javac.processorpath}" name="processorpath"/>
+            <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
+            <attribute default="${includes}" name="includes"/>
+            <attribute default="${excludes}" name="excludes"/>
+            <attribute default="${javac.debug}" name="debug"/>
+            <attribute default="${empty.dir}" name="sourcepath"/>
+            <attribute default="${empty.dir}" name="gensrcdir"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.dir}/empty" name="empty.dir"/>
+                <mkdir dir="${empty.dir}"/>
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
+                    <src>
+                        <dirset dir="@{gensrcdir}" erroronmissingdir="false">
+                            <include name="*"/>
+                        </dirset>
+                    </src>
+                    <classpath>
+                        <path path="@{classpath}"/>
+                    </classpath>
+                    <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <compilerarg line="${javac.compilerargs}"/>
+                    <customize/>
+                </javac>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
         <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
             <attribute default="${src.dir}" name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
@@ -195,14 +314,19 @@
             <attribute default="${build.classes.dir}" name="destdir"/>
             <sequential>
                 <fail unless="javac.includes">Must set javac.includes</fail>
-                <pathconvert pathsep="," property="javac.includes.binary">
+                <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
                     <path>
                         <filelist dir="@{destdir}" files="${javac.includes}"/>
                     </path>
                     <globmapper from="*.java" to="*.class"/>
                 </pathconvert>
+                <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
+                <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
                 <delete>
-                    <files includes="${javac.includes.binary}"/>
+                    <files includesfile="${javac.includesfile.binary}"/>
+                </delete>
+                <delete>
+                    <fileset file="${javac.includesfile.binary}"/>
                 </delete>
             </sequential>
         </macrodef>
@@ -213,7 +337,8 @@
             <attribute default="${excludes}" name="excludes"/>
             <attribute default="**" name="testincludes"/>
             <sequential>
-                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
+                <property name="junit.forkmode" value="perTest"/>
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
                     <batchtest todir="${build.test.results.dir}">
                         <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
                             <filename name="@{testincludes}"/>
@@ -228,11 +353,57 @@
                     </syspropertyset>
                     <formatter type="brief" usefile="false"/>
                     <formatter type="xml"/>
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-ea"/>
                     <jvmarg line="${run.jvmargs}"/>
                 </junit>
             </sequential>
         </macrodef>
     </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
+    <target name="-profile-pre-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-profile-post-init">
+        <!-- Empty placeholder for easier customization. -->
+        <!-- You can override this target in the ../build.xml file. -->
+    </target>
+    <target name="-profile-init-macrodef-profile">
+        <macrodef name="resolve">
+            <attribute name="name"/>
+            <attribute name="value"/>
+            <sequential>
+                <property name="@{name}" value="${env.@{value}}"/>
+            </sequential>
+        </macrodef>
+        <macrodef name="profile">
+            <attribute default="${main.class}" name="classname"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property environment="env"/>
+                <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
+                <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
+                    <jvmarg value="${profiler.info.jvmargs.agent}"/>
+                    <jvmarg line="${profiler.info.jvmargs}"/>
+                    <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+                    <arg line="${application.args}"/>
+                    <classpath>
+                        <path path="${run.classpath}"/>
+                    </classpath>
+                    <syspropertyset>
+                        <propertyref prefix="run-sys-prop."/>
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
+                    </syspropertyset>
+                    <customize/>
+                </java>
+            </sequential>
+        </macrodef>
+    </target>
+    <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
+        <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
+        <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
+    </target>
     <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
         <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
             <attribute default="${main.class}" name="name"/>
@@ -284,10 +455,11 @@
             <element name="customize" optional="true"/>
             <sequential>
                 <java classname="@{classname}" dir="${work.dir}" fork="true">
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
                     <jvmarg line="${debug-args-line}"/>
                     <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
-                    <jvmarg value="-Dfile.encoding=${source.encoding}"/>
-                    <redirector errorencoding="${source.encoding}" inputencoding="${source.encoding}" outputencoding="${source.encoding}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
                     <jvmarg line="${run.jvmargs}"/>
                     <classpath>
                         <path path="@{classpath}"/>
@@ -308,8 +480,9 @@
             <element name="customize" optional="true"/>
             <sequential>
                 <java classname="@{classname}" dir="${work.dir}" fork="true">
-                    <jvmarg value="-Dfile.encoding=${source.encoding}"/>
-                    <redirector errorencoding="${source.encoding}" inputencoding="${source.encoding}" outputencoding="${source.encoding}"/>
+                    <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
+                    <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
+                    <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
                     <jvmarg line="${run.jvmargs}"/>
                     <classpath>
                         <path path="@{classpath}"/>
@@ -323,20 +496,87 @@
             </sequential>
         </macrodef>
     </target>
+    <target name="-init-macrodef-copylibs">
+        <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
+            <attribute default="${manifest.file}" name="manifest"/>
+            <element name="customize" optional="true"/>
+            <sequential>
+                <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
+                <pathconvert property="run.classpath.without.build.classes.dir">
+                    <path path="${run.classpath}"/>
+                    <map from="${build.classes.dir.resolved}" to=""/>
+                </pathconvert>
+                <pathconvert pathsep=" " property="jar.classpath">
+                    <path path="${run.classpath.without.build.classes.dir}"/>
+                    <chainedmapper>
+                        <flattenmapper/>
+                        <globmapper from="*" to="lib/*"/>
+                    </chainedmapper>
+                </pathconvert>
+                <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
+                <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
+                    <fileset dir="${build.classes.dir}"/>
+                    <manifest>
+                        <attribute name="Class-Path" value="${jar.classpath}"/>
+                        <customize/>
+                    </manifest>
+                </copylibs>
+            </sequential>
+        </macrodef>
+    </target>
     <target name="-init-presetdef-jar">
         <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
-            <jar compress="${jar.compress}" jarfile="${dist.jar}">
+            <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
                 <j2seproject1:fileset dir="${build.classes.dir}"/>
             </jar>
         </presetdef>
     </target>
-    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
+    <target name="-init-ap-cmdline-properties">
+        <property name="annotation.processing.enabled" value="true"/>
+        <property name="annotation.processing.processors.list" value=""/>
+        <property name="annotation.processing.processor.options" value=""/>
+        <property name="annotation.processing.run.all.processors" value="true"/>
+        <property name="javac.processorpath" value="${javac.classpath}"/>
+        <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
+        <condition property="ap.supported.internal" value="true">
+            <not>
+                <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
+        <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
+            <isfalse value="${annotation.processing.run.all.processors}"/>
+        </condition>
+        <condition else="" property="ap.proc.none.internal" value="-proc:none">
+            <isfalse value="${annotation.processing.enabled}"/>
+        </condition>
+    </target>
+    <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
+        <property name="ap.cmd.line.internal" value=""/>
+    </target>
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
     <!--
                 ===================
                 COMPILATION SECTION
                 ===================
             -->
-    <target depends="init" name="deps-jar" unless="no.deps"/>
+    <target name="-deps-jar-init" unless="built-jar.properties">
+        <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
+        <delete file="${built-jar.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
+        <echo level="warn" message="Cycle detected: MPipeline2 was already built"/>
+    </target>
+    <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-jar.properties}" verbose="false"/>
+        <property file="${built-jar.properties}" prefix="already.built.jar."/>
+        <antcall target="-warn-already-built-jar"/>
+        <propertyfile file="${built-jar.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
     <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
     <target depends="init" name="-check-automatic-build">
         <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
@@ -359,12 +599,18 @@
         </pathconvert>
         <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
     </target>
-    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
         <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
         <copy todir="${build.classes.dir}">
             <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
     </target>
+    <target if="has.persistence.xml" name="-copy-persistence-xml">
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy todir="${build.classes.dir}/META-INF">
+            <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
+        </copy>
+    </target>
     <target name="-post-compile">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
@@ -397,75 +643,65 @@
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
         <j2seproject1:jar/>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
         <j2seproject1:jar manifest="${manifest.file}"/>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
         <j2seproject1:jar manifest="${manifest.file}">
             <j2seproject1:manifest>
                 <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
             </j2seproject1:manifest>
         </j2seproject1:jar>
-        <echo>To run this application from the command line without Ant, try:</echo>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
         <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
         <property location="${dist.jar}" name="dist.jar.resolved"/>
         <pathconvert property="run.classpath.with.dist.jar">
             <path path="${run.classpath}"/>
             <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
         </pathconvert>
-        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+        <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
+    </target>
+    <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <touch file="${tmp.manifest.file}" verbose="false"/>
+    </target>
+    <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest">
+        <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
+        <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
+    </target>
+    <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main">
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="Main-Class" value="${main.class}"/>
+        </manifest>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
-        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
-        <pathconvert property="run.classpath.without.build.classes.dir">
-            <path path="${run.classpath}"/>
-            <map from="${build.classes.dir.resolved}" to=""/>
-        </pathconvert>
-        <pathconvert pathsep=" " property="jar.classpath">
-            <path path="${run.classpath.without.build.classes.dir}"/>
-            <chainedmapper>
-                <flattenmapper/>
-                <globmapper from="*" to="lib/*"/>
-            </chainedmapper>
-        </pathconvert>
-        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
-        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
-            <fileset dir="${build.classes.dir}"/>
-            <manifest>
-                <attribute name="Main-Class" value="${main.class}"/>
-                <attribute name="Class-Path" value="${jar.classpath}"/>
-            </manifest>
-        </copylibs>
-        <echo>To run this application from the command line without Ant, try:</echo>
+    <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen">
+        <basename file="${application.splash}" property="splashscreen.basename"/>
+        <mkdir dir="${build.classes.dir}/META-INF"/>
+        <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
+        <manifest file="${tmp.manifest.file}" mode="update">
+            <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
+        </manifest>
+    </target>
+    <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack">
+        <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
+        <echo level="info">To run this application from the command line without Ant, try:</echo>
         <property location="${dist.jar}" name="dist.jar.resolved"/>
-        <echo>java -jar "${dist.jar.resolved}"</echo>
+        <echo level="info">java -jar "${dist.jar.resolved}"</echo>
     </target>
-    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="libs.CopyLibs.classpath" name="-do-jar-with-libraries-without-manifest" unless="manifest.available+main.class">
-        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
-        <pathconvert property="run.classpath.without.build.classes.dir">
-            <path path="${run.classpath}"/>
-            <map from="${build.classes.dir.resolved}" to=""/>
-        </pathconvert>
-        <pathconvert pathsep=" " property="jar.classpath">
-            <path path="${run.classpath.without.build.classes.dir}"/>
-            <chainedmapper>
-                <flattenmapper/>
-                <globmapper from="*" to="lib/*"/>
-            </chainedmapper>
-        </pathconvert>
-        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
-        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
-            <fileset dir="${build.classes.dir}"/>
-        </copylibs>
+    <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">
+        <delete>
+            <fileset file="${tmp.manifest.file}"/>
+        </delete>
     </target>
+    <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/>
     <target name="-post-jar">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-do-jar-with-libraries-without-manifest,-post-jar" description="Build JAR." name="jar"/>
+    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
     <!--
                 =================
                 EXECUTION SECTION
@@ -481,11 +717,11 @@
     <target name="-do-not-recompile">
         <property name="javac.includes.binary" value=""/>
     </target>
-    <target depends="init,-do-not-recompile,compile-single" name="run-single">
+    <target depends="init,compile-single" name="run-single">
         <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
         <j2seproject1:java classname="${run.class}"/>
     </target>
-    <target depends="init,-do-not-recompile,compile-test-single" name="run-test-with-main">
+    <target depends="init,compile-test-single" name="run-test-with-main">
         <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
         <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
     </target>
@@ -516,12 +752,12 @@
         <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
         <j2seproject3:debug classname="${debug.class}"/>
     </target>
-    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
     <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
         <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
         <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
     </target>
-    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
+    <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
     <target depends="init" name="-pre-debug-fix">
         <fail unless="fix.includes">Must set fix.includes</fail>
         <property name="javac.includes" value="${fix.includes}.java"/>
@@ -531,23 +767,98 @@
     </target>
     <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
     <!--
+                =================
+                PROFILING SECTION
+                =================
+            -->
+    <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile/>
+    </target>
+    <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
+        <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="${profile.class}"/>
+    </target>
+    <!--
+                =========================
+                APPLET PROFILING  SECTION
+                =========================
+            -->
+    <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <profile classname="sun.applet.AppletViewer">
+            <customize>
+                <arg value="${applet.url}"/>
+            </customize>
+        </profile>
+    </target>
+    <!--
+                =========================
+                TESTS PROFILING  SECTION
+                =========================
+            -->
+    <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
+        <nbprofiledirect>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+        </nbprofiledirect>
+        <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
+            <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
+            <jvmarg value="${profiler.info.jvmargs.agent}"/>
+            <jvmarg line="${profiler.info.jvmargs}"/>
+            <test name="${profile.class}"/>
+            <classpath>
+                <path path="${run.test.classpath}"/>
+            </classpath>
+            <syspropertyset>
+                <propertyref prefix="test-sys-prop."/>
+                <mapper from="test-sys-prop.*" to="*" type="glob"/>
+            </syspropertyset>
+            <formatter type="brief" usefile="false"/>
+            <formatter type="xml"/>
+        </junit>
+    </target>
+    <!--
                 ===============
                 JAVADOC SECTION
                 ===============
             -->
-    <target depends="init" name="-javadoc-build">
+    <target depends="init" if="have.sources" name="-javadoc-build">
         <mkdir dir="${dist.javadoc.dir}"/>
         <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
             <classpath>
                 <path path="${javac.classpath}"/>
             </classpath>
-            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+            <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
                 <filename name="**/*.java"/>
             </fileset>
             <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
                 <include name="**/*.java"/>
+                <exclude name="*.java"/>
             </fileset>
         </javadoc>
+        <copy todir="${dist.javadoc.dir}">
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
+            <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
+                <include name="**/doc-files/**"/>
+            </fileset>
+        </copy>
     </target>
     <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
         <nbbrowse file="${dist.javadoc.dir}/index.html"/>
@@ -568,8 +879,8 @@
     <target if="do.depend.true" name="-compile-test-depend">
         <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
     </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
-        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
         <copy todir="${build.test.classes.dir}">
             <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
@@ -583,10 +894,10 @@
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
+    <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
         <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
         <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
-        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
+        <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
         <copy todir="${build.test.classes.dir}">
             <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
@@ -623,7 +934,7 @@
     <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
         <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
     </target>
-    <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
     <!--
                 =======================
                 JUNIT DEBUGGING SECTION
@@ -650,7 +961,7 @@
     <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
         <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
     </target>
-    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
+    <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
     <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
         <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
     </target>
@@ -687,14 +998,45 @@
                 CLEANUP SECTION
                 ===============
             -->
-    <target depends="init" name="deps-clean" unless="no.deps"/>
+    <target name="-deps-clean-init" unless="built-clean.properties">
+        <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
+        <delete file="${built-clean.properties}" quiet="true"/>
+    </target>
+    <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
+        <echo level="warn" message="Cycle detected: MPipeline2 was already built"/>
+    </target>
+    <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
+        <mkdir dir="${build.dir}"/>
+        <touch file="${built-clean.properties}" verbose="false"/>
+        <property file="${built-clean.properties}" prefix="already.built.clean."/>
+        <antcall target="-warn-already-built-clean"/>
+        <propertyfile file="${built-clean.properties}">
+            <entry key="${basedir}" value=""/>
+        </propertyfile>
+    </target>
     <target depends="init" name="-do-clean">
         <delete dir="${build.dir}"/>
-        <delete dir="${dist.dir}"/>
+        <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
     </target>
     <target name="-post-clean">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
     <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
+    <target name="-check-call-dep">
+        <property file="${call.built.properties}" prefix="already.built."/>
+        <condition property="should.call.dep">
+            <not>
+                <isset property="already.built.${call.subproject}"/>
+            </not>
+        </condition>
+    </target>
+    <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
+        <ant antfile="${call.script}" inheritall="false" target="${call.target}">
+            <propertyset>
+                <propertyref prefix="transfer."/>
+                <mapper from="transfer.*" to="*" type="glob"/>
+            </propertyset>
+        </ant>
+    </target>
 </project>
--- a/src/MPipeline2/nbproject/genfiles.properties	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/nbproject/genfiles.properties	Tue Dec 06 19:07:22 2011 +0100
@@ -4,8 +4,8 @@
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=2529af0d
-nbproject/build-impl.xml.script.CRC32=a08e85a1
-nbproject/build-impl.xml.stylesheet.CRC32=5c621a33@1.26.1.45
+nbproject/build-impl.xml.script.CRC32=dd4ee7f7
+nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
 nbproject/profiler-build-impl.xml.data.CRC32=75b02ef4
 nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
 nbproject/profiler-build-impl.xml.stylesheet.CRC32=42cb6bcf
--- a/src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPreferences.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPreferences.java	Tue Dec 06 19:07:22 2011 +0100
@@ -141,10 +141,10 @@
   public static LTPDAPreferences loadFromDisk(String filepath, float version) {
 
     LTPDAPreferences loadedPrefs = null;
-
     File filename = new File(filepath);
 
     if (filename.exists()) {
+      Utils.dmsg("Loading preferences from " + filepath);
       try {
         DocumentBuilderFactory parserFactory = DocumentBuilderFactory.newInstance();
         parserFactory.setValidating(false);
@@ -198,9 +198,8 @@
   }
 
   public void writeToDisk() {
-    Utils.msg("Saving preferences to " + filename);
-
     if (filename != null) {
+      Utils.dmsg("Saving preferences to " + filename);
       try {
         Document doc = XMLUtils.createDocument("LTPDAPreferences");
         Element root = doc.getDocumentElement();
--- a/src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPrefsGui.form	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPrefsGui.form	Tue Dec 06 19:07:22 2011 +0100
@@ -28,16 +28,24 @@
   <Layout>
     <DimensionLayout dim="0">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
-          <Component id="mainPanel" alignment="0" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Component id="mainPanel" alignment="1" max="32767" attributes="0"/>
+                  <Component id="doneBtn" alignment="1" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
       </Group>
     </DimensionLayout>
     <DimensionLayout dim="1">
       <Group type="103" groupAlignment="0" attributes="0">
           <Group type="102" alignment="1" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
               <Component id="mainPanel" max="32767" attributes="0"/>
-              <EmptySpace type="separate" max="-2" attributes="0"/>
-              <Component id="jPanel2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Component id="doneBtn" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
           </Group>
       </Group>
     </DimensionLayout>
@@ -46,65 +54,31 @@
     <Container class="javax.swing.JPanel" name="mainPanel">
       <Properties>
         <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
-          <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
-            <EtchetBorder/>
-          </Border>
-        </Property>
-      </Properties>
-
-      <Layout>
-        <DimensionLayout dim="0">
-          <Group type="103" groupAlignment="0" attributes="0">
-              <EmptySpace min="0" pref="632" max="32767" attributes="0"/>
-          </Group>
-        </DimensionLayout>
-        <DimensionLayout dim="1">
-          <Group type="103" groupAlignment="0" attributes="0">
-              <EmptySpace min="0" pref="411" max="32767" attributes="0"/>
-          </Group>
-        </DimensionLayout>
-      </Layout>
-    </Container>
-    <Container class="javax.swing.JPanel" name="jPanel2">
-      <Properties>
-        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
-          <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
-            <EtchetBorder/>
-          </Border>
+          <Border info="null"/>
         </Property>
       </Properties>
 
       <Layout>
         <DimensionLayout dim="0">
           <Group type="103" groupAlignment="0" attributes="0">
-              <Group type="102" alignment="1" attributes="0">
-                  <EmptySpace pref="538" max="32767" attributes="0"/>
-                  <Component id="doneBtn" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace max="-2" attributes="0"/>
-              </Group>
+              <EmptySpace min="0" pref="612" max="32767" attributes="0"/>
           </Group>
         </DimensionLayout>
         <DimensionLayout dim="1">
           <Group type="103" groupAlignment="0" attributes="0">
-              <Group type="102" alignment="0" attributes="0">
-                  <EmptySpace max="-2" attributes="0"/>
-                  <Component id="doneBtn" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace max="32767" attributes="0"/>
-              </Group>
+              <EmptySpace min="0" pref="422" max="32767" attributes="0"/>
           </Group>
         </DimensionLayout>
       </Layout>
-      <SubComponents>
-        <Component class="javax.swing.JButton" name="doneBtn">
-          <Properties>
-            <Property name="text" type="java.lang.String" value="Done"/>
-            <Property name="toolTipText" type="java.lang.String" value="Close without applying the preferences."/>
-          </Properties>
-          <Events>
-            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="doneBtnActionPerformed"/>
-          </Events>
-        </Component>
-      </SubComponents>
     </Container>
+    <Component class="javax.swing.JButton" name="doneBtn">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Done"/>
+        <Property name="toolTipText" type="java.lang.String" value="Close without applying the preferences."/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="doneBtnActionPerformed"/>
+      </Events>
+    </Component>
   </SubComponents>
 </Form>
--- a/src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPrefsGui.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/LTPDAPrefsGui.java	Tue Dec 06 19:07:22 2011 +0100
@@ -75,7 +75,6 @@
   private void initComponents() {
 
     mainPanel = new javax.swing.JPanel();
-    jPanel2 = new javax.swing.JPanel();
     doneBtn = new javax.swing.JButton();
 
     setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@@ -88,21 +87,19 @@
       }
     });
 
-    mainPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+    mainPanel.setBorder(null);
 
     org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
     mainPanel.setLayout(mainPanelLayout);
     mainPanelLayout.setHorizontalGroup(
       mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(0, 632, Short.MAX_VALUE)
+      .add(0, 612, Short.MAX_VALUE)
     );
     mainPanelLayout.setVerticalGroup(
       mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(0, 411, Short.MAX_VALUE)
+      .add(0, 422, Short.MAX_VALUE)
     );
 
-    jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
     doneBtn.setText("Done");
     doneBtn.setToolTipText("Close without applying the preferences.");
     doneBtn.addActionListener(new java.awt.event.ActionListener() {
@@ -111,50 +108,30 @@
       }
     });
 
-    org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
-    jPanel2.setLayout(jPanel2Layout);
-    jPanel2Layout.setHorizontalGroup(
-      jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
-        .addContainerGap(538, Short.MAX_VALUE)
-        .add(doneBtn)
-        .addContainerGap())
-    );
-    jPanel2Layout.setVerticalGroup(
-      jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jPanel2Layout.createSequentialGroup()
-        .addContainerGap()
-        .add(doneBtn)
-        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-    );
-
     org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
     getContentPane().setLayout(layout);
     layout.setHorizontalGroup(
       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-      .add(mainPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+          .add(mainPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+          .add(doneBtn))
+        .addContainerGap())
     );
     layout.setVerticalGroup(
       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
       .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+        .addContainerGap()
         .add(mainPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-        .add(18, 18, 18)
-        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(doneBtn)
+        .addContainerGap())
     );
 
     pack();
   }// </editor-fold>//GEN-END:initComponents
 
-  private void doneBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneBtnActionPerformed
-
-    prefs.writeToDisk();
-//    this.dispose();
-
-    this.formWindowClosing(null);
-
-  }//GEN-LAST:event_doneBtnActionPerformed
-
   private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
 
 //    System.err.println("Form closing");
@@ -167,9 +144,17 @@
     }
 
   }//GEN-LAST:event_formWindowClosing
+
+private void doneBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneBtnActionPerformed
+
+    prefs.writeToDisk();
+//    this.dispose();
+
+    this.formWindowClosing(null);
+}//GEN-LAST:event_doneBtnActionPerformed
+
   // Variables declaration - do not modify//GEN-BEGIN:variables
   private javax.swing.JButton doneBtn;
-  private javax.swing.JPanel jPanel2;
   private javax.swing.JPanel mainPanel;
   // End of variables declaration//GEN-END:variables
 //  public void update(Observable o, Object arg) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,153 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="title" type="java.lang.String" value="Database connection"/>
+    <Property name="locationByPlatform" type="boolean" value="true"/>
+    <Property name="modal" type="boolean" value="true"/>
+    <Property name="resizable" type="boolean" value="false"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="jLabel9" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
+                      <Component id="hostnameCombo" pref="240" max="32767" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="jLabel10" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
+                      <Component id="databaseCombo" pref="240" max="32767" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="cancelButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="okButton" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="jLabel11" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace type="separate" max="-2" attributes="0"/>
+                      <Component id="usernameCombo" pref="240" max="32767" attributes="0"/>
+                  </Group>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="hostnameCombo" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="databaseCombo" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="usernameCombo" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace pref="12" max="32767" attributes="0"/>
+                      <Component id="okButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
+                      <Component id="cancelButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                  </Group>
+              </Group>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="jLabel9">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Hostname:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel10">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Database:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel11">
+      <Properties>
+        <Property name="horizontalAlignment" type="int" value="4"/>
+        <Property name="text" type="java.lang.String" value="Username:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="databaseCombo">
+      <Properties>
+        <Property name="editable" type="boolean" value="true"/>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="0"/>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="hostnameCombo">
+      <Properties>
+        <Property name="editable" type="boolean" value="true"/>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="0"/>
+        </Property>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="hostnameComboActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="usernameCombo">
+      <Properties>
+        <Property name="editable" type="boolean" value="true"/>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="0"/>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JButton" name="okButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Ok"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="cancelButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cancel"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelButtonActionPerformed"/>
+      </Events>
+    </Component>
+  </SubComponents>
+</Form>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -0,0 +1,208 @@
+package mpipeline.ltpdapreferences;
+
+import java.util.HashSet;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.table.TableModel;
+
+public class RepositoryDialog extends javax.swing.JDialog {
+
+  public boolean cancelled = true;
+  public String hostname;
+  public String database;
+  public String username;
+  private TableModel model;
+
+  public RepositoryDialog(java.awt.Window parent, TableModel model) {
+    super(parent, java.awt.Dialog.ModalityType.APPLICATION_MODAL);
+    this.model = model;
+    initComponents();
+    initHostnameCombo();
+    initDatabaseCombo();
+    initUsernameCombo();
+    super.setLocationRelativeTo(parent);
+  }
+
+  public RepositoryDialog(java.awt.Frame parent) {
+    super(parent, true);
+    initComponents();
+    super.setLocationRelativeTo(parent);
+  }
+
+  public RepositoryDialog() {
+    super(new java.awt.Frame(), true);
+    initComponents();
+  }
+
+  @SuppressWarnings("unchecked")
+  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+  private void initComponents() {
+
+    jLabel9 = new javax.swing.JLabel();
+    jLabel10 = new javax.swing.JLabel();
+    jLabel11 = new javax.swing.JLabel();
+    databaseCombo = new javax.swing.JComboBox();
+    hostnameCombo = new javax.swing.JComboBox();
+    usernameCombo = new javax.swing.JComboBox();
+    okButton = new javax.swing.JButton();
+    cancelButton = new javax.swing.JButton();
+
+    setTitle("Database connection");
+    setLocationByPlatform(true);
+    setModal(true);
+    setResizable(false);
+
+    jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+    jLabel9.setText("Hostname:");
+
+    jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+    jLabel10.setText("Database:");
+
+    jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
+    jLabel11.setText("Username:");
+
+    databaseCombo.setEditable(true);
+
+    hostnameCombo.setEditable(true);
+    hostnameCombo.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        hostnameComboActionPerformed(evt);
+      }
+    });
+
+    usernameCombo.setEditable(true);
+
+    okButton.setText("Ok");
+    okButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        okButtonActionPerformed(evt);
+      }
+    });
+
+    cancelButton.setText("Cancel");
+    cancelButton.addActionListener(new java.awt.event.ActionListener() {
+      public void actionPerformed(java.awt.event.ActionEvent evt) {
+        cancelButtonActionPerformed(evt);
+      }
+    });
+
+    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+    getContentPane().setLayout(layout);
+    layout.setHorizontalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+          .add(layout.createSequentialGroup()
+            .add(jLabel9)
+            .add(18, 18, 18)
+            .add(hostnameCombo, 0, 240, Short.MAX_VALUE))
+          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+            .add(jLabel10)
+            .add(21, 21, 21)
+            .add(databaseCombo, 0, 240, Short.MAX_VALUE))
+          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+            .add(cancelButton)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(okButton))
+          .add(layout.createSequentialGroup()
+            .add(jLabel11)
+            .add(18, 18, 18)
+            .add(usernameCombo, 0, 240, Short.MAX_VALUE)))
+        .addContainerGap())
+    );
+    layout.setVerticalGroup(
+      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+      .add(layout.createSequentialGroup()
+        .addContainerGap()
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(hostnameCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel9))
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(databaseCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel10))
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(jLabel11)
+          .add(usernameCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+          .add(layout.createSequentialGroup()
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
+            .add(okButton)
+            .addContainerGap())
+          .add(layout.createSequentialGroup()
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+            .add(cancelButton)
+            .addContainerGap())))
+    );
+
+    pack();
+  }// </editor-fold>//GEN-END:initComponents
+
+    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
+      cancelled = true;
+      doClose();
+    }//GEN-LAST:event_cancelButtonActionPerformed
+
+    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
+      cancelled = false;
+      hostname = (String) hostnameCombo.getSelectedItem();
+      database = (String) databaseCombo.getSelectedItem();
+      username = (String) usernameCombo.getSelectedItem();
+      doClose();
+    }//GEN-LAST:event_okButtonActionPerformed
+
+    private void hostnameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hostnameComboActionPerformed
+      initDatabaseCombo();
+      initUsernameCombo();
+    }//GEN-LAST:event_hostnameComboActionPerformed
+
+  private void initHostnameCombo() {
+    HashSet<String> hostnames = new HashSet<String>();
+    int rows = model.getRowCount();
+    for (int i = 0; i < rows; i++) {
+      hostnames.add((String) model.getValueAt(i, 0));
+    }
+    hostnameCombo.setModel(new DefaultComboBoxModel(hostnames.toArray()));
+  }
+
+  private void initDatabaseCombo() {
+    HashSet<String> databases = new HashSet<String>();
+    hostname = (String) hostnameCombo.getSelectedItem();
+    int rows = model.getRowCount();
+    for (int i = 0; i < rows; i++) {
+      if (hostname.equals((String) model.getValueAt(i, 0))) {
+        databases.add((String) model.getValueAt(i, 1));
+      }
+    }
+    databaseCombo.setModel(new DefaultComboBoxModel(databases.toArray()));
+  }
+
+  private void initUsernameCombo() {
+    HashSet<String> usernames = new HashSet<String>();
+    hostname = (String) hostnameCombo.getSelectedItem();
+    int rows = model.getRowCount();
+    for (int i = 0; i < rows; i++) {
+      if (hostname.equals((String) model.getValueAt(i, 0))) {
+        usernames.add((String) model.getValueAt(i, 2));
+      }
+    }
+    usernameCombo.setModel(new DefaultComboBoxModel(usernames.toArray()));
+  }
+  
+  private void doClose() {
+    setVisible(false);
+    dispose();
+
+  }
+  // Variables declaration - do not modify//GEN-BEGIN:variables
+  private javax.swing.JButton cancelButton;
+  private javax.swing.JComboBox databaseCombo;
+  private javax.swing.JComboBox hostnameCombo;
+  private javax.swing.JLabel jLabel10;
+  private javax.swing.JLabel jLabel11;
+  private javax.swing.JLabel jLabel9;
+  private javax.swing.JButton okButton;
+  private javax.swing.JComboBox usernameCombo;
+  // End of variables declaration//GEN-END:variables
+}
--- a/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryPrefGroup.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryPrefGroup.java	Tue Dec 06 19:07:22 2011 +0100
@@ -4,16 +4,13 @@
  */
 package mpipeline.ltpdapreferences;
 
+import java.util.List;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
 import mpipeline.utils.MXMLUtils;
-import mpipeline.utils.Utils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 /**
  *
@@ -23,26 +20,40 @@
 
   public static final int REPOSITORY_HOSTNAMES_CHANGED = 1;
   public static final int REPOSITORY_EXPIRY_CHANGED = 2;
-
-  private ArrayList<String> hostnames = new ArrayList<String>();
+  public static final int REPOSITORY_CACHE_PASSWORD_CHANGED = 3;
+  public static final int REPOSITORY_MAX_CONNECTIONS_NUMBER_CHANGED = 4;
+  
   private Integer expiry = 60;
+  private Integer cachePassword = 2;
+  private Integer maxConnectionsNumber = 10;
+  private ArrayList<String[]> repositories = new ArrayList<String[]>(0);
 
   public RepositoryPrefGroup() {
   }
-
+  
   public RepositoryPrefGroup(Node node, float version) {
 
     NamedNodeMap nmap = node.getAttributes();
     expiry = MXMLUtils.getIntegerFromNode("expiry", nmap, version, version);
-
-    NodeList nl = node.getChildNodes();
-    for (int ii = 0; ii < nl.getLength(); ii++) {
-      Node n = nl.item(ii);
-      Utils.dmsg(" reading child node: " + n.getNodeName());
-      if (n.getNodeName().equals("Hostname")) {
-        NamedNodeMap wbnm = n.getAttributes();
-        String path = MXMLUtils.getStringFromNode("Host", wbnm, version, version);
-        this.addHostname(path);
+    cachePassword = MXMLUtils.getIntegerFromNode("cachePassword", nmap, version, version);
+    if (cachePassword < 0)
+        cachePassword = 2;
+    maxConnectionsNumber = MXMLUtils.getIntegerFromNode("maxConnectionsNumber", nmap, version, version);
+    if (maxConnectionsNumber < 0)
+        maxConnectionsNumber = 10;
+    
+    org.w3c.dom.NodeList nodes = node.getChildNodes();    
+    for (int i = 0; i < nodes.getLength(); i++) {
+      try {
+        if (nodes.item(i).getNodeName().equals("Entry")) {
+          NamedNodeMap map = nodes.item(i).getAttributes();
+          String hostname = map.getNamedItem("hostname").getNodeValue();
+          String database = map.getNamedItem("database").getNodeValue();
+          String username = map.getNamedItem("username").getNodeValue();
+          repositories.add(new String[]{hostname, database, username});
+        }
+      } catch (NullPointerException ex) {
+        // continue
       }
     }
   }
@@ -50,29 +61,17 @@
   public void attachToDom(Document doc, Element tnode) {
 
     Element pnode = doc.createElement("Repository");
-
     pnode.setAttribute("expiry", ""+expiry);
-
-    Iterator it = hostnames.iterator();
-    while (it.hasNext()) {
-      String path = (String) it.next();
-      Element snode = doc.createElement("Hostname");
-      snode.setAttribute("Host", path);
-      pnode.appendChild(snode);
-    }
-
+    pnode.setAttribute("cachePassword", ""+cachePassword);
+    pnode.setAttribute("maxConnectionsNumber", ""+maxConnectionsNumber);
     tnode.appendChild(pnode);
-
-  }
-
-  public void addHostname(String host) {
-    hostnames.add(host);
-    this.setChanged();
-    this.notifyObservers(REPOSITORY_HOSTNAMES_CHANGED);
-  }
-
-  public ArrayList<String> getHostnames() {
-    return hostnames;
+    for (String[] repo : repositories) {
+      Element node = doc.createElement("Entry");
+      node.setAttribute("hostname", repo[0]);
+      node.setAttribute("database", repo[1]);
+      node.setAttribute("username", repo[2]);
+      pnode.appendChild(node);
+    }
   }
 
   public Integer getExpiry() {
@@ -84,20 +83,42 @@
     setChanged();
     notifyObservers(REPOSITORY_EXPIRY_CHANGED);
   }
+  
+  public Integer getCachePassword() {
+    return cachePassword;
+  }
 
-  public void setHostnames(ArrayList<String> hostnames) {
-    this.hostnames = hostnames;
+  public void setCachePassword(Integer value) {
+    cachePassword = value;
     setChanged();
-    notifyObservers(REPOSITORY_HOSTNAMES_CHANGED);
+    notifyObservers(REPOSITORY_CACHE_PASSWORD_CHANGED);
+  }
+
+  public Integer getMaxConnectionsNumber() {
+    return maxConnectionsNumber;
   }
 
-  public void display() {
-    System.out.println("Hostnames: " + hostnames);
+  public void setMaxConnectionsNumber(Integer value) {
+    maxConnectionsNumber = value;
+    setChanged();
+    notifyObservers(REPOSITORY_MAX_CONNECTIONS_NUMBER_CHANGED);
+  }
+  
+  public ArrayList<String[]> getRepositories() {
+    return repositories;
   }
-
-  public void removeHostnames(Object objs[]) {
-    hostnames.removeAll(Arrays.asList(objs));
-    this.setChanged();
-    this.notifyObservers(REPOSITORY_HOSTNAMES_CHANGED);
+  
+  public void setRepositories(ArrayList<String[]> value) {
+    repositories.clear();
+    for (String[] repo : value) {
+      repositories.add(repo);
+    }
+    setChanged();
+  }
+  
+  public void display() {
+    System.out.printf(
+        "RepositoryPrefGroup(expiry=%d, cachePassword=%d, maxConnectionsNumber=%d)\n",
+        expiry, cachePassword, maxConnectionsNumber);
   }
 }
--- a/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryPrefGroupPanel.form	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryPrefGroupPanel.form	Tue Dec 06 19:07:22 2011 +0100
@@ -1,6 +1,6 @@
 <?xml version="1.1" encoding="UTF-8" ?>
 
-<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+<Form version="1.6" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
   <AuxValues>
     <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
     <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@@ -16,27 +16,34 @@
   <Layout>
     <DimensionLayout dim="0">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="1" attributes="0">
+          <Group type="102" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="1" attributes="0">
-                  <Component id="removeBtn" alignment="1" min="-2" max="-2" attributes="0"/>
-                  <Component id="jScrollPane1" alignment="0" pref="380" max="32767" attributes="0"/>
-                  <Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
-                  <Group type="102" alignment="1" attributes="0">
-                      <Group type="103" groupAlignment="1" attributes="0">
-                          <Group type="102" attributes="0">
-                              <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="scrollPane" alignment="0" pref="422" max="32767" attributes="0"/>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Group type="103" groupAlignment="1" max="-2" attributes="0">
+                          <Group type="102" alignment="0" attributes="1">
+                              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
-                              <Component id="expirySpinner" max="32767" attributes="0"/>
+                              <Component id="cachePasswordComboBox" max="32767" attributes="1"/>
                           </Group>
-                          <Group type="102" alignment="1" attributes="0">
-                              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
-                              <EmptySpace max="-2" attributes="0"/>
-                              <Component id="newHostnameTextField" pref="226" max="32767" attributes="0"/>
-                          </Group>
+                          <Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
                       </Group>
-                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                      <Component id="addBtn" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="expirySpinner" min="-2" pref="76" max="-2" attributes="1"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="addButton" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="removeButton" min="-2" max="-2" attributes="0"/>
+                  </Group>
+                  <Group type="102" alignment="0" attributes="0">
+                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
+                      <Component id="maxConnectionsNumberSpinner" min="-2" pref="48" max="-2" attributes="1"/>
                   </Group>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
@@ -47,87 +54,39 @@
       <Group type="103" groupAlignment="0" attributes="0">
           <Group type="102" alignment="0" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
-              <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
-              <EmptySpace type="unrelated" max="-2" attributes="0"/>
-              <Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="103" alignment="0" groupAlignment="3" attributes="0">
-                      <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
-                      <Component id="newHostnameTextField" alignment="3" min="-2" max="-2" attributes="0"/>
-                  </Group>
-                  <Component id="addBtn" min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="maxConnectionsNumberSpinner" alignment="3" min="-2" max="-2" attributes="0"/>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
-              <Component id="removeBtn" min="-2" max="-2" attributes="0"/>
-              <EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="2" attributes="0">
-                  <Component id="jLabel3" alignment="2" min="-2" max="-2" attributes="0"/>
-                  <Component id="expirySpinner" alignment="2" min="-2" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="cachePasswordComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="expirySpinner" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
               </Group>
-              <EmptySpace max="32767" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="jLabel5" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="scrollPane" pref="152" max="32767" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="3" attributes="0">
+                  <Component id="addButton" alignment="3" min="-2" max="-2" attributes="0"/>
+                  <Component id="removeButton" alignment="3" min="-2" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
           </Group>
       </Group>
     </DimensionLayout>
   </Layout>
   <SubComponents>
-    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
-      <AuxValues>
-        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-      </AuxValues>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
-      <SubComponents>
-        <Component class="javax.swing.JList" name="hostnameList">
-          <Properties>
-            <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
-              <StringArray count="0"/>
-            </Property>
-          </Properties>
-        </Component>
-      </SubComponents>
-    </Container>
-    <Component class="javax.swing.JTextField" name="newHostnameTextField">
-    </Component>
-    <Component class="javax.swing.JLabel" name="jLabel1">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="New Hostname:"/>
-      </Properties>
-    </Component>
-    <Component class="javax.swing.JButton" name="addBtn">
-      <Properties>
-        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-          <Image iconType="3" name="/mpipeline/icons/add_small.png"/>
-        </Property>
-        <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-          <Image iconType="3" name="/mpipeline/icons/add_small_ro.png"/>
-        </Property>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="removeBtn">
-      <Properties>
-        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-          <Image iconType="3" name="/mpipeline/icons/subtract_small.png"/>
-        </Property>
-        <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-          <Image iconType="3" name="/mpipeline/icons/subtract_small_ro.png"/>
-        </Property>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JLabel" name="jLabel2">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="User-defined LTPDA Repository Hostnames"/>
-      </Properties>
-    </Component>
     <Component class="javax.swing.JLabel" name="jLabel3">
       <Properties>
-        <Property name="text" type="java.lang.String" value="Repository Login Expiry (s):"/>
+        <Property name="text" type="java.lang.String" value="Cached passwords expire after:"/>
       </Properties>
     </Component>
     <Component class="javax.swing.JSpinner" name="expirySpinner">
@@ -137,5 +96,90 @@
         </Property>
       </Properties>
     </Component>
+    <Component class="javax.swing.JLabel" name="jLabel1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Maximum number of simultaneous database connections:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Cache password:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JSpinner" name="maxConnectionsNumberSpinner">
+      <Properties>
+        <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
+          <SpinnerModel initial="1" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JComboBox" name="cachePasswordComboBox">
+      <Properties>
+        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+          <StringArray count="3">
+            <StringItem index="0" value="No"/>
+            <StringItem index="1" value="Yes"/>
+            <StringItem index="2" value="Ask"/>
+          </StringArray>
+        </Property>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JLabel" name="jLabel4">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="[seconds]"/>
+      </Properties>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="scrollPane">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="databasesTable">
+          <Properties>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
+              <Table columnCount="3" rowCount="0">
+                <Column editable="false" title="Hostname" type="java.lang.String"/>
+                <Column editable="false" title="Database" type="java.lang.String"/>
+                <Column editable="false" title="Username" type="java.lang.String"/>
+              </Table>
+            </Property>
+            <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+              <Color blue="cc" green="cc" red="cc" type="rgb"/>
+            </Property>
+            <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+              <Dimension value="[0, 0]"/>
+            </Property>
+            <Property name="rowHeight" type="int" value="24"/>
+            <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor">
+              <JTableSelectionModel selectionMode="0"/>
+            </Property>
+            <Property name="showVerticalLines" type="boolean" value="false"/>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JLabel" name="jLabel5">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Repositories:"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JButton" name="addButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Add"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="addButtonActionPerformed"/>
+      </Events>
+    </Component>
+    <Component class="javax.swing.JButton" name="removeButton">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Remove"/>
+      </Properties>
+      <Events>
+        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeButtonActionPerformed"/>
+      </Events>
+    </Component>
   </SubComponents>
 </Form>
--- a/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryPrefGroupPanel.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/ltpdapreferences/RepositoryPrefGroupPanel.java	Tue Dec 06 19:07:22 2011 +0100
@@ -10,23 +10,32 @@
  */
 package mpipeline.ltpdapreferences;
 
+import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
+import java.util.ArrayList;
 import java.util.Observable;
 import java.util.Observer;
-import javax.swing.DefaultListModel;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
+import javax.swing.event.TableModelListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.DefaultTableCellRenderer;
+
+class CellRenderer extends DefaultTableCellRenderer {
+  @Override
+  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+    return super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
+  }
+}
 
 /**
  *
  * @author hewitson
  */
-public class RepositoryPrefGroupPanel extends javax.swing.JPanel implements Observer, ChangeListener, ActionListener {
+public class RepositoryPrefGroupPanel extends javax.swing.JPanel implements Observer, ChangeListener, ActionListener, TableModelListener {
 
   private RepositoryPrefGroup repoPrefs;
 
@@ -34,19 +43,22 @@
   public RepositoryPrefGroupPanel(RepositoryPrefGroup repoPrefs) {
     this.repoPrefs = repoPrefs;
     initComponents();
-
-    DefaultListModel mdl = new DefaultListModel();
-    hostnameList.setModel(mdl);
+    databasesTable.setDefaultRenderer(Object.class, new CellRenderer());
+    
     setPreferences();
     repoPrefs.addObserver(this);
 
+    maxConnectionsNumberSpinner.addChangeListener(this);
+    cachePasswordComboBox.addActionListener(this);
     expirySpinner.addChangeListener(this);
-
+    databasesTable.getModel().addTableModelListener(this);
   }
 
   public void setPreferences() {
-    updateHostnames();
+    updateMaxConnectionsNumber();
+    updateCachePasswords();
     updateExpiry();
+    updateRepositories();
   }
 
   /** This method is called from within the constructor to
@@ -58,154 +70,237 @@
   // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {
 
-    jScrollPane1 = new javax.swing.JScrollPane();
-    hostnameList = new javax.swing.JList();
-    newHostnameTextField = new javax.swing.JTextField();
-    jLabel1 = new javax.swing.JLabel();
-    addBtn = new javax.swing.JButton();
-    removeBtn = new javax.swing.JButton();
-    jLabel2 = new javax.swing.JLabel();
     jLabel3 = new javax.swing.JLabel();
     expirySpinner = new javax.swing.JSpinner();
+    jLabel1 = new javax.swing.JLabel();
+    jLabel2 = new javax.swing.JLabel();
+    maxConnectionsNumberSpinner = new javax.swing.JSpinner();
+    cachePasswordComboBox = new javax.swing.JComboBox();
+    jLabel4 = new javax.swing.JLabel();
+    scrollPane = new javax.swing.JScrollPane();
+    databasesTable = new javax.swing.JTable();
+    jLabel5 = new javax.swing.JLabel();
+    addButton = new javax.swing.JButton();
+    removeButton = new javax.swing.JButton();
 
-    jScrollPane1.setViewportView(hostnameList);
+    jLabel3.setText("Cached passwords expire after:");
+
+    expirySpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 10000000, 10));
+
+    jLabel1.setText("Maximum number of simultaneous database connections:");
+
+    jLabel2.setText("Cache password:");
 
-    jLabel1.setText("New Hostname:");
+    maxConnectionsNumberSpinner.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
+
+    cachePasswordComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "No", "Yes", "Ask" }));
+
+    jLabel4.setText("[seconds]");
+
+    databasesTable.setModel(new javax.swing.table.DefaultTableModel(
+      new Object [][] {
 
-    addBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_small.png"))); // NOI18N
-    addBtn.setRolloverEnabled(true);
-    addBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_small_ro.png"))); // NOI18N
-    addBtn.addActionListener(new java.awt.event.ActionListener() {
+      },
+      new String [] {
+        "Hostname", "Database", "Username"
+      }
+    ) {
+      Class[] types = new Class [] {
+        java.lang.String.class, java.lang.String.class, java.lang.String.class
+      };
+      boolean[] canEdit = new boolean [] {
+        false, false, false
+      };
+
+      public Class getColumnClass(int columnIndex) {
+        return types [columnIndex];
+      }
+
+      public boolean isCellEditable(int rowIndex, int columnIndex) {
+        return canEdit [columnIndex];
+      }
+    });
+    databasesTable.setGridColor(new java.awt.Color(204, 204, 204));
+    databasesTable.setIntercellSpacing(new java.awt.Dimension(0, 0));
+    databasesTable.setRowHeight(24);
+    databasesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+    databasesTable.setShowVerticalLines(false);
+    scrollPane.setViewportView(databasesTable);
+
+    jLabel5.setText("Repositories:");
+
+    addButton.setText("Add");
+    addButton.addActionListener(new java.awt.event.ActionListener() {
       public void actionPerformed(java.awt.event.ActionEvent evt) {
-        addBtnActionPerformed(evt);
+        addButtonActionPerformed(evt);
       }
     });
 
-    removeBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/subtract_small.png"))); // NOI18N
-    removeBtn.setRolloverEnabled(true);
-    removeBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/subtract_small_ro.png"))); // NOI18N
-    removeBtn.addActionListener(new java.awt.event.ActionListener() {
+    removeButton.setText("Remove");
+    removeButton.addActionListener(new java.awt.event.ActionListener() {
       public void actionPerformed(java.awt.event.ActionEvent evt) {
-        removeBtnActionPerformed(evt);
+        removeButtonActionPerformed(evt);
       }
     });
 
-    jLabel2.setText("User-defined LTPDA Repository Hostnames");
-
-    jLabel3.setText("Repository Login Expiry (s):");
-
-    expirySpinner.setModel(new javax.swing.SpinnerNumberModel(0, 0, 10000000, 10));
-
     org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
     this.setLayout(layout);
     layout.setHorizontalGroup(
       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+      .add(layout.createSequentialGroup()
         .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-          .add(removeBtn)
-          .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 372, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+          .add(scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE)
           .add(layout.createSequentialGroup()
-            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-              .add(layout.createSequentialGroup()
-                .add(jLabel3)
+            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+              .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+                .add(jLabel2)
                 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-                .add(expirySpinner))
-              .add(layout.createSequentialGroup()
-                .add(jLabel1)
-                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-                .add(newHostnameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)))
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-            .add(addBtn)))
+                .add(cachePasswordComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+              .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel3))
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(expirySpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(jLabel4))
+          .add(jLabel5)
+          .add(layout.createSequentialGroup()
+            .add(addButton)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(removeButton))
+          .add(layout.createSequentialGroup()
+            .add(jLabel1)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+            .add(maxConnectionsNumberSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 48, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
         .addContainerGap())
     );
     layout.setVerticalGroup(
       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
       .add(layout.createSequentialGroup()
         .addContainerGap()
-        .add(jLabel2)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(jLabel1)
+          .add(maxConnectionsNumberSpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-          .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-            .add(jLabel1)
-            .add(newHostnameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-          .add(addBtn))
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(jLabel2)
+          .add(cachePasswordComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(jLabel3)
+          .add(expirySpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+          .add(jLabel4))
+        .add(18, 18, 18)
+        .add(jLabel5)
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(removeBtn)
-        .add(10, 10, 10)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
-          .add(jLabel3)
-          .add(expirySpinner, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        .add(scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+          .add(addButton)
+          .add(removeButton))
+        .addContainerGap())
     );
   }// </editor-fold>//GEN-END:initComponents
 
-  private void removeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeBtnActionPerformed
-    // get selected index
-    Object objs[] = hostnameList.getSelectedValues();
-    repoPrefs.removeHostnames(objs);
-  }//GEN-LAST:event_removeBtnActionPerformed
+private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
+  DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
+  RepositoryDialog dialog = new RepositoryDialog(javax.swing.SwingUtilities.windowForComponent(this), model);
+  dialog.setVisible(true);
+  if (! dialog.cancelled)
+    model.insertRow(model.getRowCount(), new Object[]{dialog.hostname, dialog.database, dialog.username});
+}//GEN-LAST:event_addButtonActionPerformed
 
-  private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addBtnActionPerformed
-
-    if (newHostnameTextField.getText().length() != 0) {
-      repoPrefs.addHostname(newHostnameTextField.getText());
-    }
-  }//GEN-LAST:event_addBtnActionPerformed
+private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
+  DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
+  int selected = databasesTable.getSelectedRow();
+  if (selected > -1)
+    model.removeRow(selected);
+}//GEN-LAST:event_removeButtonActionPerformed
 
   public void update(Observable o, Object arg) {
     if (arg != null) {
-
       if (arg instanceof Integer) {
         int identifier = ((Integer) arg).intValue();
-
-        if (identifier == RepositoryPrefGroup.REPOSITORY_EXPIRY_CHANGED) {
-          updateExpiry();
-        }
-        else if (identifier == RepositoryPrefGroup.REPOSITORY_HOSTNAMES_CHANGED) {
-          updateHostnames();
-        }
-        else {
-          System.err.println("Unknown observation argument: " + arg.toString());
+        switch (identifier) {
+          case RepositoryPrefGroup.REPOSITORY_EXPIRY_CHANGED:
+            updateExpiry();
+            break;
+          case RepositoryPrefGroup.REPOSITORY_MAX_CONNECTIONS_NUMBER_CHANGED:
+            updateMaxConnectionsNumber();
+            break;
+          case RepositoryPrefGroup.REPOSITORY_CACHE_PASSWORD_CHANGED:
+            updateCachePasswords();
+            break;
         }
       }
     }
   }
 
+  private void updateMaxConnectionsNumber() {
+    maxConnectionsNumberSpinner.setValue(repoPrefs.getMaxConnectionsNumber());
+  }
+  
+  private void updateCachePasswords() {
+    cachePasswordComboBox.setSelectedIndex(repoPrefs.getCachePassword().intValue());
+  }
+  
   private void updateExpiry() {
     expirySpinner.setValue(repoPrefs.getExpiry());
   }
 
-  private void updateHostnames() {
-    DefaultListModel mmdl = (DefaultListModel) hostnameList.getModel();
-    mmdl.removeAllElements();
-    Iterator it = repoPrefs.getHostnames().iterator();
-    while (it.hasNext()) {
-      String path = (String) it.next();
-      mmdl.addElement(path);
+  private void updateRepositories() {
+    DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
+    ArrayList<String[]> repos = repoPrefs.getRepositories();
+    for (String[] repo : repos) {
+      model.insertRow(model.getRowCount(), repo);
     }
   }
-
+  
   public void stateChanged(ChangeEvent e) {
     if (e.getSource() == expirySpinner) {
       repoPrefs.setExpiry((Integer) expirySpinner.getValue());
+      return;
+    }
+    if (e.getSource() == maxConnectionsNumberSpinner) {
+      repoPrefs.setMaxConnectionsNumber((Integer) maxConnectionsNumberSpinner.getValue());
+      return;
     }
   }
 
   public void actionPerformed(ActionEvent e) {
+    if (e.getSource() == cachePasswordComboBox) {
+      repoPrefs.setCachePassword((Integer) cachePasswordComboBox.getSelectedIndex());
+      return;  
+    }
   }
+  
+  public void tableChanged(TableModelEvent e) {
+    
+    
+    if (e.getSource() == databasesTable.getModel()) {
+      DefaultTableModel model = (DefaultTableModel) databasesTable.getModel();
+      int rows = model.getRowCount();
+      ArrayList<String[]> value = new ArrayList<String[]>(rows);
+      for (int i = 0; i < rows; i++)
+        value.add(new String[]{(String) model.getValueAt(i, 0), 
+                               (String) model.getValueAt(i, 1),
+                               (String) model.getValueAt(i, 2)});
+      repoPrefs.setRepositories(value);
+      return;
+    }
+  }
+  
   // Variables declaration - do not modify//GEN-BEGIN:variables
-  private javax.swing.JButton addBtn;
+  private javax.swing.JButton addButton;
+  private javax.swing.JComboBox cachePasswordComboBox;
+  private javax.swing.JTable databasesTable;
   private javax.swing.JSpinner expirySpinner;
-  private javax.swing.JList hostnameList;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JLabel jLabel3;
-  private javax.swing.JScrollPane jScrollPane1;
-  private javax.swing.JTextField newHostnameTextField;
-  private javax.swing.JButton removeBtn;
+  private javax.swing.JLabel jLabel4;
+  private javax.swing.JLabel jLabel5;
+  private javax.swing.JSpinner maxConnectionsNumberSpinner;
+  private javax.swing.JButton removeButton;
+  private javax.swing.JScrollPane scrollPane;
   // End of variables declaration//GEN-END:variables
 }
--- a/src/MPipeline2/src/mpipeline/main/MainWindow.form	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/main/MainWindow.form	Tue Dec 06 19:07:22 2011 +0100
@@ -481,23 +481,6 @@
             </Property>
             <Property name="verticalTextPosition" type="int" value="3"/>
           </Properties>
-          <Events>
-            <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="repoSearchTBBActionPerformed"/>
-          </Events>
-        </Component>
-        <Component class="javax.swing.JButton" name="repoConnectTBB">
-          <Properties>
-            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-              <Image iconType="3" name="/mpipeline/icons/link.png"/>
-            </Property>
-            <Property name="toolTipText" type="java.lang.String" value="Open LTPDA RepositoryManager"/>
-            <Property name="focusable" type="boolean" value="false"/>
-            <Property name="horizontalTextPosition" type="int" value="0"/>
-            <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-              <Image iconType="3" name="/mpipeline/icons/link_ro.png"/>
-            </Property>
-            <Property name="verticalTextPosition" type="int" value="3"/>
-          </Properties>
         </Component>
       </SubComponents>
     </Container>
@@ -506,9 +489,9 @@
       <Layout>
         <DimensionLayout dim="0">
           <Group type="103" groupAlignment="0" attributes="0">
-              <Component id="jSplitPane1" alignment="0" pref="1076" max="32767" attributes="0"/>
+              <Component id="jSplitPane1" alignment="0" pref="1084" max="32767" attributes="0"/>
               <Group type="102" alignment="1" attributes="0">
-                  <EmptySpace pref="883" max="32767" attributes="0"/>
+                  <EmptySpace pref="895" max="32767" attributes="0"/>
                   <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
                   <Component id="instanceIdLabel" min="-2" pref="93" max="-2" attributes="0"/>
@@ -585,13 +568,13 @@
                   <Layout>
                     <DimensionLayout dim="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="jScrollPane6" alignment="0" pref="237" max="32767" attributes="0"/>
+                          <Component id="jScrollPane6" alignment="0" pref="197" max="32767" attributes="0"/>
                           <Group type="102" alignment="1" attributes="0">
                               <EmptySpace max="-2" attributes="0"/>
                               <Group type="103" groupAlignment="0" attributes="0">
                                   <Group type="102" alignment="0" attributes="0">
                                       <Component id="mvPipelineUpBtn" linkSize="10" min="-2" pref="36" max="-2" attributes="0"/>
-                                      <EmptySpace pref="149" max="32767" attributes="0"/>
+                                      <EmptySpace pref="101" max="32767" attributes="0"/>
                                       <Component id="deletePipelineBtn" linkSize="10" min="-2" pref="36" max="-2" attributes="0"/>
                                   </Group>
                                   <Component id="mvPipelineDownBtn" linkSize="10" alignment="0" min="-2" pref="36" max="-2" attributes="0"/>
@@ -603,7 +586,7 @@
                     <DimensionLayout dim="1">
                       <Group type="103" groupAlignment="0" attributes="0">
                           <Group type="102" alignment="0" attributes="0">
-                              <Component id="jScrollPane6" pref="335" max="32767" attributes="0"/>
+                              <Component id="jScrollPane6" pref="339" max="32767" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
                               <Group type="103" groupAlignment="0" attributes="0">
                                   <Group type="102" attributes="0">
@@ -708,9 +691,9 @@
                   <Layout>
                     <DimensionLayout dim="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="jScrollPane1" alignment="0" pref="237" max="32767" attributes="0"/>
+                          <Component id="jScrollPane1" alignment="0" pref="197" max="32767" attributes="0"/>
                           <Group type="102" alignment="1" attributes="0">
-                              <EmptySpace pref="79" max="32767" attributes="1"/>
+                              <EmptySpace pref="53" max="32767" attributes="1"/>
                               <Component id="jLabel1" min="-2" pref="66" max="-2" attributes="0"/>
                               <EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
                               <Group type="103" groupAlignment="0" max="-2" attributes="0">
@@ -728,7 +711,7 @@
                     <DimensionLayout dim="1">
                       <Group type="103" groupAlignment="0" attributes="0">
                           <Group type="102" alignment="0" attributes="0">
-                              <Component id="jScrollPane1" pref="328" max="32767" attributes="0"/>
+                              <Component id="jScrollPane1" pref="341" max="32767" attributes="0"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
                               <Group type="103" groupAlignment="2" attributes="0">
                                   <Component id="jLabel1" alignment="2" min="-2" max="-2" attributes="0"/>
@@ -833,14 +816,14 @@
                   <Layout>
                     <DimensionLayout dim="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="jScrollPane2" alignment="0" pref="237" max="32767" attributes="0"/>
+                          <Component id="jScrollPane2" alignment="0" pref="197" max="32767" attributes="0"/>
                       </Group>
                     </DimensionLayout>
                     <DimensionLayout dim="1">
                       <Group type="103" groupAlignment="0" attributes="0">
                           <Group type="102" alignment="0" attributes="0">
                               <Component id="jScrollPane2" min="-2" pref="496" max="-2" attributes="0"/>
-                              <EmptySpace pref="34" max="32767" attributes="0"/>
+                              <EmptySpace pref="43" max="32767" attributes="0"/>
                           </Group>
                       </Group>
                     </DimensionLayout>
@@ -893,13 +876,13 @@
                   <Layout>
                     <DimensionLayout dim="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="jSplitPane2" alignment="0" pref="237" max="32767" attributes="0"/>
+                          <Component id="jSplitPane2" alignment="0" pref="197" max="32767" attributes="0"/>
                       </Group>
                     </DimensionLayout>
                     <DimensionLayout dim="1">
                       <Group type="103" groupAlignment="0" attributes="0">
                           <Group type="102" alignment="0" attributes="0">
-                              <Component id="jSplitPane2" pref="510" max="32767" attributes="0"/>
+                              <Component id="jSplitPane2" pref="527" max="32767" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
                           </Group>
                       </Group>
@@ -930,13 +913,13 @@
                           <Layout>
                             <DimensionLayout dim="0">
                               <Group type="103" groupAlignment="0" attributes="0">
-                                  <Component id="jScrollPane3" alignment="0" pref="237" max="32767" attributes="0"/>
+                                  <Component id="jScrollPane3" alignment="0" pref="197" max="32767" attributes="0"/>
                               </Group>
                             </DimensionLayout>
                             <DimensionLayout dim="1">
                               <Group type="103" groupAlignment="0" attributes="0">
                                   <Group type="102" alignment="0" attributes="0">
-                                      <Component id="jScrollPane3" pref="100" max="32767" attributes="0"/>
+                                      <Component id="jScrollPane3" pref="108" max="32767" attributes="0"/>
                                       <EmptySpace min="-2" max="-2" attributes="0"/>
                                   </Group>
                               </Group>
@@ -1009,7 +992,7 @@
                                   <Group type="102" alignment="1" attributes="0">
                                       <EmptySpace max="-2" attributes="0"/>
                                       <Component id="ApplyBtn" min="-2" max="-2" attributes="0"/>
-                                      <EmptySpace pref="70" max="32767" attributes="0"/>
+                                      <EmptySpace pref="62" max="32767" attributes="0"/>
                                       <Component id="ParamRmvBtn" min="-2" pref="36" max="-2" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
                                       <Component id="ParamAddBtn" min="-2" pref="36" max="-2" attributes="0"/>
@@ -1017,10 +1000,10 @@
                                   </Group>
                                   <Group type="102" alignment="0" attributes="0">
                                       <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="setCombo" pref="203" max="32767" attributes="0"/>
+                                      <Component id="setCombo" pref="173" max="32767" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
                                   </Group>
-                                  <Component id="jScrollPane5" alignment="0" pref="237" max="32767" attributes="0"/>
+                                  <Component id="jScrollPane5" alignment="0" pref="197" max="32767" attributes="0"/>
                               </Group>
                             </DimensionLayout>
                             <DimensionLayout dim="1">
@@ -1029,7 +1012,7 @@
                                       <EmptySpace min="-2" max="-2" attributes="0"/>
                                       <Component id="setCombo" min="-2" max="-2" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
-                                      <Component id="jScrollPane5" pref="284" max="32767" attributes="0"/>
+                                      <Component id="jScrollPane5" pref="304" max="32767" attributes="0"/>
                                       <EmptySpace max="-2" attributes="0"/>
                                       <Group type="103" groupAlignment="1" attributes="0">
                                           <Component id="ParamAddBtn" linkSize="9" min="-2" pref="36" max="-2" attributes="0"/>
@@ -1164,13 +1147,13 @@
                     <DimensionLayout dim="0">
                       <Group type="103" groupAlignment="0" attributes="0">
                           <Group type="102" alignment="0" attributes="0">
-                              <Component id="jSeparator6" pref="217" max="32767" attributes="2"/>
+                              <Component id="jSeparator6" pref="185" max="32767" attributes="2"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
                           </Group>
-                          <Component id="jPanel3" alignment="0" pref="237" max="32767" attributes="0"/>
+                          <Component id="jPanel3" alignment="0" pref="197" max="32767" attributes="0"/>
                           <Component id="jPanel4" alignment="0" max="32767" attributes="0"/>
                           <Group type="102" alignment="0" attributes="0">
-                              <Component id="jSeparator7" pref="217" max="32767" attributes="2"/>
+                              <Component id="jSeparator7" pref="185" max="32767" attributes="2"/>
                               <EmptySpace min="-2" max="-2" attributes="0"/>
                           </Group>
                           <Component id="jPanel6" alignment="0" max="32767" attributes="0"/>
@@ -1188,7 +1171,7 @@
                               <Component id="jSeparator7" min="-2" max="-2" attributes="0"/>
                               <EmptySpace max="-2" attributes="0"/>
                               <Component id="jPanel6" min="-2" pref="160" max="-2" attributes="0"/>
-                              <EmptySpace pref="28" max="32767" attributes="0"/>
+                              <EmptySpace pref="37" max="32767" attributes="0"/>
                           </Group>
                       </Group>
                     </DimensionLayout>
@@ -1379,7 +1362,7 @@
                                           <Component id="reportBtn" linkSize="8" min="-2" pref="36" max="-2" attributes="0"/>
                                       </Group>
                                   </Group>
-                                  <EmptySpace pref="154" max="32767" attributes="0"/>
+                                  <EmptySpace pref="107" max="32767" attributes="0"/>
                               </Group>
                           </Group>
                         </DimensionLayout>
@@ -1539,7 +1522,7 @@
                                       </Group>
                                       <Component id="vebosityCombo" alignment="0" min="-2" max="-2" attributes="0"/>
                                   </Group>
-                                  <EmptySpace pref="89" max="32767" attributes="0"/>
+                                  <EmptySpace pref="81" max="32767" attributes="0"/>
                               </Group>
                           </Group>
                         </DimensionLayout>
--- a/src/MPipeline2/src/mpipeline/main/MainWindow.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/main/MainWindow.java	Tue Dec 06 19:07:22 2011 +0100
@@ -114,9 +114,6 @@
 import mpipeline.ltpdapreferences.DisplayPrefGroup;
 import mpipeline.ltpdapreferences.LTPDAPreferences;
 import mpipeline.parametersoverview.ParametersOverviewDialog;
-import mpipeline.repository.RepositoryConnection;
-import mpipeline.repository.RepositoryManager;
-import mpipeline.repository.RepositoryQueryDialog;
 import mpipeline.repository.SubmissionInfo;
 import mpipeline.pipelinelist.PipelineList;
 import mpipeline.pipelinelist.PipelineListTree;
@@ -205,7 +202,6 @@
   private JMenuItem RebuildLibraryMenuItem = new JMenuItem();
   private JMenuItem PlotSelectedMenuItem = new JMenuItem();
   private JMenuItem ltpdaPreferencesMenuItem = new JMenuItem();
-  private JMenuItem ltpdaRepoGuiMenuItem = new JMenuItem();
   private JMenuItem ltpdaPZmodelHelperMenuItem = new JMenuItem();
   private JMenuItem ltpdaSpecwinViewerMenuItem = new JMenuItem();
   private JMenuItem ltpdaConstructorHelperMenuItem = new JMenuItem();
@@ -255,7 +251,6 @@
   private ExecutionPlanView execPlanView = new ExecutionPlanView(this, saved);
   private Timer autosaveTimer = null;
   private boolean preferencesApplied = false;
-  private RepositoryManager repositoryManager = null;
   /** Parameters overview **/
   private ParametersOverviewDialog parametersOverviewDialog = null;
   private ConsoleDialog console = null;
@@ -2123,11 +2118,9 @@
     ltpdaPreferencesMenuItem.setText("LTPDA Preferences");
     MainMenuTools.add(ltpdaPreferencesMenuItem);
 
-    ltpdaRepoGuiMenuItem.setText("LTPDA Repository GUI");
-    MainMenuTools.add(ltpdaRepoGuiMenuItem);
 
     ltpdaPZmodelHelperMenuItem.setText("Pole/zero Model Helper");
-    MainMenuTools.add(ltpdaRepoGuiMenuItem);
+    MainMenuTools.add(ltpdaPZmodelHelperMenuItem);
 
     ltpdaSpecwinViewerMenuItem.setText("Spectral Window Viewer");
     MainMenuTools.add(ltpdaSpecwinViewerMenuItem);
@@ -2471,7 +2464,6 @@
     jSeparator5 = new javax.swing.JToolBar.Separator();
     repoSubmitTBB = new javax.swing.JButton();
     repoSearchTBB = new javax.swing.JButton();
-    repoConnectTBB = new javax.swing.JButton();
     jPanel5 = new javax.swing.JPanel();
     jSplitPane1 = new javax.swing.JSplitPane();
     DocumentPane = new javax.swing.JDesktopPane();
@@ -2775,21 +2767,8 @@
     repoSearchTBB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
     repoSearchTBB.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database_ro.png"))); // NOI18N
     repoSearchTBB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    repoSearchTBB.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        repoSearchTBBActionPerformed(evt);
-      }
-    });
     MainToolbar.add(repoSearchTBB);
 
-    repoConnectTBB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/link.png"))); // NOI18N
-    repoConnectTBB.setToolTipText("Open LTPDA RepositoryManager");
-    repoConnectTBB.setFocusable(false);
-    repoConnectTBB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    repoConnectTBB.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/link_ro.png"))); // NOI18N
-    repoConnectTBB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    MainToolbar.add(repoConnectTBB);
-
     jSplitPane1.setBorder(null);
     jSplitPane1.setDividerLocation(280);
     jSplitPane1.setMinimumSize(new java.awt.Dimension(10, 41));
@@ -2849,13 +2828,13 @@
     pipelineTab.setLayout(pipelineTabLayout);
     pipelineTabLayout.setHorizontalGroup(
       pipelineTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
       .add(org.jdesktop.layout.GroupLayout.TRAILING, pipelineTabLayout.createSequentialGroup()
         .addContainerGap()
         .add(pipelineTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
           .add(pipelineTabLayout.createSequentialGroup()
             .add(mvPipelineUpBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 98, Short.MAX_VALUE)
+            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 101, Short.MAX_VALUE)
             .add(deletePipelineBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
           .add(mvPipelineDownBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
         .addContainerGap())
@@ -2955,9 +2934,9 @@
     libraryTab.setLayout(libraryTabLayout);
     libraryTabLayout.setHorizontalGroup(
       libraryTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
       .add(org.jdesktop.layout.GroupLayout.TRAILING, libraryTabLayout.createSequentialGroup()
-        .addContainerGap(50, Short.MAX_VALUE)
+        .addContainerGap(53, Short.MAX_VALUE)
         .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 66, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
         .add(4, 4, 4)
         .add(libraryTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
@@ -2971,7 +2950,7 @@
     libraryTabLayout.setVerticalGroup(
       libraryTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
       .add(libraryTabLayout.createSequentialGroup()
-        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
+        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
         .add(libraryTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
           .add(jLabel1)
@@ -3007,7 +2986,7 @@
     shelfTab.setLayout(shelfTabLayout);
     shelfTabLayout.setHorizontalGroup(
       shelfTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
     );
     shelfTabLayout.setVerticalGroup(
       shelfTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -3058,7 +3037,7 @@
     jPanel1.setLayout(jPanel1Layout);
     jPanel1Layout.setHorizontalGroup(
       jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
     );
     jPanel1Layout.setVerticalGroup(
       jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -3127,16 +3106,16 @@
       .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel2Layout.createSequentialGroup()
         .addContainerGap()
         .add(ApplyBtn)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 59, Short.MAX_VALUE)
+        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 62, Short.MAX_VALUE)
         .add(ParamRmvBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
         .add(ParamAddBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
         .addContainerGap())
       .add(jPanel2Layout.createSequentialGroup()
         .addContainerGap()
-        .add(setCombo, 0, 170, Short.MAX_VALUE)
+        .add(setCombo, 0, 173, Short.MAX_VALUE)
         .addContainerGap())
-      .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
     );
     jPanel2Layout.setVerticalGroup(
       jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -3144,7 +3123,7 @@
         .addContainerGap()
         .add(setCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
+        .add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
         .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
           .add(ParamAddBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
@@ -3161,7 +3140,7 @@
     paramsTab.setLayout(paramsTabLayout);
     paramsTabLayout.setHorizontalGroup(
       paramsTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jSplitPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jSplitPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
     );
     paramsTabLayout.setVerticalGroup(
       paramsTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -3351,7 +3330,7 @@
             .add(tableBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
             .add(reportBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 36, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
-        .addContainerGap(104, Short.MAX_VALUE))
+        .addContainerGap(107, Short.MAX_VALUE))
     );
 
     jPanel4Layout.linkSize(new java.awt.Component[] {DisplayBtn, ExploreBtn, HistoryBtn, PlotBtn, exportWorkspaceBtn, reportBtn, saveObjectBtn, tableBtn}, org.jdesktop.layout.GroupLayout.HORIZONTAL);
@@ -3405,7 +3384,7 @@
             .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
             .add(jLabel2))
           .add(vebosityCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .addContainerGap(72, Short.MAX_VALUE))
+        .addContainerGap(81, Short.MAX_VALUE))
     );
     jPanel6Layout.setVerticalGroup(
       jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -3422,12 +3401,12 @@
     controlsTabLayout.setHorizontalGroup(
       controlsTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
       .add(controlsTabLayout.createSequentialGroup()
-        .add(jSeparator6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
+        .add(jSeparator6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
         .addContainerGap())
-      .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
+      .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
       .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
       .add(controlsTabLayout.createSequentialGroup()
-        .add(jSeparator7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
+        .add(jSeparator7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
         .addContainerGap())
       .add(jPanel6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
     );
@@ -3458,9 +3437,9 @@
     jPanel5.setLayout(jPanel5Layout);
     jPanel5Layout.setHorizontalGroup(
       jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1073, Short.MAX_VALUE)
+      .add(jSplitPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1084, Short.MAX_VALUE)
       .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
-        .addContainerGap(883, Short.MAX_VALUE)
+        .addContainerGap(895, Short.MAX_VALUE)
         .add(jLabel4)
         .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
         .add(instanceIdLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 93, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
@@ -3501,12 +3480,12 @@
       }
     });
     MainMenuWindow.addMenuListener(new javax.swing.event.MenuListener() {
-      public void menuCanceled(javax.swing.event.MenuEvent evt) {
+      public void menuSelected(javax.swing.event.MenuEvent evt) {
+        MainMenuWindowMenuSelected(evt);
       }
       public void menuDeselected(javax.swing.event.MenuEvent evt) {
       }
-      public void menuSelected(javax.swing.event.MenuEvent evt) {
-        MainMenuWindowMenuSelected(evt);
+      public void menuCanceled(javax.swing.event.MenuEvent evt) {
       }
     });
     MainMenuBar.add(MainMenuWindow);
@@ -3520,11 +3499,11 @@
     getContentPane().setLayout(layout);
     layout.setHorizontalGroup(
       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(MainToolbar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1085, Short.MAX_VALUE)
+      .add(MainToolbar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1096, Short.MAX_VALUE)
       .add(layout.createSequentialGroup()
         .add(jPanel5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
         .addContainerGap())
-      .add(statusLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1085, Short.MAX_VALUE)
+      .add(statusLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 1096, Short.MAX_VALUE)
     );
     layout.setVerticalGroup(
       layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
@@ -5295,19 +5274,6 @@
   this.showPipelineListPopupMenu(evt);
 }//GEN-LAST:event_pipelineListTreeMouseReleased
 
-private void repoSearchTBBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_repoSearchTBBActionPerformed
-
-  if (repositoryManager != null) {
-
-    RepositoryConnection conn = repositoryManager.selectConnection(this);
-
-    if (conn != null && conn.isConnected()) {
-      RepositoryQueryDialog rqd = new RepositoryQueryDialog(this, false, conn, true);
-      rqd.setVisible(true);
-    }
-  }
-}//GEN-LAST:event_repoSearchTBBActionPerformed
-
 private void librarySearchPreviousActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_librarySearchPreviousActionPerformed
 
   String searchText = BlockSearchTxt.getText();
@@ -7170,14 +7136,6 @@
    *
    * @return
    */
-  public JMenuItem getLtpdaRepoGuiMenuItem() {
-    return ltpdaRepoGuiMenuItem;
-  }
-
-  /**
-   *
-   * @return
-   */
   public JMenuItem getLtpdaSignalBuilderMenuItem() {
     return ltpdaSignalBuilderMenuItem;
   }
@@ -7433,8 +7391,8 @@
     return repoSubmitTBB;
   }
 
-  public JButton getRepoConnectTBB() {
-    return repoConnectTBB;
+  public JButton getRepoSearchTBB() {
+    return repoSearchTBB;
   }
 
   public JButton getTableBtn() {
@@ -7449,18 +7407,10 @@
     return prefsDialog;
   }
 
-  public RepositoryManager getRepositoryManager() {
-    return repositoryManager;
-  }
-
   public LTPDAPreferences getLtpdaPreferences2() {
     return ltpdaPreferences2;
   }
 
-  public void setRepositoryManager(RepositoryManager repositoryManager) {
-    this.repositoryManager = repositoryManager;
-  }
-
   /**
    *
    * @param setCombo
@@ -7608,7 +7558,6 @@
   private javax.swing.JPanel pipelineTab;
   private final javax.swing.JTable plistTable = new PlistTable(this);
   private javax.swing.JButton redoTBB;
-  private javax.swing.JButton repoConnectTBB;
   private javax.swing.JButton repoSearchTBB;
   private javax.swing.JButton repoSubmitTBB;
   private javax.swing.JButton reportBtn;
--- a/src/MPipeline2/src/mpipeline/plisttable/JParamValueSpecialEditor.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/plisttable/JParamValueSpecialEditor.java	Tue Dec 06 19:07:22 2011 +0100
@@ -366,26 +366,6 @@
       }
 
     }
-    else if (key.toLowerCase().equals("hostname")) {
-
-      ArrayList<String> ports = blk.getInputPortNumbersAsStrings();
-      ArrayList<String> choices = getChoices(mw.getRepositoryManager().getRepoHosts().toArray(), ports);
-      String s = (String) JOptionPane.showInputDialog(
-              null,
-              "Hostname",
-              "Select hostname",
-              JOptionPane.PLAIN_MESSAGE,
-              null,
-              choices.toArray(),
-              currentValue.toString());
-
-      //If a string was returned, say so.
-      if ((s != null) && (s.length() > 0)) {
-        response = s;
-      }
-
-
-    }
     else if (key.toLowerCase().equals("built-in")) {
 
       ArrayList<LTPDAModel> models = null;
--- a/src/MPipeline2/src/mpipeline/plisttable/JPlist.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/plisttable/JPlist.java	Tue Dec 06 19:07:22 2011 +0100
@@ -564,22 +564,6 @@
         String defaultWin = ltpdaPreferences2.getMiscPrefs().getDefaultWindow();
         p.setDefaultVal(defaultWin);
       }
-      else if (p.getKey().equalsIgnoreCase("HOSTNAME")) {
-
-        Object currentHostname = p.getDefaultVal();
-        p.getVal().clearOptions();
-        // Get hostnames from the preferences
-        ArrayList<String> prefsHosts = ltpdaPreferences2.getRepoPrefs().getHostnames();
-        // Add this hostnames to the options of the param object
-        for (int i = 0; i < prefsHosts.size(); i++) {
-          p.addOption(prefsHosts.get(i), "char");
-        }
-        p.setDefaultVal(currentHostname);
-
-        if (p.getOptions().isEmpty()) {
-          p.addOption("", "char");
-        }
-      }
     }
   }
 }
--- a/src/MPipeline2/src/mpipeline/repository/ConnectionSelector.form	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="2"/>
-    <Property name="title" type="java.lang.String" value="Select a connection"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-  </SyntheticProperties>
-  <AuxValues>
-    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
-    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-  </AuxValues>
-
-  <Layout>
-    <DimensionLayout dim="0">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" attributes="0">
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Component id="cancelBtn" pref="99" max="32767" attributes="0"/>
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Component id="newConnectionBtn" pref="160" max="32767" attributes="0"/>
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Component id="selectBtn" pref="97" max="32767" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
-          </Group>
-          <Group type="102" alignment="2" attributes="0">
-              <EmptySpace min="12" pref="12" max="12" attributes="0"/>
-              <Component id="jScrollPane1" pref="368" max="32767" attributes="0"/>
-              <EmptySpace min="12" pref="12" max="12" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-    <DimensionLayout dim="1">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="0" attributes="0">
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Component id="jScrollPane1" pref="412" max="32767" attributes="0"/>
-              <EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="2" attributes="0">
-                  <Component id="selectBtn" alignment="2" min="-2" max="-2" attributes="0"/>
-                  <Component id="newConnectionBtn" alignment="2" min="-2" max="-2" attributes="0"/>
-                  <Component id="cancelBtn" alignment="2" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace max="-2" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-  </Layout>
-  <SubComponents>
-    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
-      <AuxValues>
-        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-      </AuxValues>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
-      <SubComponents>
-        <Component class="mpipeline.repository.RepositoryConnectionsTable" name="repositoryConnectionsTable">
-          <Properties>
-            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
-              <Table columnCount="4" rowCount="4">
-                <Column editable="true" title="Title 1" type="java.lang.Object"/>
-                <Column editable="true" title="Title 2" type="java.lang.Object"/>
-                <Column editable="true" title="Title 3" type="java.lang.Object"/>
-                <Column editable="true" title="Title 4" type="java.lang.Object"/>
-              </Table>
-            </Property>
-          </Properties>
-        </Component>
-      </SubComponents>
-    </Container>
-    <Component class="javax.swing.JButton" name="cancelBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Cancel"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="newConnectionBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="New Connection"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newConnectionBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="selectBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Select"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="selectBtnActionPerformed"/>
-      </Events>
-    </Component>
-  </SubComponents>
-</Form>
--- a/src/MPipeline2/src/mpipeline/repository/ConnectionSelector.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/*
- * ConnectionSelector.java
- *
- * Created on Jan 8, 2010, 3:29:50 PM
- */
-package mpipeline.repository;
-
-import java.awt.Point;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import javax.swing.JButton;
-import mpipeline.main.MainWindow;
-
-/**
- *
- * @author hewitson
- */
-public class ConnectionSelector extends javax.swing.JDialog {
-
-  private RepositoryManager manager = null;
-  private MainWindow mw = null;
-  private RepositoryConnectionTableModel tableModel = null;
-  private boolean cancelled = true;
-  private int selectedIndex = -1;
-
-  /** Creates new form ConnectionSelector */
-  public ConnectionSelector(MainWindow parent, RepositoryManager manager) {
-    super(parent, true);
-    initComponents();
-
-    this.manager = manager;
-    this.mw = parent;
-    tableModel = new RepositoryConnectionTableModel(manager.getConnections());
-    repositoryConnectionsTable.setModel(tableModel);
-    repositoryConnectionsTable.addMouseListener(new MouseListenerDoubleClick());
-  }
-
-  private class MouseListenerDoubleClick extends MouseAdapter {
-
-    @Override
-    public void mouseClicked(MouseEvent e) {
-      if (e.getClickCount() >= 2) {
-        Point p = e.getPoint();
-        selectedIndex = repositoryConnectionsTable.rowAtPoint(p);
-        cancelled = false;
-        dispose();
-      }
-    }
-  }
-
-  public void reloadConnectionTable() {
-    tableModel.fireTableDataChanged();
-  }
-
-  public void selectLast() {
-    repositoryConnectionsTable.getSelectionModel().setSelectionInterval(tableModel.getRowCount()-1, tableModel.getRowCount()-1);
-  }
-
-  /** This method is called from within the constructor to
-   * initialize the form.
-   * WARNING: Do NOT modify this code. The content of this method is
-   * always regenerated by the Form Editor.
-   */
-  @SuppressWarnings("unchecked")
-  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-  private void initComponents() {
-
-    jScrollPane1 = new javax.swing.JScrollPane();
-    repositoryConnectionsTable = new mpipeline.repository.RepositoryConnectionsTable();
-    cancelBtn = new javax.swing.JButton();
-    newConnectionBtn = new javax.swing.JButton();
-    selectBtn = new javax.swing.JButton();
-
-    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-    setTitle("Select a connection");
-
-    repositoryConnectionsTable.setModel(new javax.swing.table.DefaultTableModel(
-      new Object [][] {
-        {null, null, null, null},
-        {null, null, null, null},
-        {null, null, null, null},
-        {null, null, null, null}
-      },
-      new String [] {
-        "Title 1", "Title 2", "Title 3", "Title 4"
-      }
-    ));
-    jScrollPane1.setViewportView(repositoryConnectionsTable);
-
-    cancelBtn.setText("Cancel");
-    cancelBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        cancelBtnActionPerformed(evt);
-      }
-    });
-
-    newConnectionBtn.setText("New Connection");
-    newConnectionBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        newConnectionBtnActionPerformed(evt);
-      }
-    });
-
-    selectBtn.setText("Select");
-    selectBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        selectBtnActionPerformed(evt);
-      }
-    });
-
-    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
-    getContentPane().setLayout(layout);
-    layout.setHorizontalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(cancelBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(newConnectionBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(selectBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
-        .addContainerGap())
-      .add(org.jdesktop.layout.GroupLayout.CENTER, layout.createSequentialGroup()
-        .add(12, 12, 12)
-        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 368, Short.MAX_VALUE)
-        .add(12, 12, 12))
-    );
-    layout.setVerticalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 412, Short.MAX_VALUE)
-        .add(12, 12, 12)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
-          .add(selectBtn)
-          .add(newConnectionBtn)
-          .add(cancelBtn))
-        .addContainerGap())
-    );
-
-    pack();
-  }// </editor-fold>//GEN-END:initComponents
-
-  private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
-
-    cancelled = true;
-    this.dispose();
-  }//GEN-LAST:event_cancelBtnActionPerformed
-
-  private void selectBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectBtnActionPerformed
-
-    cancelled = false;
-    selectedIndex = repositoryConnectionsTable.getSelectedRow();
-    this.dispose();
-  }//GEN-LAST:event_selectBtnActionPerformed
-
-  private void newConnectionBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newConnectionBtnActionPerformed
-
-    RepositoryConnectionDialog rcd = new RepositoryConnectionDialog(mw, true, manager.getRepoHosts(), null);
-    rcd.setVisible(true);
-
-    if (!rcd.isCancelled()) {
-      RepositoryConnection conn = rcd.getRepositoryConnection();
-      manager.addConnection(conn);
-      reloadConnectionTable();
-      int rowCount = repositoryConnectionsTable.getRowCount();
-      repositoryConnectionsTable.getSelectionModel().setSelectionInterval(rowCount-1, rowCount-1);
-    }
-  }//GEN-LAST:event_newConnectionBtnActionPerformed
-
-  public boolean isCancelled() {
-    return cancelled;
-  }
-
-  public JButton getNewConnectionBtn() {
-    return newConnectionBtn;
-  }
-
-  public int getSelectedIndex() {
-    return selectedIndex;
-  }
-
-  public RepositoryConnection getSelectedConnection() {
-    if (!cancelled) {
-      if (selectedIndex >= 0 ) {
-        return(manager.getConnections().get(selectedIndex));
-      }
-    }
-    return(null);
-  }
-
-  public JButton getSelectBtn() {
-    return selectBtn;
-  }
-  // Variables declaration - do not modify//GEN-BEGIN:variables
-  private javax.swing.JButton cancelBtn;
-  private javax.swing.JScrollPane jScrollPane1;
-  private javax.swing.JButton newConnectionBtn;
-  private mpipeline.repository.RepositoryConnectionsTable repositoryConnectionsTable;
-  private javax.swing.JButton selectBtn;
-  // End of variables declaration//GEN-END:variables
-}
--- a/src/MPipeline2/src/mpipeline/repository/MySQLUtils.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-/*
- * Class MySQLUtils <one line to give the program's name and a brief idea of what it does.>
- *
- * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-package mpipeline.repository;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- *
- * @author Martin Hewitson <martin.hewitson at aei.mpg.de>
- */
-public class MySQLUtils {
-
-
-  public static int[] getObjectIDsFromCollectionID(RepositoryConnection conn, int cid) {
-
-    if (!conn.isConnected()) {
-      conn.openConnection();
-    }
-
-    if (!conn.isConnected()) {
-      return null;
-    }
-
-    Statement stmt = conn.createStatement();
-    ResultSet rs;
-    try {
-      rs = stmt.executeQuery("select obj_ids from collections where id='" + cid + "';");
-      while (rs.next()) {
-        String obj_ids = rs.getString(1);
-        String[] sints = obj_ids.split(",");
-        int[] ids = new int[sints.length];
-        for (int kk = 0; kk < sints.length; kk++) {
-          Integer id = Integer.parseInt(sints[kk]);
-          ids[kk] = id.intValue();
-        }
-        return ids;
-      }
-    } catch (SQLException ex) {
-      Logger.getLogger(RepositoryQueryDialog.class.getName()).log(Level.SEVERE, null, ex);
-    }
-
-    return null;
-  }
-
-  public static String getObjectTypeForID(RepositoryConnection conn, int id) {
-
-    String obj_type = null;
-    if (!conn.isConnected()) {
-      conn.openConnection();
-    }
-
-    if (!conn.isConnected()) {
-      return null;
-    }
-
-    Statement stmt = conn.createStatement();
-    ResultSet rs;
-    try {
-      rs = stmt.executeQuery("select obj_type from objmeta where obj_id='" + id + "';");
-      while (rs.next()) {
-        obj_type = rs.getString(1);
-      }
-    } catch (SQLException ex) {
-      Logger.getLogger(RepositoryQueryDialog.class.getName()).log(Level.SEVERE, null, ex);
-    }
-    
-    return obj_type;
-  }
-
-}
--- a/src/MPipeline2/src/mpipeline/repository/QueryResultsTableDialog.form	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/repository/QueryResultsTableDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.1" encoding="UTF-8" ?>
 
 <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
   <Properties>
@@ -64,7 +64,7 @@
               <Group type="102" alignment="1" attributes="0">
                   <EmptySpace max="-2" attributes="0"/>
                   <Component id="createConstructors" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace pref="409" max="32767" attributes="0"/>
+                  <EmptySpace pref="451" max="32767" attributes="0"/>
                   <Component id="doneBtn" min="-2" max="-2" attributes="0"/>
               </Group>
           </Group>
--- a/src/MPipeline2/src/mpipeline/repository/QueryResultsTableDialog.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/repository/QueryResultsTableDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -29,6 +29,8 @@
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 import javax.swing.JButton;
 import javax.swing.JOptionPane;
 import javax.swing.table.DefaultTableModel;
@@ -49,7 +51,7 @@
   private ResultSet results = null;
   private ArrayList<String> colNames = new ArrayList<String>();
   private MainWindow mw = null;
-  private RepositoryConnection usedConn = null;
+  private java.sql.Connection conn = null;
 
   /** Creates new form QueryResultsTable
    * @param parent
@@ -118,10 +120,6 @@
     return cancelled;
   }
 
-  public RepositoryConnection getUsedConn() {
-    return usedConn;
-  }
-
   public JButton getCreateConstructors() {
     return createConstructors;
   }
@@ -133,11 +131,11 @@
   public ArrayList<String> getColNames() {
     return colNames;
   }
+
+  public void setUsedConn(java.sql.Connection conn) {
+    this.conn = conn;
+  }
   
-  public void setUsedConn(RepositoryConnection usedConn) {
-    this.usedConn = usedConn;
-  }
-
   /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
@@ -269,15 +267,18 @@
           }
           int obj_id = Integer.parseInt(o.toString());
 
-          // get connection
-          if (usedConn == null) {
-            usedConn = mw.getRepositoryManager().selectConnection(mw);
+          // get object type
+          String obj_type = null;
+          try {
+            java.sql.PreparedStatement stmt = conn.prepareStatement(
+                    "SELECT obj_type FROM objmeta WHERE obj_id=?");
+            stmt.setInt(1, obj_id);
+            ResultSet rs = stmt.executeQuery();
+            rs.next();
+            obj_type = (String) rs.getObject(1);
           }
-
-          usedConn.openConnection();
-          // get object type
-          String obj_type = MySQLUtils.getObjectTypeForID(usedConn, obj_id);
-
+          catch (SQLException ex) { }
+          
           if (obj_type == null) {
             JOptionPane.showMessageDialog(this,
                     "Unable to determine object type for object with id: " + obj_id,
@@ -288,7 +289,7 @@
 
           // build constructor block
           ArrayList<LTPDAalgorithm> algos = mw.getLibrary().findMatches(obj_type);
-          if (algos.size() == 0) {
+          if (algos.isEmpty()) {
             JOptionPane.showMessageDialog(this,
                     "No constructor block found for object type: " + obj_type,
                     "Search error",
@@ -304,11 +305,18 @@
           MBlock b = new MBlock(algos.get(0));
           b.removeAllInputs();
 
-
+          // extract hostname and database from connection object
+          String url = conn.getMetaData().getURL();
+          Pattern r = Pattern.compile("^jdbc:mysql://(.*)/(.*)$");
+          Matcher m = r.matcher(url);
+          m.find();
+          String hostname = m.group(1);
+          String database = m.group(2);
+          
           // make a plist for this block
           JPlist pl = new JPlist();
-          pl.add("HOSTNAME", usedConn.getHostname(), "char");
-          pl.add("DATABASE", usedConn.getDatabase(), "char");
+          pl.add("HOSTNAME", hostname, "char");
+          pl.add("DATABASE", database, "char");
           pl.add("ID", "" + obj_id, "char");
           pl.add("BINARY", true, "logical");
 
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnection.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,423 +0,0 @@
-/*
- * Class RepositoryConnection <one line to give the program's name and a brief idea of what it does.>
- *
- * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package mpipeline.repository;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.JOptionPane;
-import mpipeline.main.MainWindow;
-
-/**
- *
- * @author Martin Hewitson <martin.hewitson at aei.mpg.de>
- */
-public class RepositoryConnection {
-
-  private String hostname = "";
-  private String database = "";
-  private String username = "";
-  private String password = "";
-  private MainWindow mw = null;
-  private Connection conn = null;
-  private long connectedAt = -1;
-  private long passwordSetAt = -1;
-  private boolean locked = false;
-
-  public RepositoryConnection(MainWindow mw) {
-    this.mw = mw;
-    try {
-      Class.forName("com.mysql.jdbc.Driver");
-    }
-    catch (ClassNotFoundException ex) {
-      Logger.getLogger(SubmitInfoDialog.class.getName()).log(Level.SEVERE, null, ex);
-    }
-  }
-
-  public RepositoryConnection(MainWindow mw, String aHost, String aDB, String aUser) {
-    // Call first constructor
-    this(mw);
-    // Set all other information
-    this.hostname = aHost;
-    this.database = aDB;
-    this.username = aUser;
-  }
-
-  public RepositoryConnection(MainWindow mw, String aHost, String aDB, String aUser, String aPassword) {
-    // Call constructor
-    this(mw, aHost, aDB, aUser);
-    // Set all other information
-    setPassword(aPassword);
-  }
-
-  public String getDatabase() {
-    return database;
-  }
-
-  public void setDatabase(String database) {
-    if (database != null) {
-      this.database = database;
-    }
-  }
-
-  public String getHostname() {
-    return hostname;
-  }
-
-  public void setHostname(String hostname) {
-    if (hostname != null) {
-      this.hostname = hostname;
-    }
-  }
-
-  public String getPassword() {
-    return password;
-  }
-
-  public void setPassword(String password) {
-    if (password != null) {
-      this.password = password;
-
-      if (password.length() == 0)
-        this.passwordSetAt = -1;
-      else
-        this.passwordSetAt = System.currentTimeMillis();
-    }
-  }
-
-  public String getUsername() {
-    return username;
-  }
-
-  public void setUsername(String username) {
-    if (username != null) {
-      this.username = username;
-    }
-  }
-
-  public long getConnectedAt() {
-    return connectedAt;
-  }
-
-  public void setConnectedAt(long connectedAt) {
-    this.connectedAt = connectedAt;
-  }
-
-  public long getPasswordSetAt() {
-    return passwordSetAt;
-  }
-
-  public void setPasswordSetAt(long passwordSetAt) {
-    this.passwordSetAt = passwordSetAt;
-  }
-
-  public Connection getConn() {
-    return conn;
-  }
-
-  public boolean isLocked() {
-    return locked;
-  }
-
-  public void setLocked(boolean locked) {
-    this.locked = locked;
-
-    // Reset the timers because if the user lock the connection
-    // then I assume that he will use it.
-    if (locked) {
-      touch();
-    }
-  }
-
-  public String getDescription() {
-    return hostname + "/" + database + " as " + username;
-  }
-
-  public String getURL() {
-    return "jdbc:mysql://" + hostname + "/" + database;
-  }
-
-  public static Object[][] resultSetToObjectArray(ResultSet rs) {
-    Object[][] objects = null;
-    try {
-      ResultSetMetaData rsmd = rs.getMetaData();
-      int Ncol = rsmd.getColumnCount();
-      rs.last();
-      int Nrow = rs.getRow();
-      rs.beforeFirst();
-
-      objects = new Object[Nrow][Ncol];
-      int kk = 0;
-      while (rs.next()) {
-        for (int ll = 0; ll < Ncol; ll++) {
-          Object o = rs.getObject(ll + 1);
-          if (o == null) {
-            objects[kk][ll] = "";
-          }
-          else {
-            objects[kk][ll] = rs.getObject(ll + 1);
-          }
-        }
-        kk++;
-      }
-    }
-    catch (SQLException ex) {
-      Logger.getLogger(RepositoryConnection.class.getName()).log(Level.SEVERE, null, ex);
-    }
-
-    return objects;
-  }
-
-  public Connection openConnection() {
-
-    // check we have a hostname
-    if (this.getHostname().equals("")) {
-
-      JOptionPane.showMessageDialog(mw,
-              "Please set a repository hostname.",
-              "Connection error",
-              JOptionPane.ERROR_MESSAGE);
-      return null;
-    }
-
-    // check we have a database
-    if (this.getDatabase().equals("")) {
-
-      JOptionPane.showMessageDialog(mw,
-              "Please set a repository database.",
-              "Connection error",
-              JOptionPane.ERROR_MESSAGE);
-      return null;
-    }
-
-    // check we have a username
-    if (this.getUsername().equals("")) {
-
-      JOptionPane.showMessageDialog(mw,
-              "Please set a username to log in to the repository",
-              "Connection error",
-              JOptionPane.ERROR_MESSAGE);
-      return null;
-    }
-
-    // ask for password if no exist
-    if (this.getPassword().equals("")) {
-      ArrayList<String> hosts = new ArrayList<String>();
-      hosts.add(getHostname());
-
-      RepositoryConnectionPasswordDialog rpwdd = new RepositoryConnectionPasswordDialog(null, true, this);
-      rpwdd.setVisible(true);
-
-      if (rpwdd.isCancelled()) {
-        return null;
-      }
-      else {
-        conn = rpwdd.getConn().getConn();
-      }
-    }
-
-    try {
-      if (!isConnected()) {
-        conn = DriverManager.getConnection(getURL(), username, password);
-        connectedAt = System.currentTimeMillis();
-      }
-
-    }
-    catch (SQLException ex) {
-      System.err.println("error: " + ex);
-//      JOptionPane.showMessageDialog(mw,
-//              "Failed to connect to the repository.",
-//              "Connection error",
-//              JOptionPane.ERROR_MESSAGE);
-      this.setPassword("");
-      return null;
-    }
-    return conn;
-  }
-
-  public boolean isConnected() {
-    if (conn == null) {
-      return false;
-    }
-    try {
-      return !conn.isClosed();
-    }
-    catch (SQLException ex) {
-      return false;
-    }
-  }
-
-  public void touch() {
-    this.connectedAt = System.currentTimeMillis();
-    this.passwordSetAt = System.currentTimeMillis();
-  }
-
-  public void closeConnection() {
-    if ((conn != null) && (!isLocked())) {
-      try {
-        conn.close();
-        conn = null;
-        connectedAt = -1;
-      }
-      catch (SQLException ex) {
-        JOptionPane.showMessageDialog(mw,
-                "Failed to close connection to the repository.",
-                "Connection close error",
-                JOptionPane.ERROR_MESSAGE);
-      }
-    }
-    if (isLocked()) {
-      System.err.println("Cannot disconnect; the connection is locked.");
-    }
-  }
-
-  public ArrayList<String> getTableList() {
-    openConnection();
-    ArrayList<String> tables = new ArrayList<String>();
-    try {
-      ResultSet rs = this.query("show tables;");
-      while (rs.next()) {
-        String str = rs.getString(1);
-        tables.add(str);
-      }
-    }
-    catch (SQLException ex) {
-      Logger.getLogger(RepositoryConnection.class.getName()).log(Level.SEVERE, null, ex);
-    }
-    return tables;
-  }
-
-  public ResultSet query(String aQuery) {
-
-    try {
-      this.openConnection();
-
-      //Get a Statement object
-      Statement stmt = conn.createStatement();
-      // List databases
-      ResultSet rs = stmt.executeQuery(aQuery);
-      return rs;
-    }
-    catch (SQLException ex) {
-      Logger.getLogger(RepositoryConnection.class.getName()).log(Level.SEVERE, null, ex);
-    }
-
-    return null;
-  }
-
-  public Statement createStatement() {
-    try {
-      this.openConnection();
-      Statement s = conn.createStatement();
-      return s;
-    }
-    catch (SQLException ex) {
-      return null;
-    }
-  }
-
-  public ArrayList<String> getDatabaseList() {
-    ArrayList<String> dbs = new ArrayList<String>();
-
-    this.openConnection();
-    if (this.isConnected()) {
-      try {
-        // List databases
-        ResultSet rs = this.query("SHOW DATABASES");
-        while (rs.next()) {
-          String str = rs.getString(1);
-          System.out.println("database: " + str);
-          if (!str.equals("information_schema") && !str.equals("test") && !str.equals("mysql")) {
-            dbs.add(str);
-          }
-        }
-      }
-      catch (SQLException ex) {
-        JOptionPane.showMessageDialog(mw,
-                "Failed to retrieve a database list from the repository.",
-                "Query error",
-                JOptionPane.ERROR_MESSAGE);
-      }
-    }
-    else {
-      JOptionPane.showMessageDialog(mw,
-              "This repository connection is not connected. Please connect first.",
-              "Connection error",
-              JOptionPane.ERROR_MESSAGE);
-    }
-    return dbs;
-  }
-
-  public void display() {
-    System.out.println("--- Repository connection ----- ");
-    System.out.println(this.getDescription());
-    System.out.println(" connected: " + this.isConnected());
-    System.out.println("    active: " + this.ageConnected() + " seconds");
-    System.out.println("    locked: " + this.isLocked());
-    System.out.println("------------------------------- ");
-  }
-
-  @Override
-  public String toString() {
-    return getDescription();
-  }
-
-  /**
-   * Returns the age of the connection in seconds.
-   * @return
-   */
-  public double ageConnected() {
-    if (this.isConnected()) {
-      return (1.0 * System.currentTimeMillis() - this.connectedAt) / 1000.0;
-    }
-    else {
-      return -1.0;
-    }
-  }
-
-  /**
-   * Returns the age of the connection in seconds.
-   * @return
-   */
-  public double agePassword() {
-    if (passwordSetAt != -1) {
-      return (1.0 * System.currentTimeMillis() - this.passwordSetAt) / 1000.0;
-    }
-    else {
-      return -1.0;
-    }
-  }
-
-  @Override
-  protected void finalize() throws Throwable {
-    //do finalization here
-    if (conn != null) {
-      conn.close();
-      conn = null;
-    }
-    super.finalize(); //not necessary if extending Object.
-  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionCellRenderer.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package mpipeline.repository;
-
-import java.awt.Color;
-import java.awt.Component;
-import javax.swing.BorderFactory;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.UIManager;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableModel;
-
-/**
- *
- * @author hewitson
- */
-public class RepositoryConnectionCellRenderer extends DefaultTableCellRenderer {
-
-  public JTextField textarea = new JTextField();
-
-  /**
-   * Returns the component used for drawing the cell. This method is
-   * used to configure the renderer appropriately before drawing.
-   *
-   * @param	table       the <code>JTable</code> that is asking the
-   *                      renderer to draw.
-   * @param	value       the value of the cell to be rendered.
-   * @param	isSelected	true if the cell is to be rendered with the
-   *                      selection highlighted; otherwise false
-   * @param	hasFocus	if true, render cell appropriately.
-   * @param	row	        the row index of the cell being drawn.
-   * @param	col 	    the column index of the cell being drawn
-   *
-   * @return  Component
-   */
-  @Override
-  public Component getTableCellRendererComponent(JTable table,
-          Object value,
-          boolean isSelected,
-          boolean hasFocus,
-          int row,
-          int col) {
-
-    Color textcol = Color.green;
-
-    // we need to get the connection from the model
-    TableModel mdl = table.getModel();
-    if (mdl instanceof RepositoryConnectionTableModel) {
-      RepositoryConnectionTableModel connmdl = (RepositoryConnectionTableModel) mdl;
-
-      RepositoryConnection conn = connmdl.connectionAtRow(row);
-
-      if (!conn.isConnected() && conn.getPassword().equals("")) {
-        textcol = Color.red;
-      }
-
-    }
-
-    /* Set default values from table object and UI manager*/
-    if (isSelected) {
-      textarea.setBackground(table.getSelectionBackground());
-      textarea.setForeground(textcol);
-    } else {
-      textarea.setBackground(table.getBackground());
-      textarea.setForeground(textcol);
-    }
-
-    textarea.setEnabled(table.isEnabled());
-    textarea.setFont(table.getFont());
-
-    if (hasFocus) {
-      textarea.setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
-    } else {
-      textarea.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
-    }
-
-    textarea.setHorizontalAlignment(JTextField.CENTER);
-    textarea.setText(value.toString());
-
-    return textarea;
-  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionDialog.form	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="2"/>
-    <Property name="title" type="java.lang.String" value="Repository Connection"/>
-    <Property name="locationByPlatform" type="boolean" value="true"/>
-    <Property name="modal" type="boolean" value="true"/>
-    <Property name="resizable" type="boolean" value="false"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-  </SyntheticProperties>
-  <AuxValues>
-    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
-    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-  </AuxValues>
-
-  <Layout>
-    <DimensionLayout dim="0">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" attributes="0">
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Component id="jLabel11" alignment="1" min="-2" max="-2" attributes="0"/>
-                  <Component id="jLabel9" alignment="1" min="-2" max="-2" attributes="0"/>
-                  <Component id="jLabel12" alignment="1" min="-2" max="-2" attributes="0"/>
-                  <Component id="jLabel10" alignment="1" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Component id="getDatabaseListBtn" alignment="1" min="-2" max="-2" attributes="0"/>
-                  <Component id="repositoryHostTxtField" alignment="1" pref="216" max="32767" attributes="0"/>
-                  <Component id="passwordTxtField" alignment="1" pref="216" max="32767" attributes="0"/>
-                  <Group type="102" alignment="1" attributes="0">
-                      <Component id="cancelBtn" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="connectBtn" min="-2" max="-2" attributes="0"/>
-                  </Group>
-                  <Component id="usernameTxtField" alignment="1" pref="216" max="32767" attributes="0"/>
-                  <Component id="databaseCombo" alignment="1" pref="216" max="32767" attributes="0"/>
-                  <Component id="repositoryHostsCombo" alignment="1" pref="216" max="32767" attributes="0"/>
-              </Group>
-              <EmptySpace max="-2" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-    <DimensionLayout dim="1">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="0" attributes="0">
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="repositoryHostsCombo" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace max="-2" attributes="0"/>
-              <Component id="repositoryHostTxtField" min="-2" max="-2" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="usernameTxtField" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace type="separate" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="passwordTxtField" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace type="unrelated" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="databaseCombo" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace type="unrelated" max="-2" attributes="0"/>
-              <Component id="getDatabaseListBtn" min="-2" max="-2" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="connectBtn" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace max="32767" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-  </Layout>
-  <SubComponents>
-    <Component class="javax.swing.JLabel" name="jLabel10">
-      <Properties>
-        <Property name="horizontalAlignment" type="int" value="4"/>
-        <Property name="text" type="java.lang.String" value="database"/>
-      </Properties>
-    </Component>
-    <Component class="javax.swing.JLabel" name="jLabel9">
-      <Properties>
-        <Property name="horizontalAlignment" type="int" value="4"/>
-        <Property name="text" type="java.lang.String" value="hostname"/>
-      </Properties>
-    </Component>
-    <Component class="javax.swing.JComboBox" name="repositoryHostsCombo">
-      <Properties>
-        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
-          <StringArray count="0"/>
-        </Property>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="repositoryHostsComboActionPerformed"/>
-        <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="repositoryHostsComboKeyTyped"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JTextField" name="repositoryHostTxtField">
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="repositoryHostTxtFieldActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JComboBox" name="databaseCombo">
-      <Properties>
-        <Property name="editable" type="boolean" value="true"/>
-        <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
-          <StringArray count="0"/>
-        </Property>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="databaseComboActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="getDatabaseListBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Get list"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="getDatabaseListBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JTextField" name="usernameTxtField">
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="usernameTxtFieldActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JLabel" name="jLabel11">
-      <Properties>
-        <Property name="horizontalAlignment" type="int" value="4"/>
-        <Property name="text" type="java.lang.String" value="username"/>
-      </Properties>
-    </Component>
-    <Component class="javax.swing.JLabel" name="jLabel12">
-      <Properties>
-        <Property name="horizontalAlignment" type="int" value="4"/>
-        <Property name="text" type="java.lang.String" value="password"/>
-      </Properties>
-    </Component>
-    <Component class="javax.swing.JPasswordField" name="passwordTxtField">
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="passwordTxtFieldActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="connectBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Connect"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="cancelBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Cancel"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
-      </Events>
-    </Component>
-  </SubComponents>
-</Form>
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionDialog.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,384 +0,0 @@
-/*
- * Class RepositoryConnectionDialog <one line to give the program's name and a brief idea of what it does.>
- *
- * Copyright (c) 2009 Max-Planck-Gesellschaft, Martin Hewitson <martin.hewitson at aei.mpg.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * RepositoryConnectionDialog.java
- *
- * Created on 25-Jul-2009, 17:12:21
- */
-package mpipeline.repository;
-
-import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.swing.DefaultComboBoxModel;
-import mpipeline.main.MainWindow;
-
-/**
- *
- * @author Martin Hewitson <martin.hewitson at aei.mpg.de>
- */
-public class RepositoryConnectionDialog extends javax.swing.JDialog {
-
-  private RepositoryConnection repoConnection = null;
-  private boolean cancelled = true;
-  private MainWindow mw = null;
-
-  /** Creates new form RepositoryConnectionDialog
-   * @param parent
-   * @param modal
-   * @param hostnames
-   * @param repocon 
-   */
-  public RepositoryConnectionDialog(MainWindow parent, boolean modal, ArrayList<String> hostnames, RepositoryConnection repocon) {
-    super(parent, modal);
-    initComponents();
-    this.mw = parent;
-
-    try {
-      Class.forName("com.mysql.jdbc.Driver");
-    }
-    catch (ClassNotFoundException ex) {
-      Logger.getLogger(SubmitInfoDialog.class.getName()).log(Level.SEVERE, null, ex);
-    }
-
-    repositoryHostsCombo.setModel(new DefaultComboBoxModel(hostnames.toArray()));
-    if (repocon != null) {
-      repoConnection = repocon;
-      usernameTxtField.setText(repocon.getUsername());
-      passwordTxtField.setText(repocon.getPassword());
-      repositoryHostsCombo.setSelectedItem(repocon.getHostname());
-
-      if (repocon.getHostname().equals("")) {
-        if (hostnames.size() > 0) {
-          repositoryHostTxtField.setText(hostnames.get(0));
-        }
-      }
-      else {
-        repositoryHostTxtField.setText(repocon.getHostname());
-      }
-      String[] dbs = new String[1];
-      dbs[0] = repocon.getDatabase();
-      databaseCombo.setModel(new DefaultComboBoxModel(dbs));
-    }
-    else {
-      if (hostnames.size() > 0) {
-        repositoryHostTxtField.setText(hostnames.get(0));
-      }
-    }
-  }
-
-  public RepositoryConnection getRepositoryConnection() {
-    return repoConnection;
-  }
-
-  public boolean isCancelled() {
-    return cancelled;
-  }
-
-  /** This method is called from within the constructor to
-   * initialize the form.
-   * WARNING: Do NOT modify this code. The content of this method is
-   * always regenerated by the Form Editor.
-   */
-  @SuppressWarnings("unchecked")
-  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-  private void initComponents() {
-
-    jLabel10 = new javax.swing.JLabel();
-    jLabel9 = new javax.swing.JLabel();
-    repositoryHostsCombo = new javax.swing.JComboBox();
-    repositoryHostTxtField = new javax.swing.JTextField();
-    databaseCombo = new javax.swing.JComboBox();
-    getDatabaseListBtn = new javax.swing.JButton();
-    usernameTxtField = new javax.swing.JTextField();
-    jLabel11 = new javax.swing.JLabel();
-    jLabel12 = new javax.swing.JLabel();
-    passwordTxtField = new javax.swing.JPasswordField();
-    connectBtn = new javax.swing.JButton();
-    cancelBtn = new javax.swing.JButton();
-
-    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-    setTitle("Repository Connection");
-    setLocationByPlatform(true);
-    setModal(true);
-    setResizable(false);
-
-    jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
-    jLabel10.setText("database");
-
-    jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
-    jLabel9.setText("hostname");
-
-    repositoryHostsCombo.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        repositoryHostsComboActionPerformed(evt);
-      }
-    });
-    repositoryHostsCombo.addKeyListener(new java.awt.event.KeyAdapter() {
-      public void keyTyped(java.awt.event.KeyEvent evt) {
-        repositoryHostsComboKeyTyped(evt);
-      }
-    });
-
-    repositoryHostTxtField.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        repositoryHostTxtFieldActionPerformed(evt);
-      }
-    });
-
-    databaseCombo.setEditable(true);
-    databaseCombo.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        databaseComboActionPerformed(evt);
-      }
-    });
-
-    getDatabaseListBtn.setText("Get list");
-    getDatabaseListBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        getDatabaseListBtnActionPerformed(evt);
-      }
-    });
-
-    usernameTxtField.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        usernameTxtFieldActionPerformed(evt);
-      }
-    });
-
-    jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
-    jLabel11.setText("username");
-
-    jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
-    jLabel12.setText("password");
-
-    passwordTxtField.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        passwordTxtFieldActionPerformed(evt);
-      }
-    });
-
-    connectBtn.setText("Connect");
-    connectBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        connectBtnActionPerformed(evt);
-      }
-    });
-
-    cancelBtn.setText("Cancel");
-    cancelBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        cancelBtnActionPerformed(evt);
-      }
-    });
-
-    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
-    getContentPane().setLayout(layout);
-    layout.setHorizontalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel11)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel9)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel12)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel10))
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, getDatabaseListBtn)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, repositoryHostTxtField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, passwordTxtField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
-            .add(cancelBtn)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(connectBtn))
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, usernameTxtField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, databaseCombo, 0, 216, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, repositoryHostsCombo, 0, 216, Short.MAX_VALUE))
-        .addContainerGap())
-    );
-    layout.setVerticalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(jLabel9)
-          .add(repositoryHostsCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(repositoryHostTxtField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(jLabel11)
-          .add(usernameTxtField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .add(18, 18, 18)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(jLabel12)
-          .add(passwordTxtField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(jLabel10)
-          .add(databaseCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
-        .add(getDatabaseListBtn)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(connectBtn)
-          .add(cancelBtn))
-        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-    );
-
-    pack();
-  }// </editor-fold>//GEN-END:initComponents
-
-    private void repositoryHostsComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_repositoryHostsComboActionPerformed
-
-      repositoryHostTxtField.setText(repositoryHostsCombo.getSelectedItem().toString());
-      passwordTxtField.setText("");
-      checkInputsAndConnect();
-    }//GEN-LAST:event_repositoryHostsComboActionPerformed
-
-    private void getDatabaseListBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getDatabaseListBtnActionPerformed
-
-      RepositoryConnection conn = new RepositoryConnection(mw);
-      conn.setHostname(repositoryHostTxtField.getText());
-      conn.setDatabase("test");
-      conn.setUsername(usernameTxtField.getText());
-      conn.setPassword(new String(passwordTxtField.getPassword()));
-
-      conn.openConnection();
-      if (conn.isConnected()) {
-        ArrayList<String> dbs = conn.getDatabaseList();
-        conn.closeConnection();
-        // fill combo list
-        databaseCombo.setModel(new DefaultComboBoxModel(dbs.toArray()));
-      }
-    }//GEN-LAST:event_getDatabaseListBtnActionPerformed
-
-    private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
-
-      cancelled = true;
-      this.dispose();
-    }//GEN-LAST:event_cancelBtnActionPerformed
-
-    private void connectBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectBtnActionPerformed
-
-      checkInputsAndConnect();
-    }//GEN-LAST:event_connectBtnActionPerformed
-
-    private void repositoryHostTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_repositoryHostTxtFieldActionPerformed
-
-      checkInputsAndConnect();
-    }//GEN-LAST:event_repositoryHostTxtFieldActionPerformed
-
-    private void usernameTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameTxtFieldActionPerformed
-
-      checkInputsAndConnect();
-    }//GEN-LAST:event_usernameTxtFieldActionPerformed
-
-    private void passwordTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordTxtFieldActionPerformed
-
-      checkInputsAndConnect();
-    }//GEN-LAST:event_passwordTxtFieldActionPerformed
-
-    private void databaseComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_databaseComboActionPerformed
-
-      // Connect only if the user enters RETURN
-      if (evt.getActionCommand().equals("comboBoxEdited")) {
-        checkInputsAndConnect();
-      }
-    }//GEN-LAST:event_databaseComboActionPerformed
-
-    private void repositoryHostsComboKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_repositoryHostsComboKeyTyped
-
-      if (evt.getKeyChar() == '\n') {
-        checkInputsAndConnect();
-      }
-    }//GEN-LAST:event_repositoryHostsComboKeyTyped
-  // Variables declaration - do not modify//GEN-BEGIN:variables
-  private javax.swing.JButton cancelBtn;
-  private javax.swing.JButton connectBtn;
-  private javax.swing.JComboBox databaseCombo;
-  private javax.swing.JButton getDatabaseListBtn;
-  private javax.swing.JLabel jLabel10;
-  private javax.swing.JLabel jLabel11;
-  private javax.swing.JLabel jLabel12;
-  private javax.swing.JLabel jLabel9;
-  private javax.swing.JPasswordField passwordTxtField;
-  private javax.swing.JTextField repositoryHostTxtField;
-  private javax.swing.JComboBox repositoryHostsCombo;
-  private javax.swing.JTextField usernameTxtField;
-  // End of variables declaration//GEN-END:variables
-
-  private void checkInputsAndConnect() {
-
-    String hostname = repositoryHostTxtField.getText();
-    String username = usernameTxtField.getText();
-    String password = new String(passwordTxtField.getPassword());
-    String database = null;
-
-    Object selObj = databaseCombo.getSelectedItem();
-    if (selObj == null) {
-      database = "";
-    }
-    else {
-      database = selObj.toString();
-    }
-
-    // Set the focus to the host-textfield if no hostname is entered.
-    if (hostname.length() == 0) {
-      repositoryHostTxtField.requestFocusInWindow();
-      return;
-    }
-    // Set the focus to the username-textfield if no username is entered.
-    if (username.length() == 0) {
-      usernameTxtField.requestFocusInWindow();
-      return;
-    }
-    // Set the focus to the database-textfield if no database is entered.
-    if (database.length() == 0) {
-      databaseCombo.requestFocusInWindow();
-      return;
-    }
-
-    // test the connection
-    if (repoConnection == null) {
-
-      repoConnection = new RepositoryConnection(mw, hostname, database, username, password);
-      repoConnection.display();
-
-    }
-    else {
-
-      if (repoConnection.isConnected()) {
-        repoConnection.closeConnection();
-      }
-
-      repoConnection.setHostname(hostname);
-      repoConnection.setDatabase(database);
-      repoConnection.setUsername(username);
-      repoConnection.setPassword(password);
-    }
-
-    cancelled = false;
-    this.dispose();
-
-  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionPasswordDialog.form	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-<?xml version="1.1" encoding="UTF-8" ?>
-
-<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="2"/>
-    <Property name="title" type="java.lang.String" value="Login"/>
-    <Property name="locationByPlatform" type="boolean" value="true"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-  </SyntheticProperties>
-  <AuxValues>
-    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
-    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-  </AuxValues>
-
-  <Layout>
-    <DimensionLayout dim="0">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" attributes="0">
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="102" alignment="1" attributes="0">
-                      <Component id="cancelBtn" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="connectBtn" min="-2" max="-2" attributes="0"/>
-                  </Group>
-                  <Group type="102" alignment="0" attributes="0">
-                      <Component id="jPasswordLable" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="passwordTxtField" pref="217" max="32767" attributes="0"/>
-                  </Group>
-                  <Component id="jInfoLabel" alignment="0" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace max="-2" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-    <DimensionLayout dim="1">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="0" attributes="0">
-              <EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
-              <Component id="jInfoLabel" min="-2" max="-2" attributes="0"/>
-              <EmptySpace type="separate" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="jPasswordLable" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="passwordTxtField" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace type="separate" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="3" attributes="0">
-                  <Component id="connectBtn" alignment="3" min="-2" max="-2" attributes="0"/>
-                  <Component id="cancelBtn" alignment="3" min="-2" max="-2" attributes="0"/>
-              </Group>
-              <EmptySpace max="32767" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-  </Layout>
-  <SubComponents>
-    <Component class="javax.swing.JLabel" name="jPasswordLable">
-      <Properties>
-        <Property name="horizontalAlignment" type="int" value="4"/>
-        <Property name="text" type="java.lang.String" value="password"/>
-      </Properties>
-    </Component>
-    <Component class="javax.swing.JPasswordField" name="passwordTxtField">
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="passwordTxtFieldActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="connectBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Connect"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JButton" name="cancelBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Cancel"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cancelBtnActionPerformed"/>
-      </Events>
-    </Component>
-    <Component class="javax.swing.JLabel" name="jInfoLabel">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="username@hostname: database"/>
-      </Properties>
-    </Component>
-  </SubComponents>
-</Form>
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionPasswordDialog.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,211 +0,0 @@
-/*
- * Class RepositoryConnectionPasswordDialog <one line to give the program's name and a brief idea of what it does.>
- *
- * Copyright (c) 2010 Max-Planck-Gesellschaft, Ingo Diepholz <ingo.diepholz@aei.mpg.de>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * RepositoryConnectionPasswordDialog.java
- *
- * Created on 14-Jan-2010, 18:29:29
- */
-package mpipeline.repository;
-
-import java.awt.Dimension;
-import java.awt.FontMetrics;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import mpipeline.main.MainWindow;
-
-/**
- *
- * @author Ingo Diepholz <ingo.diepholz@aei.mpg.de>
- */
-public class RepositoryConnectionPasswordDialog extends javax.swing.JDialog {
-
-  private RepositoryConnection conn;
-  private boolean cancelled = false;
-
-  /** Creates new form RepositoryConnectionPasswordDialog */
-  public RepositoryConnectionPasswordDialog(MainWindow parent, boolean modal, RepositoryConnection repocon) {
-    super(parent, modal);
-    initComponents();
-
-    try {
-      Class.forName("com.mysql.jdbc.Driver");
-    }
-    catch (ClassNotFoundException ex) {
-      Logger.getLogger(SubmitInfoDialog.class.getName()).log(Level.SEVERE, null, ex);
-    }
-
-    conn = repocon;
-
-    if (conn != null) {
-      jInfoLabel.setText(conn.getUsername() + "@" + conn.getHostname() + ": " + conn.getDatabase());
-    }
-    else {
-      jInfoLabel.setText("null");
-    }
-
-    // Make sure that the width of the label string fits into the dialog
-    FontMetrics fm = jInfoLabel.getFontMetrics(jInfoLabel.getFont());
-    int width = fm.stringWidth(jInfoLabel.getText());
-    jInfoLabel.setPreferredSize(new Dimension(width, jInfoLabel.getPreferredSize().height));
-    jInfoLabel.setMaximumSize(new Dimension(width, jInfoLabel.getPreferredSize().height));
-    jInfoLabel.invalidate();
-    pack();
-
-  }
-
-  public boolean isCancelled() {
-    return cancelled;
-  }
-
-  public void setCancelled(boolean cancelled) {
-    this.cancelled = cancelled;
-  }
-
-  public RepositoryConnection getConn() {
-    return conn;
-  }
-
-  public void setConn(RepositoryConnection conn) {
-    this.conn = conn;
-  }
-
-  /** This method is called from within the constructor to
-   * initialize the form.
-   * WARNING: Do NOT modify this code. The content of this method is
-   * always regenerated by the Form Editor.
-   */
-  @SuppressWarnings("unchecked")
-  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-  private void initComponents() {
-
-    jPasswordLable = new javax.swing.JLabel();
-    passwordTxtField = new javax.swing.JPasswordField();
-    connectBtn = new javax.swing.JButton();
-    cancelBtn = new javax.swing.JButton();
-    jInfoLabel = new javax.swing.JLabel();
-
-    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-    setTitle("Login");
-    setLocationByPlatform(true);
-
-    jPasswordLable.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
-    jPasswordLable.setText("password");
-
-    passwordTxtField.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        passwordTxtFieldActionPerformed(evt);
-      }
-    });
-
-    connectBtn.setText("Connect");
-    connectBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        connectBtnActionPerformed(evt);
-      }
-    });
-
-    cancelBtn.setText("Cancel");
-    cancelBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        cancelBtnActionPerformed(evt);
-      }
-    });
-
-    jInfoLabel.setText("username@hostname: database");
-
-    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
-    getContentPane().setLayout(layout);
-    layout.setHorizontalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
-            .add(cancelBtn)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(connectBtn))
-          .add(layout.createSequentialGroup()
-            .add(jPasswordLable)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(passwordTxtField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE))
-          .add(jInfoLabel))
-        .addContainerGap())
-    );
-    layout.setVerticalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .add(20, 20, 20)
-        .add(jInfoLabel)
-        .add(18, 18, 18)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(jPasswordLable)
-          .add(passwordTxtField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-        .add(18, 18, Short.MAX_VALUE)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
-          .add(connectBtn)
-          .add(cancelBtn))
-        .addContainerGap())
-    );
-
-    pack();
-  }// </editor-fold>//GEN-END:initComponents
-
-    private void connectBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectBtnActionPerformed
-
-      connectToRepository();
-    }//GEN-LAST:event_connectBtnActionPerformed
-
-    private void cancelBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelBtnActionPerformed
-
-      cancelled = true;
-      this.dispose();
-}//GEN-LAST:event_cancelBtnActionPerformed
-
-    private void passwordTxtFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordTxtFieldActionPerformed
-
-      connectToRepository();
-    }//GEN-LAST:event_passwordTxtFieldActionPerformed
-
-  // Variables declaration - do not modify//GEN-BEGIN:variables
-  private javax.swing.JButton cancelBtn;
-  private javax.swing.JButton connectBtn;
-  private javax.swing.JLabel jInfoLabel;
-  private javax.swing.JLabel jPasswordLable;
-  private javax.swing.JPasswordField passwordTxtField;
-  // End of variables declaration//GEN-END:variables
-
-  private void connectToRepository() {
-    this.dispose();
-    String password = new String(passwordTxtField.getPassword());
-
-//    if (password.length() > 0) {
-      conn.setPassword(password);
-
-      conn.openConnection();
-      if (conn.isConnected()) {
-        cancelled = false;
-      }
-      else {
-        conn.setPassword("");
-      }
-    }
-//  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionTableModel.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package mpipeline.repository;
-
-import java.util.ArrayList;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.AbstractTableModel;
-
-/**
- *
- * @author hewitson
- */
-public class RepositoryConnectionTableModel extends AbstractTableModel implements TableModelListener {
-
-  private ArrayList<RepositoryConnection> connections = null;
-  private final String columnName[] = {"Hostname", "Database", "Username", "Age [s]"};
-
-  public RepositoryConnectionTableModel(ArrayList<RepositoryConnection> conns) {
-
-    this.connections = conns;
-    this.addTableModelListener(this);
-  }
-
-  public void tableChanged(TableModelEvent e) {
-    // System.out.println("tableChanged");
-  }
-
-  public RepositoryConnection connectionAtRow(int row) {
-    if (row >= 0 && row < connections.size()) {
-      return connections.get(row);
-    }
-    else {
-      return null;
-    }
-  }
-
-  @Override
-  public String getColumnName(int col) {
-    return columnName[col];
-  }
-
-  @Override
-  public boolean isCellEditable(int rowIndex, int columnIndex) {
-    return false;
-  }
-
-  public int getRowCount() {
-    return connections.size();
-  }
-
-  public int getColumnCount() {
-    return 4;
-  }
-
-  public Object getValueAt(int rowIndex, int columnIndex) {
-
-    if (columnIndex == 0) {
-      return connections.get(rowIndex).getHostname();
-    }
-    else if (columnIndex == 1) {
-      return connections.get(rowIndex).getDatabase();
-    }
-    else if (columnIndex == 2) {
-      return connections.get(rowIndex).getUsername();
-    }
-    else if (columnIndex == 3) {
-      int age = (int) connections.get(rowIndex).ageConnected();
-      if (age < 0) {
-        return "not connected";
-      }
-
-      return age;
-    }
-    else {
-      return connections.get(rowIndex).getHostname();
-    }
-  }
-
-  @Override
-  public void addTableModelListener(TableModelListener l) {
-    super.addTableModelListener(l);
-  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryConnectionsTable.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package mpipeline.repository;
-
-import java.awt.Color;
-import java.awt.event.MouseEvent;
-import javax.swing.JTable;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-
-/**
- *
- * @author hewitson
- */
-public class RepositoryConnectionsTable extends JTable{
-
-  public RepositoryConnectionsTable() {
-
-    setDefaultRenderer(String.class, new RepositoryConnectionCellRenderer());
-
-    this.setGridColor(Color.gray);
-    this.getTableHeader().setReorderingAllowed(false);
-    this.setSelectionBackground(Color.lightGray);
-
-    this.getTableHeader().setReorderingAllowed(false);
-
-    this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
-    this.setSelectionBackground(Color.lightGray);
-  }
-
-  @Override
-  public String getToolTipText(MouseEvent e) {
-    String tip = null;
-    java.awt.Point p = e.getPoint();
-    int rowIndex = rowAtPoint(p);
-    int colIndex = columnAtPoint(p);
-
-    tip = getValueAt(rowIndex, colIndex).toString();
-
-    return tip;
-  }
-
-  @Override
-  public TableCellRenderer getCellRenderer(int row, int column) {
-
-    Object obj = getValueAt(row, column);
-    if (obj == null) {
-      return new DefaultTableCellRenderer();
-    }
-
-    return new RepositoryConnectionCellRenderer();
-  }
-
-  @Override
-  public TableCellEditor getCellEditor(int row, int column) {
-    return null;
-  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryManager.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,235 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package mpipeline.repository;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-import mpipeline.main.MainWindow;
-
-/**
- *
- * @author hewitson
- */
-public class RepositoryManager {
-
-  private ArrayList<RepositoryConnection> connections = new ArrayList<RepositoryConnection>();
-  private ArrayList<String> repoHosts = new ArrayList<String>();
-
-  public RepositoryManager() {
-  }
-
-  public void addConnection(RepositoryConnection aConnection) {
-
-    boolean add = true;
-    ListIterator<RepositoryConnection> it = connections.listIterator();
-    while (it.hasNext()) {
-      RepositoryConnection conn = it.next();
-      if ((conn.getHostname().equals(aConnection.getHostname())) &&
-          (conn.getDatabase().equals(aConnection.getDatabase())) &&
-          (conn.getUsername().equals(aConnection.getUsername()))) {
-        // If an existing connection have the same hostname, database
-        // and user name then don't add the connection
-        if (conn.getPassword().length() == 0) {
-          conn.setPassword(aConnection.getPassword());
-        }
-        add = false;
-        break;
-      }
-    }
-
-    if (add) {
-      connections.add(aConnection);
-    }
-  }
-
-  public void removeConnection(RepositoryConnection aConnection) {
-    connections.remove(aConnection);
-  }
-
-  public void removeAll() {
-    this.closeAllConnections();
-    connections.clear();
-  }
-
-  public void closeAllConnections() {
-    Iterator it = connections.iterator();
-    while (it.hasNext()) {
-      RepositoryConnection conn = (RepositoryConnection) it.next();
-      conn.setLocked(false);
-      conn.closeConnection();
-    }
-  }
-
-  public ArrayList<RepositoryConnection> findConnections(String hostname, String database, String username) {
-
-    ArrayList<RepositoryConnection> conns = new ArrayList<RepositoryConnection>();
-
-    Iterator it = connections.iterator();
-    while (it.hasNext()) {
-      RepositoryConnection conn = (RepositoryConnection) it.next();
-
-      boolean found = true;
-
-      // check hostname if it's not empty
-      if (hostname.length() != 0 && !conn.getHostname().equals(hostname)) {
-        found = false;
-      }
-
-      // check database if it's not empty
-      if (database.length() != 0 && !conn.getDatabase().equals(database)) {
-        found = false;
-      }
-
-      // check username if it's not empty
-      if (username.length() != 0 && !conn.getUsername().equals(username)) {
-        found = false;
-      }
-
-      if (found) {
-        conns.add(conn);
-      }
-    }
-
-    return conns;
-  }
-
-  public RepositoryConnection findConnection(String hostname, String database, String username) {
-
-    RepositoryConnection connFound = null;
-
-    Iterator it = connections.iterator();
-    while (it.hasNext()) {
-      RepositoryConnection conn = (RepositoryConnection) it.next();
-
-      boolean found = true;
-
-      // check hostname if it's not empty
-      if (hostname.length() != 0 && !conn.getHostname().equals(hostname)) {
-        found = false;
-      }
-
-      // check database if it's not empty
-      if (database.length() != 0 && !conn.getDatabase().equals(database)) {
-        found = false;
-      }
-
-      // check username if it's not empty
-      if (username.length() != 0 && !conn.getUsername().equals(username)) {
-        found = false;
-      }
-
-      if (found) {
-        connFound = conn;
-        break;
-      }
-    }
-
-    return connFound;
-  }
-
-  public RepositoryConnection findExactConnection(String hostname, String database, String username) {
-
-    RepositoryConnection connFound = null;
-
-    Iterator it = connections.iterator();
-    while (it.hasNext()) {
-      RepositoryConnection conn = (RepositoryConnection) it.next();
-
-      // check hostname
-      if (conn.getHostname().equals(hostname) &&
-          conn.getDatabase().equals(database) &&
-          conn.getUsername().equals(username)) {
-        connFound = conn;
-        break;
-      }
-    }
-    return connFound;
-  }
-
-  /**
-   * 
-   * @param  mw LTPDA main window
-   * @return selected connection
-   */
-  public RepositoryConnection selectConnection(MainWindow mw) {
-
-    RepositoryConnection conn = null;
-
-    if (connections.size() >= 1) {
-      ConnectionSelector cs = new ConnectionSelector(mw, this);
-      cs.setVisible(true);
-
-      if (!cs.isCancelled()) {
-        conn = cs.getSelectedConnection();
-      }
-    }
-    else {
-      RepositoryConnectionDialog rcd = new RepositoryConnectionDialog(mw, true, repoHosts, null);
-      rcd.setVisible(true);
-
-      if (!rcd.isCancelled()) {
-        conn = rcd.getRepositoryConnection();
-        addConnection(conn);
-      }
-    }
-
-    if (conn != null) {
-      conn.openConnection();
-      if (!conn.isConnected()) {
-        conn = null;
-      }
-    }
-    return (conn);
-  }
-
-  public int count() {
-    return connections.size();
-  }
-
-  public int countConnected() {
-    int count = 0;
-    Iterator it = connections.iterator();
-    while (it.hasNext()) {
-      RepositoryConnection conn = (RepositoryConnection) it.next();
-      if (conn.isConnected()) {
-        count++;
-      }
-    }
-    return count;
-  }
-
-  public ArrayList<RepositoryConnection> getConnections() {
-    return connections;
-  }
-
-  public void setConnections(ArrayList<RepositoryConnection> connections) {
-    this.connections = connections;
-  }
-
-  public ArrayList<String> getRepoHosts() {
-    return repoHosts;
-  }
-
-  public void setRepoHosts(ArrayList<String> repoHosts) {
-    this.repoHosts = repoHosts;
-  }
-
-  public void display() {
-    System.out.println("---- Repository Manager  ----- ");
-    System.out.println(" connections: " + this.count());
-    System.out.println("   connected: " + this.countConnected());
-    System.out.println("------------------------------ ");
-  }
-
-  @Override
-  protected void finalize() throws Throwable {
-    System.out.println("Finalized repository manager");
-    closeAllConnections();
-
-    //do finalization here
-    super.finalize(); //not necessary if extending Object.
-  }
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryManagerGUI.form	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
-  <Properties>
-    <Property name="defaultCloseOperation" type="int" value="2"/>
-    <Property name="title" type="java.lang.String" value="Repository Manager"/>
-  </Properties>
-  <SyntheticProperties>
-    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
-  </SyntheticProperties>
-  <AuxValues>
-    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
-    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
-    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
-    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
-  </AuxValues>
-
-  <Layout>
-    <DimensionLayout dim="0">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="1" attributes="0">
-              <EmptySpace max="-2" attributes="0"/>
-              <Component id="jScrollPane1" pref="366" max="32767" attributes="0"/>
-              <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="0" max="-2" attributes="0">
-                  <Component id="newConnectionBtn" alignment="0" max="32767" attributes="1"/>
-                  <Component id="removePwdBtn" alignment="1" max="32767" attributes="1"/>
-                  <Component id="connectBtn" alignment="1" max="32767" attributes="1"/>
-                  <Component id="removeConnBtn" alignment="1" max="32767" attributes="1"/>
-              </Group>
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-    <DimensionLayout dim="1">
-      <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" alignment="0" attributes="0">
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="1" attributes="0">
-                  <Component id="jScrollPane1" alignment="0" min="0" pref="0" max="32767" attributes="2"/>
-                  <Group type="102" alignment="0" attributes="0">
-                      <Component id="connectBtn" min="-2" pref="51" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="removePwdBtn" min="-2" pref="53" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="removeConnBtn" min="-2" pref="51" max="-2" attributes="0"/>
-                      <EmptySpace max="-2" attributes="0"/>
-                      <Component id="newConnectionBtn" min="-2" pref="51" max="-2" attributes="0"/>
-                  </Group>
-              </Group>
-              <EmptySpace min="-2" max="-2" attributes="0"/>
-          </Group>
-      </Group>
-    </DimensionLayout>
-  </Layout>
-  <SubComponents>
-    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
-      <AuxValues>
-        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
-      </AuxValues>
-
-      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
-      <SubComponents>
-        <Component class="mpipeline.repository.RepositoryConnectionsTable" name="repositoryConnectionsTable">
-          <Properties>
-            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
-              <Connection code="new RepositoryConnectionTableModel(manager.getConnections()) " type="code"/>
-            </Property>
-          </Properties>
-        </Component>
-      </SubComponents>
-    </Container>
-    <Component class="javax.swing.JButton" name="connectBtn">
-      <Properties>
-        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-          <Image iconType="3" name="/mpipeline/icons/connect.png"/>
-        </Property>
-        <Property name="text" type="java.lang.String" value="Connect"/>
-        <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
-          <Connection code="getConnectTooltip()" type="code"/>
-        </Property>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connectBtnActionPerformed"/>
-      </Events>
-      <AuxValues>
-        <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="connectBtn.setDisplayedMnemonicIndex(0);"/>
-      </AuxValues>
-    </Component>
-    <Component class="javax.swing.JButton" name="removeConnBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Remove Connection"/>
-        <Property name="toolTipText" type="java.lang.String" value="Remove selected connection from the repository manager"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeConnBtnActionPerformed"/>
-      </Events>
-      <AuxValues>
-        <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="removeConnBtn.setDisplayedMnemonicIndex(0);"/>
-      </AuxValues>
-    </Component>
-    <Component class="javax.swing.JButton" name="newConnectionBtn">
-      <Properties>
-        <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-          <Image iconType="3" name="/mpipeline/icons/newconnection.png"/>
-        </Property>
-        <Property name="text" type="java.lang.String" value="New"/>
-        <Property name="toolTipText" type="java.lang.String" value="Create new connection"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newConnectionBtnActionPerformed"/>
-      </Events>
-      <AuxValues>
-        <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="newConnectionBtn.setDisplayedMnemonicIndex(0);"/>
-      </AuxValues>
-    </Component>
-    <Component class="javax.swing.JButton" name="removePwdBtn">
-      <Properties>
-        <Property name="text" type="java.lang.String" value="Clear Password"/>
-        <Property name="toolTipText" type="java.lang.String" value="Clears password from selected connection"/>
-      </Properties>
-      <Events>
-        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removePwdBtnActionPerformed"/>
-      </Events>
-      <AuxValues>
-        <AuxValue name="JavaCodeGenerator_AddingCodePost" type="java.lang.String" value="removePwdBtn.setDisplayedMnemonicIndex(6);"/>
-      </AuxValues>
-    </Component>
-  </SubComponents>
-</Form>
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryManagerGUI.java	Tue Dec 06 18:42:11 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,329 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/*
- * RepositoryManagerGUI.java
- *
- * Created on Jan 6, 2010, 10:38:55 AM
- */
-package mpipeline.repository;
-
-import mpipeline.dialogs.KeyBindingDialog;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import javax.swing.AbstractAction;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import javax.swing.KeyStroke;
-import javax.swing.Timer;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import mpipeline.main.MainWindow;
-
-/**
- *
- * @author hewitson
- */
-public class RepositoryManagerGUI extends KeyBindingDialog {
-
-  private RepositoryManager manager = null;
-  private MainWindow mw = null;
-  private RepositoryConnectionTableModel tableModel = null;
-  private ImageIcon disconnectIcon;
-  private ImageIcon connectIcon;
-  private javax.swing.Timer guiTimer = null;
-
-  /** Creates new form RepositoryManagerGUI */
-  public RepositoryManagerGUI(MainWindow parent, RepositoryManager manager) {
-    super(parent, false);
-    this.manager = manager;
-    this.mw = parent;
-
-    initComponents();
-
-    tableModel = (RepositoryConnectionTableModel) repositoryConnectionsTable.getModel();
-
-    repositoryConnectionsTable.getSelectionModel().addListSelectionListener(new SelectionListener());
-
-    disconnectIcon = new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/disconnect.png"));
-    connectIcon = new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/connect.png"));
-    guiTimer = new Timer(1000, new ActionListenerTimer());
-    guiTimer.start();
-
-    // Connect/Disconnect the selected connection with CTRL+C
-    KeyStroke keyStrokeC = KeyStroke.getKeyStroke(KeyEvent.VK_C, keyModifier, false);
-    rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStrokeC, "CTRL_C");
-    rootPane.getInputMap(JComponent.WHEN_FOCUSED).put(keyStrokeC, "CTRL_C");
-//    rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(keyStrokeC, "CTRL_C");
-    rootPane.getActionMap().put("CTRL_C", new ActionCTRL_C());
-    repositoryConnectionsTable.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStrokeC, "CTRL_C");
-    repositoryConnectionsTable.getInputMap(JComponent.WHEN_FOCUSED).put(keyStrokeC, "CTRL_C");
-    repositoryConnectionsTable.getActionMap().put("CTRL_C", new ActionCTRL_C());
-
-    // Clear the password of the selected connection with CTRL+P
-    KeyStroke keyStrokeP = KeyStroke.getKeyStroke(KeyEvent.VK_P, keyModifier, false);
-    rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStrokeP, "CTRL_P");
-    rootPane.getActionMap().put("CTRL_P", new ActionCTRL_P());
-
-    // Remove the selected connection with CTRL+R
-    KeyStroke keyStrokeR = KeyStroke.getKeyStroke(KeyEvent.VK_R, keyModifier);
-    rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStrokeR, "CTRL_R");
-    rootPane.getActionMap().put("CTRL_R", new ActionCTRL_R());
-
-    // Create a new connection with CTRL+N
-    KeyStroke keyStrokeN = KeyStroke.getKeyStroke(KeyEvent.VK_N, keyModifier);
-    rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStrokeN, "CTRL_N");
-    rootPane.getActionMap().put("CTRL_N", new ActionCTRL_N());
-}
-
-  private class ActionCTRL_N extends AbstractAction {
-
-    public void actionPerformed(ActionEvent e) {
-      newConnectionBtnActionPerformed(e);
-    }
-  }
-
-  private class ActionCTRL_R extends AbstractAction {
-
-    public void actionPerformed(ActionEvent e) {
-      removeConnBtnActionPerformed(e);
-    }
-  }
-
-  private class ActionCTRL_P extends AbstractAction {
-
-    public void actionPerformed(ActionEvent e) {
-      removePwdBtnActionPerformed(e);
-    }
-  }
-
-  private class ActionCTRL_C extends AbstractAction {
-
-    public void actionPerformed(ActionEvent e) {
-      connectBtnActionPerformed(e);
-    }
-  }
-
-  private class ActionListenerTimer implements ActionListener {
-
-    public void actionPerformed(ActionEvent evt) {
-      for (int i = 0; i < tableModel.getRowCount(); i++) {
-        tableModel.fireTableCellUpdated(i, 3);
-      }
-    }
-  }
-
-  private class SelectionListener implements ListSelectionListener {
-
-    public void valueChanged(ListSelectionEvent e) {
-
-      int row = repositoryConnectionsTable.getSelectedRow();
-
-      if (row >= 0) {
-        // get connection at this row
-        RepositoryConnection conn = tableModel.connectionAtRow(row);
-
-        if (conn != null) {
-          if (conn.isConnected()) {
-            connectBtn.setText("Disconnect");
-            connectBtn.setIcon(disconnectIcon);
-            connectBtn.setDisplayedMnemonicIndex(3);
-          }
-          else {
-            connectBtn.setText("Connect");
-            connectBtn.setIcon(connectIcon);
-            connectBtn.setDisplayedMnemonicIndex(0);
-          }
-        }
-      }
-    }
-  }
-
-  private String getConnectTooltip() {
-    return ("Connect/Disconnect selected connection " + getKeyBindingText(KeyEvent.VK_C, true));
-  }
-
-  /** This method is called from within the constructor to
-   * initialize the form.
-   * WARNING: Do NOT modify this code. The content of this method is
-   * always regenerated by the Form Editor.
-   */
-  @SuppressWarnings("unchecked")
-  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-  private void initComponents() {
-
-    jScrollPane1 = new javax.swing.JScrollPane();
-    repositoryConnectionsTable = new mpipeline.repository.RepositoryConnectionsTable();
-    connectBtn = new javax.swing.JButton();
-    removeConnBtn = new javax.swing.JButton();
-    newConnectionBtn = new javax.swing.JButton();
-    removePwdBtn = new javax.swing.JButton();
-
-    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-    setTitle("Repository Manager");
-
-    repositoryConnectionsTable.setModel(new RepositoryConnectionTableModel(manager.getConnections()) );
-    jScrollPane1.setViewportView(repositoryConnectionsTable);
-
-    connectBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/connect.png"))); // NOI18N
-    connectBtn.setText("Connect");
-    connectBtn.setToolTipText(getConnectTooltip());
-    connectBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        connectBtnActionPerformed(evt);
-      }
-    });
-
-    removeConnBtn.setText("Remove Connection");
-    removeConnBtn.setToolTipText("Remove selected connection from the repository manager");
-    removeConnBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        removeConnBtnActionPerformed(evt);
-      }
-    });
-
-    newConnectionBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/newconnection.png"))); // NOI18N
-    newConnectionBtn.setText("New");
-    newConnectionBtn.setToolTipText("Create new connection");
-    newConnectionBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        newConnectionBtnActionPerformed(evt);
-      }
-    });
-
-    removePwdBtn.setText("Clear Password");
-    removePwdBtn.setToolTipText("Clears password from selected connection");
-    removePwdBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        removePwdBtnActionPerformed(evt);
-      }
-    });
-
-    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
-    getContentPane().setLayout(layout);
-    layout.setHorizontalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
-        .addContainerGap()
-        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
-          .add(newConnectionBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, removePwdBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, connectBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, removeConnBtn, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-        .addContainerGap())
-    );
-    layout.setVerticalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-          .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, 0, 0, Short.MAX_VALUE)
-          .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
-            .add(connectBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(removePwdBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(removeConnBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(newConnectionBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
-        .addContainerGap())
-    );
-
-    connectBtn.setDisplayedMnemonicIndex(0);
-    removeConnBtn.setDisplayedMnemonicIndex(0);
-    newConnectionBtn.setDisplayedMnemonicIndex(0);
-    removePwdBtn.setDisplayedMnemonicIndex(6);
-
-    pack();
-  }// </editor-fold>//GEN-END:initComponents
-
-  public void reloadConnectionTable() {
-    tableModel.fireTableDataChanged();
-  }
-
-    private void connectBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectBtnActionPerformed
-
-      // get selected connection
-      int row = repositoryConnectionsTable.getSelectedRow();
-      if (row >= 0) {
-        RepositoryConnection conn = tableModel.connectionAtRow(row);
-        if (conn != null) {
-          if (conn.isConnected()) {
-            conn.closeConnection();
-            connectBtn.setText("Connect");
-            connectBtn.setIcon(connectIcon);
-            connectBtn.setDisplayedMnemonicIndex(0);
-          }
-          else {
-            conn.openConnection();
-            if (conn.isConnected()) {
-              connectBtn.setText("Disconnect");
-              connectBtn.setIcon(disconnectIcon);
-              connectBtn.setDisplayedMnemonicIndex(3);
-            }
-          }
-
-          tableModel.fireTableDataChanged();
-          repositoryConnectionsTable.getSelectionModel().setSelectionInterval(row, row);
-        }
-      }
-
-    }//GEN-LAST:event_connectBtnActionPerformed
-
-    private void removeConnBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeConnBtnActionPerformed
-
-      int row = repositoryConnectionsTable.getSelectedRow();
-      if (row >= 0) {
-        RepositoryConnection conn = tableModel.connectionAtRow(row);
-        if (conn != null) {
-          conn.closeConnection();
-          manager.removeConnection(conn);
-          tableModel.fireTableDataChanged();
-        }
-      }
-
-    }//GEN-LAST:event_removeConnBtnActionPerformed
-
-    private void removePwdBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removePwdBtnActionPerformed
-
-      int row = repositoryConnectionsTable.getSelectedRow();
-      if (row >= 0) {
-        RepositoryConnection conn = tableModel.connectionAtRow(row);
-        if (conn != null) {
-          if (conn.isConnected()) {
-            conn.closeConnection();
-          }
-          conn.setPassword("");
-
-          tableModel.fireTableDataChanged();
-          repositoryConnectionsTable.getSelectionModel().setSelectionInterval(row, row);
-        }
-      }
-
-    }//GEN-LAST:event_removePwdBtnActionPerformed
-
-    private void newConnectionBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newConnectionBtnActionPerformed
-
-      RepositoryConnectionDialog rcd = new RepositoryConnectionDialog(mw, true, manager.getRepoHosts(), null);
-      rcd.setVisible(true);
-
-      if (!rcd.isCancelled()) {
-        RepositoryConnection conn = rcd.getRepositoryConnection();
-        manager.addConnection(conn);
-        reloadConnectionTable();
-      }
-    }//GEN-LAST:event_newConnectionBtnActionPerformed
-  // Variables declaration - do not modify//GEN-BEGIN:variables
-  private javax.swing.JButton connectBtn;
-  private javax.swing.JScrollPane jScrollPane1;
-  private javax.swing.JButton newConnectionBtn;
-  private javax.swing.JButton removeConnBtn;
-  private javax.swing.JButton removePwdBtn;
-  private mpipeline.repository.RepositoryConnectionsTable repositoryConnectionsTable;
-  // End of variables declaration//GEN-END:variables
-}
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryQueryDialog.form	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/repository/RepositoryQueryDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.1" encoding="UTF-8" ?>
 
 <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
   <Properties>
@@ -71,16 +71,16 @@
                           </Group>
                           <EmptySpace max="-2" attributes="0"/>
                           <Group type="103" groupAlignment="0" attributes="0">
-                              <Component id="fieldOrderCombo" pref="182" max="32767" attributes="0"/>
+                              <Component id="fieldOrderCombo" pref="193" max="32767" attributes="0"/>
                               <Component id="jScrollPane1" min="0" pref="0" max="32767" attributes="1"/>
-                              <Component id="tablesCombo" alignment="0" pref="182" max="32767" attributes="1"/>
+                              <Component id="tablesCombo" alignment="0" pref="193" max="32767" attributes="1"/>
                           </Group>
                           <EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
                           <Group type="103" groupAlignment="0" attributes="0">
                               <Component id="orderDirectionCombo" min="-2" max="-2" attributes="0"/>
                               <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
                               <Group type="102" alignment="0" attributes="0">
-                                  <Component id="jScrollPane2" pref="170" max="32767" attributes="0"/>
+                                  <Component id="jScrollPane2" pref="181" max="32767" attributes="0"/>
                                   <EmptySpace max="-2" attributes="0"/>
                                   <Group type="103" groupAlignment="0" attributes="0">
                                       <Component id="removeConditionBtn" linkSize="1" min="-2" max="-2" attributes="0"/>
@@ -277,7 +277,7 @@
         <DimensionLayout dim="0">
           <Group type="103" groupAlignment="0" attributes="0">
               <Group type="102" alignment="1" attributes="0">
-                  <EmptySpace pref="381" max="32767" attributes="0"/>
+                  <EmptySpace pref="422" max="32767" attributes="0"/>
                   <Component id="doneBtn" min="-2" max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
                   <Component id="executeBtn" min="-2" max="-2" attributes="0"/>
--- a/src/MPipeline2/src/mpipeline/repository/RepositoryQueryDialog.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/repository/RepositoryQueryDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -48,18 +48,18 @@
   private boolean cancelled = true;
   private MainWindow mw = null;
   private boolean modal = true;
-  private RepositoryConnection repoConnection = null;
+  private java.sql.Connection repoConnection = null;
   private ArrayList<String> tables = new ArrayList<String>();
   private ArrayList<String> fields = new ArrayList<String>();
   private boolean showConstructorButton = true;
-
+  
   /** Creates new form RepositoryQueryDialgo
    * @param parent
    * @param modal
    * @param conn
    * @param showConstructorButton
    */
-  public RepositoryQueryDialog(MainWindow parent, boolean modal, RepositoryConnection conn, boolean showConstructorButton) {
+  public RepositoryQueryDialog(MainWindow parent, boolean modal, java.sql.Connection conn, boolean showConstructorButton) {
     super(parent, modal);
     initComponents();
 
@@ -67,47 +67,27 @@
     this.showConstructorButton = showConstructorButton;
     this.modal = modal;
 
-    // Set or get connection
-    if (conn != null) {
-      repoConnection = conn;
-    }
-    if ((repoConnection == null) && (mw != null)) {
-      repoConnection = mw.getRepositoryManager().selectConnection(mw);
-    }
-
     // Return if the connection is invalid();
-    if (repoConnection == null) {
+    if (conn == null) {
       dispose();
       return;
     }
-
-    // Set title
-    if (repoConnection != null) {
-      this.setTitle("Query: " + repoConnection.getHostname() + "/" + repoConnection.getDatabase());
-    }
-
-    // connect to repository
-    if (!repoConnection.isConnected()) {
-      repoConnection.openConnection();
-    }
+    repoConnection = conn;
 
     // get a table list
-    if (repoConnection.isConnected()) {
-      Statement stmt = repoConnection.createStatement();
+    try {
       ResultSet rs;
-      try {
-        rs = stmt.executeQuery("SHOW TABLES");
-        while (rs.next()) {
-          String str = rs.getString(1);
-          tables.add(str);
-        }
+      Statement stmt = repoConnection.createStatement();
+      rs = stmt.executeQuery("SHOW TABLES");
+      while (rs.next()) {
+        String str = rs.getString(1);
+        tables.add(str);
       }
-      catch (SQLException ex) {
-        Logger.getLogger(RepositoryQueryDialog.class.getName()).log(Level.SEVERE, null, ex);
-      }
-
-      tablesCombo.setModel(new DefaultComboBoxModel(tables.toArray()));
     }
+    catch (SQLException ex) {
+      Logger.getLogger(RepositoryQueryDialog.class.getName()).log(Level.SEVERE, null, ex);
+    }
+    tablesCombo.setModel(new DefaultComboBoxModel(tables.toArray()));
 
     if (tables.contains("objmeta")) {
       tablesCombo.setSelectedItem("objmeta");
@@ -126,13 +106,12 @@
     if (o != null) {
 
       String tbl = o.toString();
-
       String q = "describe " + tbl;
-      Statement stmt = repoConnection.createStatement();
-      ResultSet rs;
       DefaultListModel mdl = new DefaultListModel();
-
+      
       try {
+        ResultSet rs;
+        Statement stmt = repoConnection.createStatement();
         fields.clear();
         rs = stmt.executeQuery(q);
         while (rs.next()) {
@@ -210,40 +189,30 @@
   @Override
   public void dispose() {
     super.dispose();
+    if (repoConnection != null) {
+      try {
+        repoConnection.close();
+      } catch (SQLException ex) { }
+    }
   }
 
   protected void executeActionPerformed(java.awt.event.ActionEvent evt) {
-
+      
     String q = queryTxtField.getText();
-
-    if (!repoConnection.isConnected()) {
-      repoConnection.openConnection();
-    }
-
-    if (repoConnection.isConnected()) {
-      // lock connection
-      repoConnection.setLocked(true);
-
+    try {
       Statement stmt = repoConnection.createStatement();
       ResultSet rs;
-      try {
-        rs = stmt.executeQuery(q);
-
-        // pass to query results table
-        QueryResultsTableDialog qrt = new QueryResultsTableDialog(mw, modal, rs, q, showConstructorButton);
-        qrt.setUsedConn(repoConnection);
-        qrt.setVisible(true);
-
-      }
-      catch (Exception ex) {
-
-        JOptionPane.showMessageDialog(mw,
-                ex.getMessage(),
-                "Query error",
-                JOptionPane.ERROR_MESSAGE);
-      }
-      repoConnection.setLocked(false);
-
+      rs = stmt.executeQuery(q);
+      // pass to query results table
+      QueryResultsTableDialog qrt = new QueryResultsTableDialog(mw, modal, rs, q, showConstructorButton);
+      qrt.setUsedConn(repoConnection);
+      qrt.setVisible(true);
+    }
+    catch (Exception ex) {
+      JOptionPane.showMessageDialog(mw,
+              ex.getMessage(),
+              "Query error",
+              JOptionPane.ERROR_MESSAGE);
     }
   }
 
@@ -251,7 +220,7 @@
     return queryTxtField;
   }
 
-  public RepositoryConnection getRepoConnection() {
+  public java.sql.Connection getRepoConnection() {
     return repoConnection;
   }
 
--- a/src/MPipeline2/src/mpipeline/workspace/WorkspaceBrowserDialog.form	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/workspace/WorkspaceBrowserDialog.form	Tue Dec 06 19:07:22 2011 +0100
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.1" encoding="UTF-8" ?>
 
 <Form version="1.7" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
   <Properties>
@@ -168,20 +168,6 @@
             <Property name="verticalTextPosition" type="int" value="3"/>
           </Properties>
         </Component>
-        <Component class="javax.swing.JButton" name="repositoryManagerBtn">
-          <Properties>
-            <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-              <Image iconType="3" name="/mpipeline/icons/link.png"/>
-            </Property>
-            <Property name="toolTipText" type="java.lang.String" value="Open the LTPDA repositorynamager"/>
-            <Property name="focusable" type="boolean" value="false"/>
-            <Property name="horizontalTextPosition" type="int" value="0"/>
-            <Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
-              <Image iconType="3" name="/mpipeline/icons/link_ro.png"/>
-            </Property>
-            <Property name="verticalTextPosition" type="int" value="3"/>
-          </Properties>
-        </Component>
       </SubComponents>
     </Container>
     <Container class="javax.swing.JPanel" name="jPanel2">
@@ -198,7 +184,7 @@
           <Group type="103" groupAlignment="0" attributes="0">
               <Group type="102" alignment="0" attributes="0">
                   <Component id="refreshBtn" min="-2" max="-2" attributes="0"/>
-                  <EmptySpace pref="101" max="32767" attributes="0"/>
+                  <EmptySpace pref="140" max="32767" attributes="0"/>
                   <Component id="doneBtn" min="-2" max="-2" attributes="0"/>
                   <EmptySpace max="-2" attributes="0"/>
               </Group>
--- a/src/MPipeline2/src/mpipeline/workspace/WorkspaceBrowserDialog.java	Tue Dec 06 18:42:11 2011 +0100
+++ b/src/MPipeline2/src/mpipeline/workspace/WorkspaceBrowserDialog.java	Tue Dec 06 19:07:22 2011 +0100
@@ -83,164 +83,155 @@
    * always regenerated by the Form Editor.
    */
   @SuppressWarnings("unchecked")
-  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-  private void initComponents() {
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
 
-    jToolBar1 = new javax.swing.JToolBar();
-    plotBtn = new javax.swing.JButton();
-    displayBtn = new javax.swing.JButton();
-    plotHistoryBtn = new javax.swing.JButton();
-    exploreBtn = new javax.swing.JButton();
-    jSeparator1 = new javax.swing.JToolBar.Separator();
-    submitBtn = new javax.swing.JButton();
-    queryBtn = new javax.swing.JButton();
-    retrieveBtn = new javax.swing.JButton();
-    repositoryManagerBtn = new javax.swing.JButton();
-    jPanel2 = new javax.swing.JPanel();
-    doneBtn = new javax.swing.JButton();
-    refreshBtn = new javax.swing.JButton();
-    jScrollPane1 = new javax.swing.JScrollPane();
-    workspaceTree = new WorkspaceTree(mw);
+        jToolBar1 = new javax.swing.JToolBar();
+        plotBtn = new javax.swing.JButton();
+        displayBtn = new javax.swing.JButton();
+        plotHistoryBtn = new javax.swing.JButton();
+        exploreBtn = new javax.swing.JButton();
+        jSeparator1 = new javax.swing.JToolBar.Separator();
+        submitBtn = new javax.swing.JButton();
+        queryBtn = new javax.swing.JButton();
+        retrieveBtn = new javax.swing.JButton();
+        jPanel2 = new javax.swing.JPanel();
+        doneBtn = new javax.swing.JButton();
+        refreshBtn = new javax.swing.JButton();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        workspaceTree = new WorkspaceTree(mw);
 
-    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
-    setTitle("Workspace Browser");
-    setLocationByPlatform(true);
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+        setTitle("Workspace Browser");
+        setLocationByPlatform(true);
 
-    jToolBar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
-    jToolBar1.setFloatable(false);
-    jToolBar1.setOrientation(1);
-    jToolBar1.setRollover(true);
-
-    plotBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/plot_small.png"))); // NOI18N
-    plotBtn.setToolTipText("Plot the selected AOs.");
-    plotBtn.setFocusable(false);
-    plotBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    plotBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/plot_small_ro.png"))); // NOI18N
-    plotBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(plotBtn);
+        jToolBar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
+        jToolBar1.setFloatable(false);
+        jToolBar1.setOrientation(javax.swing.SwingConstants.VERTICAL);
+        jToolBar1.setRollover(true);
 
-    displayBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/display.png"))); // NOI18N
-    displayBtn.setToolTipText("Display the selected object(s) on the Matlab terminal");
-    displayBtn.setFocusable(false);
-    displayBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    displayBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/display_ro.png"))); // NOI18N
-    displayBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(displayBtn);
+        plotBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/plot_small.png"))); // NOI18N
+        plotBtn.setToolTipText("Plot the selected AOs.");
+        plotBtn.setFocusable(false);
+        plotBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        plotBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/plot_small_ro.png"))); // NOI18N
+        plotBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(plotBtn);
 
-    plotHistoryBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/history_small.png"))); // NOI18N
-    plotHistoryBtn.setToolTipText("Display the history of the selected objects.");
-    plotHistoryBtn.setFocusable(false);
-    plotHistoryBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    plotHistoryBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/history_small_ro.png"))); // NOI18N
-    plotHistoryBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(plotHistoryBtn);
+        displayBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/display.png"))); // NOI18N
+        displayBtn.setToolTipText("Display the selected object(s) on the Matlab terminal");
+        displayBtn.setFocusable(false);
+        displayBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        displayBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/display_ro.png"))); // NOI18N
+        displayBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(displayBtn);
 
-    exploreBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/explore.png"))); // NOI18N
-    exploreBtn.setToolTipText("Explore the selected objects.");
-    exploreBtn.setFocusable(false);
-    exploreBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    exploreBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/explore_ro.png"))); // NOI18N
-    exploreBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(exploreBtn);
-    jToolBar1.add(jSeparator1);
+        plotHistoryBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/history_small.png"))); // NOI18N
+        plotHistoryBtn.setToolTipText("Display the history of the selected objects.");
+        plotHistoryBtn.setFocusable(false);
+        plotHistoryBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        plotHistoryBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/history_small_ro.png"))); // NOI18N
+        plotHistoryBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(plotHistoryBtn);
 
-    submitBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_to_database.png"))); // NOI18N
-    submitBtn.setToolTipText("Submit the selected objects to a repository.");
-    submitBtn.setFocusable(false);
-    submitBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    submitBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_to_database_ro.png"))); // NOI18N
-    submitBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(submitBtn);
+        exploreBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/explore.png"))); // NOI18N
+        exploreBtn.setToolTipText("Explore the selected objects.");
+        exploreBtn.setFocusable(false);
+        exploreBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        exploreBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/explore_ro.png"))); // NOI18N
+        exploreBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(exploreBtn);
+        jToolBar1.add(jSeparator1);
 
-    queryBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database.png"))); // NOI18N
-    queryBtn.setToolTipText("Query an LTPDA Repository");
-    queryBtn.setFocusable(false);
-    queryBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    queryBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database_ro.png"))); // NOI18N
-    queryBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(queryBtn);
+        submitBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_to_database.png"))); // NOI18N
+        submitBtn.setToolTipText("Submit the selected objects to a repository.");
+        submitBtn.setFocusable(false);
+        submitBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        submitBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/add_to_database_ro.png"))); // NOI18N
+        submitBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(submitBtn);
 
-    retrieveBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/download_database.png"))); // NOI18N
-    retrieveBtn.setToolTipText("Retrieve objecst from a repository.");
-    retrieveBtn.setFocusable(false);
-    retrieveBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    retrieveBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/download_database_ro.png"))); // NOI18N
-    retrieveBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(retrieveBtn);
+        queryBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database.png"))); // NOI18N
+        queryBtn.setToolTipText("Query an LTPDA Repository");
+        queryBtn.setFocusable(false);
+        queryBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        queryBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/search_database_ro.png"))); // NOI18N
+        queryBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(queryBtn);
 
-    repositoryManagerBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/link.png"))); // NOI18N
-    repositoryManagerBtn.setToolTipText("Open the LTPDA repositorynamager");
-    repositoryManagerBtn.setFocusable(false);
-    repositoryManagerBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-    repositoryManagerBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/link_ro.png"))); // NOI18N
-    repositoryManagerBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-    jToolBar1.add(repositoryManagerBtn);
+        retrieveBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/download_database.png"))); // NOI18N
+        retrieveBtn.setToolTipText("Retrieve objecst from a repository.");
+        retrieveBtn.setFocusable(false);
+        retrieveBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+        retrieveBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/download_database_ro.png"))); // NOI18N
+        retrieveBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+        jToolBar1.add(retrieveBtn);
 
-    jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
+        jPanel2.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
 
-    doneBtn.setText("Done");
-    doneBtn.addActionListener(new java.awt.event.ActionListener() {
-      public void actionPerformed(java.awt.event.ActionEvent evt) {
-        doneBtnActionPerformed(evt);
-      }
-    });
+        doneBtn.setText("Done");
+        doneBtn.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                doneBtnActionPerformed(evt);
+            }
+        });
 
-    refreshBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/refresh_small.png"))); // NOI18N
-    refreshBtn.setToolTipText("Refresh the workspace.");
-    refreshBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/refresh_small_ro.png"))); // NOI18N
+        refreshBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/refresh_small.png"))); // NOI18N
+        refreshBtn.setToolTipText("Refresh the workspace.");
+        refreshBtn.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpipeline/icons/refresh_small_ro.png"))); // NOI18N
 
-    org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
-    jPanel2.setLayout(jPanel2Layout);
-    jPanel2Layout.setHorizontalGroup(
-      jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jPanel2Layout.createSequentialGroup()
-        .add(refreshBtn)
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 101, Short.MAX_VALUE)
-        .add(doneBtn)
-        .addContainerGap())
-    );
-    jPanel2Layout.setVerticalGroup(
-      jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(jPanel2Layout.createSequentialGroup()
-        .addContainerGap()
-        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
-          .add(doneBtn)
-          .add(refreshBtn))
-        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-    );
+        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
+        jPanel2.setLayout(jPanel2Layout);
+        jPanel2Layout.setHorizontalGroup(
+            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel2Layout.createSequentialGroup()
+                .add(refreshBtn)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 140, Short.MAX_VALUE)
+                .add(doneBtn)
+                .addContainerGap())
+        );
+        jPanel2Layout.setVerticalGroup(
+            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(jPanel2Layout.createSequentialGroup()
+                .addContainerGap()
+                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+                    .add(doneBtn)
+                    .add(refreshBtn))
+                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+        );
 
-    jPanel2Layout.linkSize(new java.awt.Component[] {doneBtn, refreshBtn}, org.jdesktop.layout.GroupLayout.VERTICAL);
+        jPanel2Layout.linkSize(new java.awt.Component[] {doneBtn, refreshBtn}, org.jdesktop.layout.GroupLayout.VERTICAL);
 
-    jScrollPane1.setViewportView(workspaceTree);
+        jScrollPane1.setViewportView(workspaceTree);
 
-    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
-    getContentPane().setLayout(layout);
-    layout.setHorizontalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-          .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
-            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
-            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-            .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
-          .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-        .addContainerGap())
-    );
-    layout.setVerticalGroup(
-      layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-      .add(layout.createSequentialGroup()
-        .addContainerGap()
-        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
-          .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
-          .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE))
-        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
-        .addContainerGap())
-    );
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
+                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                        .add(jToolBar1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE)
+                    .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 325, Short.MAX_VALUE))
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+        );
 
-    pack();
-  }// </editor-fold>//GEN-END:initComponents
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
 
   private void doneBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doneBtnActionPerformed
 
@@ -248,23 +239,22 @@
   }//GEN-LAST:event_doneBtnActionPerformed
 
 
-  // Variables declaration - do not modify//GEN-BEGIN:variables
-  private javax.swing.JButton displayBtn;
-  private javax.swing.JButton doneBtn;
-  private javax.swing.JButton exploreBtn;
-  private javax.swing.JPanel jPanel2;
-  private javax.swing.JScrollPane jScrollPane1;
-  private javax.swing.JToolBar.Separator jSeparator1;
-  private javax.swing.JToolBar jToolBar1;
-  private javax.swing.JButton plotBtn;
-  private javax.swing.JButton plotHistoryBtn;
-  private javax.swing.JButton queryBtn;
-  private javax.swing.JButton refreshBtn;
-  private javax.swing.JButton repositoryManagerBtn;
-  private javax.swing.JButton retrieveBtn;
-  private javax.swing.JButton submitBtn;
-  private javax.swing.JTree workspaceTree;
-  // End of variables declaration//GEN-END:variables
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton displayBtn;
+    private javax.swing.JButton doneBtn;
+    private javax.swing.JButton exploreBtn;
+    private javax.swing.JPanel jPanel2;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JToolBar.Separator jSeparator1;
+    private javax.swing.JToolBar jToolBar1;
+    private javax.swing.JButton plotBtn;
+    private javax.swing.JButton plotHistoryBtn;
+    private javax.swing.JButton queryBtn;
+    private javax.swing.JButton refreshBtn;
+    private javax.swing.JButton retrieveBtn;
+    private javax.swing.JButton submitBtn;
+    private javax.swing.JTree workspaceTree;
+    // End of variables declaration//GEN-END:variables
 
 
   public JTree getWorkspaceTree() {
@@ -302,10 +292,6 @@
     return retrieveBtn;
   }
 
-  public JButton getRepositoryManagerBtn() {
-    return repositoryManagerBtn;
-  }
-
   public TreePath[] getSelectedPaths() {
     return workspaceTree.getSelectionPaths();
   }