Home > classes > @ao > fromRepository.m

fromRepository

PURPOSE ^

FROMREPOSITORY Construct an ao from a repository

SYNOPSIS ^

function aos = fromRepository(a, pli)

DESCRIPTION ^

 FROMREPOSITORY Construct an ao from a repository
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 FUNCTION:    fromRepository

 DESCRIPTION: Construct an ao from a repository

 CALL:        aos = fromRepository(a, pl)

 PARAMETER:
              pl:       Parameter list object

 HISTORY:     07-05-2007 Hewitson
              Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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