changeset 13:e05504b18072 database-connection-manager

Move more functions to utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents 86aabb42dd84
children 6d43f39633b8
files m-toolbox/classes/+utils/@jmysql/insertObjMetadata.m m-toolbox/classes/+utils/@jmysql/insertObjMetadataV1.m m-toolbox/classes/+utils/@jmysql/updateObjMetadata.m m-toolbox/classes/+utils/@jmysql/updateObjMetadataV1.m m-toolbox/classes/+utils/@repository/insertObjMetadata.m m-toolbox/classes/+utils/@repository/insertObjMetadataV1.m m-toolbox/classes/+utils/@repository/repository.m m-toolbox/classes/+utils/@repository/updateObjMetadata.m m-toolbox/classes/+utils/@repository/updateObjMetadataV1.m
diffstat 9 files changed, 532 insertions(+), 528 deletions(-) [+]
line wrap: on
line diff
--- a/m-toolbox/classes/+utils/@jmysql/insertObjMetadata.m	Mon Dec 05 16:20:06 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-function insertObjMetadata(conn, obj, objid)
-  % an utility to insert 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 updateObjMetadata()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-  % VERSION:     $Id: insertObjMetadata.m,v 1.9 2011/11/09 18:45:14 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.jmysql.insertObjMetadata(conn, obj.data, objid);
-
-      % insert the AO info
-      stmt = conn.prepareStatement(...
-        'INSERT INTO ao (obj_id, data_type, description) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, 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(3, java.lang.String(desc));
-      stmt.execute();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO cdata (obj_id, yunits) VALUES (?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.execute();
-      stmt.close();
-
-    case 'fsdata'
-
-      % possible bad entries
-      fs = obj.fs;
-      if ~isfinite(fs)
-        fs = [];
-      end
-        
-      stmt = conn.prepareStatement(...
-        'INSERT INTO fsdata (obj_id, xunits, yunits, fs) VALUES (?, ?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.xunits)));
-      stmt.setObject(3, java.lang.String(char(obj.yunits)));
-      stmt.setObject(4, fs);
-      stmt.execute();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO tsdata (obj_id, xunits, yunits, fs, t0, nsecs, toffset) VALUES (?, ?, ?, ?, ?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.xunits)));
-      stmt.setObject(3, java.lang.String(char(obj.yunits)));
-      stmt.setObject(4, obj.fs);
-      stmt.setObject(5, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
-      stmt.setObject(6, obj.nsecs);
-      stmt.setObject(7, obj.toffset);
-      stmt.execute();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO xydata (obj_id, xunits, yunits) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(char(obj.xunits)));
-      stmt.setObject(3, java.lang.String(char(obj.yunits)));
-      stmt.execute();
-      stmt.close();
-
-    case 'mfir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    case 'miir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    otherwise
-      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
-
-  end
-
-end
--- a/m-toolbox/classes/+utils/@jmysql/insertObjMetadataV1.m	Mon Dec 05 16:20:06 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +0,0 @@
-function id = insertObjMetadataV1(conn, obj, objid)
-  % an utility to insert entries for various object metadata in the
-  % corresponding tables. uses the old v2.1 database schema.
-  %
-  % MUST BE KEPT IN SYNC WITH updateObjMetadataV1()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-
-  import utils.const.*
-
-  if nargin < 3
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### incorrect usage');
-  end
-
-  % default output value
-  id = [];
-
-  % 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
-      dataid = utils.jmysql.insertObjMetadataV1(conn, obj.data, objid);
-
-      % insert the AO info
-      stmt = conn.prepareStatement(...
-        'INSERT INTO ao (obj_id, data_type, data_id, description) VALUES (?, ?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(class(obj.data)));
-      stmt.setObject(3, dataid);
-      desc = obj.description;
-      if length(desc)>65535
-        warning('Object description length exceeded. Truncating to 65535 characters');
-        desc = desc(1:65535);
-      end
-      stmt.setObject(4, java.lang.String(desc));
-      stmt.execute();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO cdata (yunits) VALUES (?)');
-      stmt.setObject(1, java.lang.String(char(obj.yunits)));
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'fsdata'
-
-      % possible bad entries
-      fs = obj.fs;
-      if ~isfinite(fs)
-        fs = [];
-      end
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO fsdata (xunits, yunits, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.setObject(3, fs);
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO tsdata (xunits, yunits, fs, t0, nsecs) VALUES (?, ?, ?, ?, ?)');
-      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, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
-      stmt.setObject(5, obj.nsecs);
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO xydata (xunits, yunits) VALUES (?, ?)');
-      stmt.setObject(1, java.lang.String(char(obj.xunits)));
-      stmt.setObject(2, java.lang.String(char(obj.yunits)));
-      stmt.executeUpdate();
-
-      % obtain generated data id
-      rs = stmt.getGeneratedKeys();
-      rs.next();
-      id = rs.getInt(1);
-      rs.close();
-      stmt.close();
-
-    case 'mfir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    case 'miir'
-
-      stmt = conn.prepareStatement(...
-        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
-      stmt.setObject(1, objid);
-      stmt.setObject(2, java.lang.String(obj.infile));
-      stmt.setObject(3, obj.fs);
-      stmt.execute();
-      stmt.close();
-
-    otherwise
-      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
-
-  end
-end
--- a/m-toolbox/classes/+utils/@jmysql/updateObjMetadata.m	Mon Dec 05 16:20:06 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-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.jmysql.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
--- a/m-toolbox/classes/+utils/@jmysql/updateObjMetadataV1.m	Mon Dec 05 16:20:06 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-function id = updateObjMetadataV1(conn, obj, objid)
-  % an utility to update entries for various object metadata in the
-  % corresponding tables. uses the old v2.1 database schema.
-  %
-  % MUST BE KEPT IN SYNC WITH insertObjMetadataV1()
-  %
-  % conn   - Java database connection object
-  % obj    - object
-  % objid  - unique ID of the object in the database
-  %
-
-  import utils.const.*
-
-  if nargin < 3
-    error('### incorrect usage');
-  end
-  if ~isjava(conn)
-    error('### incorrect usage');
-  end
-
-  % default return value
-  id = [];
-  
-  % class of object
-  cl = class(obj);
-  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
-
-  switch cl
-    case 'ao'
-
-      % get data type and id
-      stmt = conn.prepareStatement(...
-        'SELECT data_id, data_type FROM ao WHERE obj_id = ?');
-      stmt.setObject(1, objid);
-      rs = stmt.executeQuery();
-      rs.next();
-      dataid = rs.getInt(1);
-      datatype = rs.getString(2);
-      rs.close();
-      stmt.close();
-      
-      % check if the data type is consistent
-      if ~strcmp(datatype, class(obj.data))
-        error('### cannot update an object with one having a different data type');
-      end
-        
-      % call recursively to insert the data object info
-      id = utils.jmysql.updateObjMetadataV1(conn, obj.data, dataid);
-
-      % update ao description
-      stmt = conn.prepareStatement(...
-        'UPDATE ao SET description=? WHERE obj_id = ?');
-      desc = obj.description;
-      if length(desc)>65535
-        warning('Object description length exceeded. Truncating to 65535 characters');
-        desc = desc(1:65535);
-      end
-      stmt.setObject(1, desc);
-      stmt.setObject(2, objid);
-      stmt.execute();
-      stmt.close();
-
-    case 'cdata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE cdata SET yunits=? WHERE id = ?');
-      stmt.setObject(1, char(obj.yunits));
-      stmt.setObject(2, objid);
-      stmt.execute();
-      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 id = ?');
-      stmt.setObject(1, char(obj.xunits));
-      stmt.setObject(2, char(obj.yunits));
-      stmt.setObject(3, fs);
-      stmt.setObject(4, objid);      
-      stmt.execute();
-      stmt.close();
-
-    case 'tsdata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=? WHERE id = ?');
-      stmt.setObject(1, char(obj.xunits));
-      stmt.setObject(2, char(obj.yunits));
-      stmt.setObject(3, obj.fs);
-      stmt.setObject(4, format(obj.t0, 'yyyy-mm-dd HH:MM:SS', 'UTC'));
-      stmt.setObject(5, obj.nsecs);
-      stmt.setObject(6, objid);      
-      stmt.execute();
-      stmt.close();
-
-    case 'xydata'
-
-      stmt = conn.prepareStatement(...
-        'UPDATE xydata SET xunits=?, yunits=? WHERE id = ?');
-      stmt.setObject(1, char(obj.xunits));
-      stmt.setObject(2, 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, 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, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/insertObjMetadata.m	Mon Dec 05 16:20:06 2011 +0100
@@ -0,0 +1,124 @@
+function insertObjMetadata(conn, obj, objid)
+% an utility to insert 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 updateObjMetadata()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+% VERSION:     $Id: insertObjMetadata.m,v 1.9 2011/11/09 18:45:14 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.insertObjMetadata(conn, obj.data, objid);
+
+      % insert the AO info
+      stmt = conn.prepareStatement(...
+        'INSERT INTO ao (obj_id, data_type, description) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, 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(3, java.lang.String(desc));
+      stmt.execute();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO cdata (obj_id, yunits) VALUES (?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.execute();
+      stmt.close();
+
+    case 'fsdata'
+
+      % possible bad entries
+      fs = obj.fs;
+      if ~isfinite(fs)
+        fs = [];
+      end
+        
+      stmt = conn.prepareStatement(...
+        'INSERT INTO fsdata (obj_id, xunits, yunits, fs) VALUES (?, ?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.xunits)));
+      stmt.setObject(3, java.lang.String(char(obj.yunits)));
+      stmt.setObject(4, fs);
+      stmt.execute();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO tsdata (obj_id, xunits, yunits, fs, t0, nsecs, toffset) VALUES (?, ?, ?, ?, ?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.xunits)));
+      stmt.setObject(3, java.lang.String(char(obj.yunits)));
+      stmt.setObject(4, obj.fs);
+      stmt.setObject(5, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
+      stmt.setObject(6, obj.nsecs);
+      stmt.setObject(7, obj.toffset);
+      stmt.execute();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO xydata (obj_id, xunits, yunits) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(char(obj.xunits)));
+      stmt.setObject(3, java.lang.String(char(obj.yunits)));
+      stmt.execute();
+      stmt.close();
+
+    case 'mfir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    case 'miir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    otherwise
+      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
+
+  end
+
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/insertObjMetadataV1.m	Mon Dec 05 16:20:06 2011 +0100
@@ -0,0 +1,142 @@
+function id = insertObjMetadataV1(conn, obj, objid)
+% an utility to insert entries for various object metadata in the
+% corresponding tables. uses the old v2.1 database schema.
+%
+% MUST BE KEPT IN SYNC WITH updateObjMetadataV1()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+
+  import utils.const.*
+
+  if nargin < 3
+    error('### incorrect usage');
+  end
+  if ~isjava(conn)
+    error('### incorrect usage');
+  end
+
+  % default output value
+  id = [];
+
+  % 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
+      dataid = utils.repository.insertObjMetadataV1(conn, obj.data, objid);
+
+      % insert the AO info
+      stmt = conn.prepareStatement(...
+        'INSERT INTO ao (obj_id, data_type, data_id, description) VALUES (?, ?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(class(obj.data)));
+      stmt.setObject(3, dataid);
+      desc = obj.description;
+      if length(desc)>65535
+        warning('Object description length exceeded. Truncating to 65535 characters');
+        desc = desc(1:65535);
+      end
+      stmt.setObject(4, java.lang.String(desc));
+      stmt.execute();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO cdata (yunits) VALUES (?)');
+      stmt.setObject(1, java.lang.String(char(obj.yunits)));
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'fsdata'
+
+      % possible bad entries
+      fs = obj.fs;
+      if ~isfinite(fs)
+        fs = [];
+      end
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO fsdata (xunits, yunits, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.setObject(3, fs);
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO tsdata (xunits, yunits, fs, t0, nsecs) VALUES (?, ?, ?, ?, ?)');
+      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, 'yyyy-mm-dd HH:MM:SS', 'UTC')));
+      stmt.setObject(5, obj.nsecs);
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO xydata (xunits, yunits) VALUES (?, ?)');
+      stmt.setObject(1, java.lang.String(char(obj.xunits)));
+      stmt.setObject(2, java.lang.String(char(obj.yunits)));
+      stmt.executeUpdate();
+
+      % obtain generated data id
+      rs = stmt.getGeneratedKeys();
+      rs.next();
+      id = rs.getInt(1);
+      rs.close();
+      stmt.close();
+
+    case 'mfir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO mfir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    case 'miir'
+
+      stmt = conn.prepareStatement(...
+        'INSERT INTO miir (obj_id, in_file, fs) VALUES (?, ?, ?)');
+      stmt.setObject(1, objid);
+      stmt.setObject(2, java.lang.String(obj.infile));
+      stmt.setObject(3, obj.fs);
+      stmt.execute();
+      stmt.close();
+
+    otherwise
+      utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl);
+
+  end
+end
--- a/m-toolbox/classes/+utils/@repository/repository.m	Mon Dec 05 16:20:06 2011 +0100
+++ b/m-toolbox/classes/+utils/@repository/repository.m	Mon Dec 05 16:20:06 2011 +0100
@@ -6,6 +6,12 @@
     ids = getCollectionIDs(conn, cid);
     varargout = getUser(conn);
 
+    varargout = insertObjMetadata(varargin);
+    varargout = insertObjMetadataV1(varargin);
+
+    varargout = updateObjMetadata(varargin);
+    varargout = updateObjMetadataV1(varargin);
+
   end % static methods
 
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/updateObjMetadata.m	Mon Dec 05 16:20:06 2011 +0100
@@ -0,0 +1,123 @@
+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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@repository/updateObjMetadataV1.m	Mon Dec 05 16:20:06 2011 +0100
@@ -0,0 +1,137 @@
+function id = updateObjMetadataV1(conn, obj, objid)
+% an utility to update entries for various object metadata in the
+% corresponding tables. uses the old v2.1 database schema.
+%
+% MUST BE KEPT IN SYNC WITH insertObjMetadataV1()
+%
+% conn   - Java database connection object
+% obj    - object
+% objid  - unique ID of the object in the database
+%
+
+  import utils.const.*
+
+  if nargin < 3
+    error('### incorrect usage');
+  end
+  if ~isjava(conn)
+    error('### incorrect usage');
+  end
+
+  % default return value
+  id = [];
+  
+  % class of object
+  cl = class(obj);
+  utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl);
+
+  switch cl
+    case 'ao'
+
+      % get data type and id
+      stmt = conn.prepareStatement(...
+        'SELECT data_id, data_type FROM ao WHERE obj_id = ?');
+      stmt.setObject(1, objid);
+      rs = stmt.executeQuery();
+      rs.next();
+      dataid = rs.getInt(1);
+      datatype = rs.getString(2);
+      rs.close();
+      stmt.close();
+      
+      % check if the data type is consistent
+      if ~strcmp(datatype, class(obj.data))
+        error('### cannot update an object with one having a different data type');
+      end
+        
+      % call recursively to insert the data object info
+      id = utils.repository.updateObjMetadataV1(conn, obj.data, dataid);
+
+      % update ao description
+      stmt = conn.prepareStatement(...
+        'UPDATE ao SET description=? WHERE obj_id = ?');
+      desc = obj.description;
+      if length(desc)>65535
+        warning('Object description length exceeded. Truncating to 65535 characters');
+        desc = desc(1:65535);
+      end
+      stmt.setObject(1, desc);
+      stmt.setObject(2, objid);
+      stmt.execute();
+      stmt.close();
+
+    case 'cdata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE cdata SET yunits=? WHERE id = ?');
+      stmt.setObject(1, char(obj.yunits));
+      stmt.setObject(2, objid);
+      stmt.execute();
+      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 id = ?');
+      stmt.setObject(1, char(obj.xunits));
+      stmt.setObject(2, char(obj.yunits));
+      stmt.setObject(3, fs);
+      stmt.setObject(4, objid);      
+      stmt.execute();
+      stmt.close();
+
+    case 'tsdata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=? WHERE id = ?');
+      stmt.setObject(1, char(obj.xunits));
+      stmt.setObject(2, char(obj.yunits));
+      stmt.setObject(3, obj.fs);
+      stmt.setObject(4, format(obj.t0, 'yyyy-mm-dd HH:MM:SS', 'UTC'));
+      stmt.setObject(5, obj.nsecs);
+      stmt.setObject(6, objid);      
+      stmt.execute();
+      stmt.close();
+
+    case 'xydata'
+
+      stmt = conn.prepareStatement(...
+        'UPDATE xydata SET xunits=?, yunits=? WHERE id = ?');
+      stmt.setObject(1, char(obj.xunits));
+      stmt.setObject(2, 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, 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, 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