Home > classes > @timespan > fromRepository.m

fromRepository

PURPOSE ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SYNOPSIS ^

function ts = fromRepository(f, pli)

DESCRIPTION ^

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromRepository

 DESCRIPTION: Construct an timespan from a repository

 CALL:        ts = fromRepository(pli)

 PARAMETER:   pli:      Parameter list object

 HISTORY:     22-03-2008 M Hewitson
              Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %
0003 % FUNCTION:    fromRepository
0004 %
0005 % DESCRIPTION: Construct an timespan from a repository
0006 %
0007 % CALL:        ts = fromRepository(pli)
0008 %
0009 % PARAMETER:   pli:      Parameter list object
0010 %
0011 % HISTORY:     22-03-2008 M Hewitson
0012 %              Creation
0013 %
0014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0015 function ts = fromRepository(f, pli)
0016 
0017   VERSION = '$Id: fromRepository.m,v 1.3 2008/08/11 13:14:35 hewitson Exp $';
0018   % get timespan info
0019   ii = timespan.getInfo('timespan', 'From Repository');
0020 
0021   % Set the method version string in the minfo object
0022   ii.setMversion([VERSION '-->' ii.mversion]);
0023 
0024   % Add default values
0025   pl = combine(pli, ii.plists);
0026 
0027   % Get parameters
0028   conn     = find(pl, 'conn');
0029   hostname = find(pl, 'hostname');
0030   database = find(pl, 'database');
0031   ids      = find(pl, 'id');
0032 
0033   % do we have a connection?
0034   closeConn = 0;
0035   if isempty(conn)
0036     closeConn = 1;
0037     % Connect to repository
0038     conn = utils.mysql.connect(hostname, database);
0039   end
0040   if ~isa(conn, 'database')
0041     error('### connection failed.');
0042   end
0043 
0044   % Get each ID
0045   Nids = length(ids);
0046   ts  = [];
0047   for kk=1:Nids
0048 
0049     %---- This id
0050     id = ids(kk);
0051     utils.helper.msg(utils.const.msg.OPROC2, 'retrieving ID %d', id);
0052 
0053     %---- check ID object type
0054     tt = utils.mysql.getObjType(conn, id);
0055     %---- If this is a timespan
0056     if strcmp(tt, mfilename)
0057       %---- call database constructor
0058       a = ltpda_uo.retrieve(conn, id);
0059       %---- Add history
0060       %---- Add to output array
0061       ts = [ts a];
0062     else
0063       warning('    !skipping ID %d, type %s', id, tt);
0064     end
0065 
0066   end
0067 
0068   % close connection
0069   if closeConn
0070     close(conn);
0071   end
0072 
0073 end % function ts = timespanFromRepository(pli, version, algoname)
0074

Generated on Thu 14-Aug-2008 14:29:45 by m2html © 2003