TAG tag each input AO with a proper ID number. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: TAG tag each input AO with a proper ID number. For each input AO, a new ID Tag is retrieved from the MySQL database and set in the AO. This is necessary before an AO can be submitted to the database. CALL: aout = tag(ain, mysqlid) VERSION: $Id: tag.m,v 1.7 2007/08/31 17:40:08 hewitson Exp $ The following call returns a parameter list object that contains the default parameter values: >> pl = tag(ao, 'Params') HISTORY: 09-05-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function bs = tag(varargin) 0002 % TAG tag each input AO with a proper ID number. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: TAG tag each input AO with a proper ID number. 0007 % For each input AO, a new ID Tag is retrieved from the 0008 % MySQL database and set in the AO. This is necessary before an AO 0009 % can be submitted to the database. 0010 % 0011 % CALL: aout = tag(ain, mysqlid) 0012 % 0013 % VERSION: $Id: tag.m,v 1.7 2007/08/31 17:40:08 hewitson Exp $ 0014 % 0015 % The following call returns a parameter list object that 0016 % contains the default parameter values: 0017 % 0018 % >> pl = tag(ao, 'Params') 0019 % 0020 % HISTORY: 09-05-07 M Hewitson 0021 % Creation 0022 % 0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0024 0025 % Check if this is a call for parameters 0026 if nargin == 2 0027 if isa(as, 'ao') && ischar(mymid) 0028 in = char(mymid); 0029 if strcmp(in, 'Params') 0030 bs = getDefaultPL(); 0031 return 0032 end 0033 end 0034 end 0035 0036 %-------------------------------------------------------------------------- 0037 % collect all AOs from input 0038 as = []; 0039 for j=1:nargin 0040 a = varargin{j}; 0041 if isa(a, 'ao') 0042 as = [as a]; 0043 end 0044 if isa(a, 'database') 0045 conn = a; 0046 end 0047 end 0048 na = length(as); 0049 if na < 1 0050 error('### Incorrect inputs: please supply at least one AO to submit.'); 0051 end 0052 0053 0054 %-------------------------------------------------------------------------- 0055 % Now process each AO 0056 bs = []; 0057 for j=1:na 0058 0059 a = as(j); 0060 disp(sprintf('** Tagging AO: %s', a.name)); 0061 0062 %----- complete all information in this AO 0063 0064 % get current max id from server 0065 aoid = 1+mysql_getMaxId(conn); 0066 disp(sprintf('** Got object id: %06d', aoid)); 0067 0068 % set id 0069 a = set(a, 'tag', aoid); 0070 bs = [bs a]; 0071 end 0072 0073 0074 %-------------------------------------------------------------------------- 0075 % Get default params 0076 function plo = getDefaultPL() 0077 0078 disp('* creating default plist...'); 0079 plo = plist(); 0080 disp('* done.'); 0081 0082 0083 % END