# HG changeset patch # User Daniele Nicolodi # Date 1323098406 -3600 # Node ID 29276498ebdb58d664562eea3d2b3d53cc5e27b9 # Parent ce4df2e95a55e707094f21cba168e3edfef87fe8 Remove LTPDARepositoryManager implementation * * * Remove GUI helper diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/LTPDARepositoryManager.m --- a/m-toolbox/classes/@LTPDARepositoryManager/LTPDARepositoryManager.m Mon Dec 05 16:20:06 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 - diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/addConnection.m --- a/m-toolbox/classes/@LTPDARepositoryManager/addConnection.m Mon Dec 05 16:20:06 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'); -% -% parameter sets -% -% 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 - diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/basic_newConnection.m --- a/m-toolbox/classes/@LTPDARepositoryManager/basic_newConnection.m Mon Dec 05 16:20:06 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 - - diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/cb_guiClosed.m --- a/m-toolbox/classes/@LTPDARepositoryManager/cb_guiClosed.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/cb_newConnection.m --- a/m-toolbox/classes/@LTPDARepositoryManager/cb_newConnection.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/cb_timerClearPassord.m --- a/m-toolbox/classes/@LTPDARepositoryManager/cb_timerClearPassord.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/cb_timerDisconnect.m --- a/m-toolbox/classes/@LTPDARepositoryManager/cb_timerDisconnect.m Mon Dec 05 16:20:06 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 - - diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/copyObjects.m --- a/m-toolbox/classes/@LTPDARepositoryManager/copyObjects.m Mon Dec 05 16:20:06 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'); -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/deleteTimer.m --- a/m-toolbox/classes/@LTPDARepositoryManager/deleteTimer.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/display.m --- a/m-toolbox/classes/@LTPDARepositoryManager/display.m Mon Dec 05 16:20:06 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 -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/executeQuery.m --- a/m-toolbox/classes/@LTPDARepositoryManager/executeQuery.m Mon Dec 05 16:20:06 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. -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/findConnections.m --- a/m-toolbox/classes/@LTPDARepositoryManager/findConnections.m Mon Dec 05 16:20:06 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'); -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/getConnection.m --- a/m-toolbox/classes/@LTPDARepositoryManager/getConnection.m Mon Dec 05 16:20:06 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. -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/getSinfo.m --- a/m-toolbox/classes/@LTPDARepositoryManager/getSinfo.m Mon Dec 05 16:20:06 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. -% -% Parameters Description -% -% 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 - diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/listConnections.m --- a/m-toolbox/classes/@LTPDARepositoryManager/listConnections.m Mon Dec 05 16:20:06 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) -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/newConnection.m --- a/m-toolbox/classes/@LTPDARepositoryManager/newConnection.m Mon Dec 05 16:20:06 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. -% -% Parameters Description -% -% 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 - diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/resetTimer.m --- a/m-toolbox/classes/@LTPDARepositoryManager/resetTimer.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/showGui.m --- a/m-toolbox/classes/@LTPDARepositoryManager/showGui.m Mon Dec 05 16:20:06 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) -% -% Parameters Description -% -% 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/startTimer.m --- a/m-toolbox/classes/@LTPDARepositoryManager/startTimer.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/classes/@LTPDARepositoryManager/updatePrefs.m --- a/m-toolbox/classes/@LTPDARepositoryManager/updatePrefs.m Mon Dec 05 16:20:06 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 diff -r ce4df2e95a55 -r 29276498ebdb m-toolbox/m/helper/LTPDARepositoryManagerGui.m --- a/m-toolbox/m/helper/LTPDARepositoryManagerGui.m Mon Dec 05 16:20:06 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