0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 function objs = fromRepository(obj, pli)
0019
0020 VERSION = '$Id: fromRepository.m,v 1.3 2008/09/04 13:37:14 ingo Exp $';
0021
0022
0023 ii = obj.getInfo(class(obj), 'From Repository');
0024
0025 ii.setMversion([VERSION '-->' ii.mversion]);
0026
0027
0028 pl = combine(pli, ii.plists);
0029
0030
0031 conn = find(pl, 'conn');
0032 hostname = find(pl, 'hostname');
0033 database = find(pl, 'database');
0034 ids = find(pl, 'id');
0035 cid = find(pl, 'cid');
0036
0037
0038 closeConn = 0;
0039 if isempty(conn)
0040 closeConn = 1;
0041
0042 conn = utils.mysql.connect(hostname, database);
0043 end
0044 if ~isa(conn, 'database')
0045 error('### connection to the database failed.');
0046 end
0047
0048 if isempty(ids) && ~isempty(cid)
0049
0050 ids = utils.mysql.getObjIds(conn,cid);
0051 end
0052
0053
0054 Nids = length(ids);
0055 objs = [];
0056
0057 for kk=1:Nids
0058
0059
0060 id = ids(kk);
0061 utils.helper.msg(utils.const.msg.OPROC2, 'retrieving ID %d', id);
0062
0063
0064 tt = utils.mysql.getObjType(conn, id);
0065
0066
0067 if strcmp(tt, class(obj))
0068
0069 obj = ltpda_uo.retrieve(conn, id);
0070
0071
0072
0073
0074 txt = textscan(conn.URL, '%s', 'Delimiter', '/', 'CollectOutput', 1);
0075 plc = plist('hostname', txt{1}{3}, 'database', txt{1}{4});
0076 pl = combine(pli, plc);
0077 pl.remove('conn');
0078 obj.addHistory(ii, pl, [], obj.hist);
0079
0080
0081 objs = [objs obj];
0082 else
0083 warning(' !skipping ID %d, type %s', id, tt);
0084 end
0085
0086 end
0087
0088
0089 if closeConn
0090 close(conn);
0091 end
0092 end
0093