comparison m-toolbox/classes/@ltpda_uo/retrieve.m @ 49:0bcdf74587d1 database-connection-manager

Cleanup
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:36 +0100
parents a59cdb8aaf31
children
comparison
equal deleted inserted replaced
48:16aa66670d74 49:0bcdf74587d1
30 % 30 %
31 % VERSION: $Id: retrieve.m,v 1.29 2011/11/30 06:49:01 hewitson Exp $ 31 % VERSION: $Id: retrieve.m,v 1.29 2011/11/30 06:49:01 hewitson Exp $
32 % 32 %
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 34
35 function varargout = retrieve(varargin) 35 function varargout = retrieve(conn, varargin)
36 36
37 import utils.const.* 37 import utils.const.*
38 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 38 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
39 39
40 if numel(varargin) < 2 40 if numel(varargin) < 2
41 error('### invalid usage'); 41 error('### invalid usage');
42 end 42 end
43 43
44 % connection 44 % connection
45 conn = varargin{1};
46 varargin = varargin(2:end);
47 if ~isa(conn, 'java.sql.Connection') 45 if ~isa(conn, 'java.sql.Connection')
48 error('### the first argument should be a java.sql.Connection object'); 46 error('### the first argument should be a java.sql.Connection object');
49 end 47 end
50 48
51 binary = false; 49 binary = false;
65 end 63 end
66 utils.helper.msg(msg.PROC1, 'retrieving collection %d', cid); 64 utils.helper.msg(msg.PROC1, 'retrieving collection %d', cid);
67 65
68 % get list of object IDs from the collection ID 66 % get list of object IDs from the collection ID
69 ids = utils.repository.getCollectionIDs(conn, cid); 67 ids = utils.repository.getCollectionIDs(conn, cid);
70 68
71 else 69 else
72 % IDs list 70 % IDs list
73 if isnumeric([varargin{:}]) 71 if isnumeric([varargin{:}])
74 ids = [varargin{:}]; 72 ids = [varargin{:}];
75 else 73 else
148 146
149 % check xml 147 % check xml
150 if strcmp(rows{1}(1:13), 'binary submit') 148 if strcmp(rows{1}(1:13), 'binary submit')
151 error('### object %d has binary representation only', ids(j)); 149 error('### object %d has binary representation only', ids(j));
152 end 150 end
153 151
154 % parse xml 152 % parse xml
155 stream = java.io.StringBufferInputStream(java.lang.String(rows{1})); 153 stream = java.io.StringBufferInputStream(java.lang.String(rows{1}));
156 builder = javax.xml.parsers.DocumentBuilderFactory.newInstance.newDocumentBuilder(); 154 builder = javax.xml.parsers.DocumentBuilderFactory.newInstance.newDocumentBuilder();
157 xdoc = builder.parse(stream); 155 xdoc = builder.parse(stream);
158 obj = utils.xml.xmlread(xdoc); 156 obj = utils.xml.xmlread(xdoc);
159 157