Mercurial > hg > ltpda
view m-toolbox/classes/+utils/@repository/updateObjMetadata.m @ 22:b11e88004fca database-connection-manager
Update collection.fromRepository
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | e05504b18072 |
children |
line wrap: on
line source
function updateObjMetadata(conn, obj, objid) % an utility to update entries for various object metadata in the % corresponding tables. differs from insertObjMetadataV1() by % the use of the new v3.0 database structure % % MUST BE KEPT IN SYNC WITH insertObjMetadata() % % conn - Java database connection object % obj - object % objid - unique ID of the object in the database % % VERSION: $Id: updateObjMetadata.m,v 1.7 2011/11/09 18:47:04 mauro Exp $ % import utils.const.* if nargin < 3 error('### incorrect usage'); end if ~isjava(conn) error('### incorrect usage'); end % class of object cl = class(obj); utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl); switch cl case 'ao' % call recursively to insert the data object info utils.repository.updateObjMetadata(conn, obj.data, objid); % insert the AO info stmt = conn.prepareStatement(... 'UPDATE ao SET data_type=?, description=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(class(obj.data))); desc = obj.description; if length(desc)>65535 warning('Object description length exceeded. Truncating to 65535 characters'); desc = desc(1:65535); end stmt.setObject(2, java.lang.String(desc)); stmt.setObject(3, objid); stmt.executeUpdate(); stmt.close(); case 'cdata' stmt = conn.prepareStatement(... 'UPDATE cdata SET yunits=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(char(obj.yunits))); stmt.setObject(2, objid); stmt.executeUpdate(); stmt.close(); case 'fsdata' % possible bad entries fs = obj.fs; if ~isfinite(fs) fs = []; end stmt = conn.prepareStatement(... 'UPDATE fsdata SET xunits=?, yunits=?, fs=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(char(obj.xunits))); stmt.setObject(2, java.lang.String(char(obj.yunits))); stmt.setObject(3, fs); stmt.setObject(4, objid); stmt.executeUpdate(); stmt.close(); case 'tsdata' stmt = conn.prepareStatement(... 'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=?, toffset=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(char(obj.xunits))); stmt.setObject(2, java.lang.String(char(obj.yunits))); stmt.setObject(3, obj.fs); stmt.setObject(4, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC'))); stmt.setObject(5, obj.nsecs); stmt.setObject(6, obj.toffset); stmt.setObject(7, objid); stmt.execute(); stmt.close(); case 'xydata' stmt = conn.prepareStatement(... 'UPDATE xydata SET xunits=?, yunits=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(char(obj.xunits))); stmt.setObject(2, java.lang.String(char(obj.yunits))); stmt.setObject(3, objid); stmt.execute(); stmt.close(); case 'mfir' stmt = conn.prepareStatement(... 'UPDATE mfir SET in_file=?, fs=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(obj.infile)); stmt.setObject(2, obj.fs); stmt.setObject(3, objid); stmt.execute(); stmt.close(); case 'miir' stmt = conn.prepareStatement(... 'UPDATE miir SET in_file=?, fs=? WHERE obj_id = ?'); stmt.setObject(1, java.lang.String(obj.infile)); stmt.setObject(2, obj.fs); stmt.setObject(3, objid); stmt.execute(); stmt.close(); otherwise utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl); end end