changeset 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children 18e956c96a1b
files m-toolbox/classes/+utils/@mysql/connect.m m-toolbox/classes/+utils/@mysql/dbquery.m m-toolbox/classes/+utils/@mysql/getAOsInTimeSpan.m m-toolbox/classes/+utils/@mysql/getMD5hash.m m-toolbox/classes/+utils/@mysql/getMaxId.m m-toolbox/classes/+utils/@mysql/getObjIds.m m-toolbox/classes/+utils/@mysql/getObjType.m m-toolbox/classes/+utils/@mysql/getRepositoryVersion.m m-toolbox/classes/+utils/@mysql/getUserID.m m-toolbox/classes/+utils/@mysql/getXdoc.m m-toolbox/classes/+utils/@mysql/getsinfo.m m-toolbox/classes/+utils/@mysql/insert.m m-toolbox/classes/+utils/@mysql/logindlg.m m-toolbox/classes/+utils/@mysql/mysql.m
diffstat 14 files changed, 0 insertions(+), 1143 deletions(-) [+]
line wrap: on
line diff
--- a/m-toolbox/classes/+utils/@mysql/connect.m	Wed Nov 23 19:22:13 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-% CONNECT connects to an LTPDA repository and returns the connection object.
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%
-% 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 = 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
-%
-% VERSION:     $Id: connect.m,v 1.8 2010/01/22 12:46:08 ingo Exp $
-%
-% HISTORY:     24-05-2007 M Hewitson
-%                 Creation
-%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-%              (*) 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
-
-  persistent logins;
-  
-  prefs = getappdata(0, 'LTPDApreferences');
-  expTime = prefs.repository.loginExpiry;
-  
-  dbuser = '';
-  dbpass = '';
-
-  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
-      end
-    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
-    
-  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	Wed Nov 23 19:22:13 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
-
-
--- a/m-toolbox/classes/+utils/@mysql/getAOsInTimeSpan.m	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 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	Wed Nov 23 19:22:13 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-% 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
-
-  %------------------------------------------------
-  %--------- Declaration of Static methods --------
-  %------------------------------------------------
-  methods (Static)
-
-    %-------------------------------------------------------------
-    % List other methods
-    %-------------------------------------------------------------
-
-    %%% 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
-