Home > classes > @ssm > ssmFromRepository.m

ssmFromRepository

PURPOSE ^

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

SYNOPSIS ^

function ss = ssmFromRepository(pli)

DESCRIPTION ^

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

 FUNCTION:    ssmFromRepository

 DESCRIPTION: Construct a statespace model from a repository

 CALL:        see ssm

 PARAMETER:   

 HISTORY:     15-04-2008 Hewitson
              Creation
 
 VERSION : '$Id: ssmFromRepository.m,v 1.12 2008/08/08 15:32:33 adrien Exp $';
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0002 %
0003 % FUNCTION:    ssmFromRepository
0004 %
0005 % DESCRIPTION: Construct a statespace model from a repository
0006 %
0007 % CALL:        see ssm
0008 %
0009 % PARAMETER:
0010 %
0011 % HISTORY:     15-04-2008 Hewitson
0012 %              Creation
0013 %
0014 % VERSION : '$Id: ssmFromRepository.m,v 1.12 2008/08/08 15:32:33 adrien Exp $';
0015 %
0016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0017 function ss = ssmFromRepository(pli)
0018 utils.helper.msg(utils.const.msg.MNAME, ['running ', mfilename]);
0019 
0020 % Add default values
0021 pl = combine(pli, ssm.getDefaultPlist('From Repository'));
0022 
0023 % Get parameters
0024 conn     = find(pl, 'conn');
0025 hostname = find(pl, 'hostname');
0026 database = find(pl, 'database');
0027 ids      = find(pl, 'id');
0028 
0029 % do we have a connection?
0030 closeConn = 0;
0031 if isempty(conn)
0032   closeConn = 1;
0033   % Connect to repository
0034   conn = mysql_connect(hostname, database);
0035 end
0036 if ~isa(conn, 'database')
0037   error('### connection failed.');
0038 end
0039 
0040 % Get each ID
0041 Nids = length(ids);
0042 ss  = [];
0043 for kk=1:Nids
0044 
0045   %---- This id
0046   id = ids(kk);
0047   disp(sprintf('  - retrieving ID %d', id));
0048 
0049   %---- check ID object type
0050   tt = mysql_getObjType(conn, id);
0051   %---- If this is an AO
0052   if strcmp(tt, mfilename)
0053     %---- call database constructor
0054     s = ltpda_obj_retrieve(conn, id);
0055     %---- Add history
0056     s.addHistory(ssm.getInfo('ssm', 'From Repository'), pli, {''}, []);
0057     %---- Add to output array
0058     ss = [ss s]; %#ok<AGROW>
0059   else
0060     warning('    !skipping ID %d, type %s', id, tt);
0061   end
0062 
0063 end
0064 
0065 % close connection
0066 if closeConn
0067   close(conn);
0068 end
0069 end
0070

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003