LTPDA_OBJ_RETRIEVE retrieves a collection of objects from an LTPDA repository. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: RETRIEVE a collection of objects from an LTPDA repository. CALL: objs = ltpda_obj_retrieve(conn, cid) INPUTS: conn - database connection object cid - a collection id OUTPUTS: objs - the retrieved object(s) VERSION: $Id: submit.m,v 1.14 2007/08/16 06:55:25 hewitson Exp $ HISTORY: 30-08-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function objs = ltpda_obj_retrieve(varargin) 0002 0003 % LTPDA_OBJ_RETRIEVE retrieves a collection of objects from an LTPDA repository. 0004 % 0005 % 0006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0007 % 0008 % DESCRIPTION: RETRIEVE a collection of objects from an LTPDA repository. 0009 % 0010 % CALL: objs = ltpda_obj_retrieve(conn, cid) 0011 % 0012 % INPUTS: 0013 % conn - database connection object 0014 % cid - a collection id 0015 % 0016 % OUTPUTS: 0017 % objs - the retrieved object(s) 0018 % 0019 % VERSION: $Id: submit.m,v 1.14 2007/08/16 06:55:25 hewitson Exp $ 0020 % 0021 % HISTORY: 30-08-07 M Hewitson 0022 % Creation 0023 % 0024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0025 0026 objs = []; 0027 if nargin ~= 2 0028 help(mfilename) 0029 error('### Incorrect inputs'); 0030 end 0031 conn = varargin{1}; 0032 if ~isa(conn, 'database') 0033 error('### the first argument should be a database connection object.'); 0034 end 0035 cid = varargin{2}; 0036 if ~isnumeric(cid) 0037 error('### the second argument should be a collection id.'); 0038 end 0039 0040 %%%%%%%%%%%% Get a list of object IDs from the collection ID 0041 ids = mysql_getObjIds(conn, cid); 0042 0043 disp([sprintf('*** retrieving collection %d [objects ', cid) num2str(ids) ']']) 0044 0045 %%%%%%%%%%%% Get the object type 0046 type = mysql_getObjType(conn, ids(1)); 0047 0048 % check the rest 0049 for j=2:length(ids) 0050 tt = mysql_getObjType(conn, ids(j)); 0051 if ~strcmp(type, tt) 0052 error('### All objects in a collection should be of the same type. This should never happen.') 0053 end 0054 end 0055 0056 %%%%%%%%%%%% Call appropriate constructor 0057 0058 cmd = sprintf('objs = %s(conn, ids);', type); 0059 eval(cmd); 0060 0061 0062 0063 % END