Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@jmysql/updateObjMetadata.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function updateObjMetadata(conn, obj, objid) | |
2 % an utility to update entries for various object metadata in the | |
3 % corresponding tables. differs from insertObjMetadataV1() by | |
4 % the use of the new v3.0 database structure | |
5 % | |
6 % MUST BE KEPT IN SYNC WITH insertObjMetadata() | |
7 % | |
8 % conn - Java database connection object | |
9 % obj - object | |
10 % objid - unique ID of the object in the database | |
11 % | |
12 % VERSION: $Id: updateObjMetadata.m,v 1.7 2011/11/09 18:47:04 mauro Exp $ | |
13 % | |
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
15 | |
16 import utils.const.* | |
17 | |
18 if nargin < 3 | |
19 error('### incorrect usage'); | |
20 end | |
21 if ~isjava(conn) | |
22 error('### incorrect usage'); | |
23 end | |
24 | |
25 % class of object | |
26 cl = class(obj); | |
27 utils.helper.msg(msg.PROC2, 'making meta data entry for %s object', cl); | |
28 | |
29 switch cl | |
30 case 'ao' | |
31 | |
32 % call recursively to insert the data object info | |
33 utils.jmysql.updateObjMetadata(conn, obj.data, objid); | |
34 | |
35 % insert the AO info | |
36 stmt = conn.prepareStatement(... | |
37 'UPDATE ao SET data_type=?, description=? WHERE obj_id = ?'); | |
38 stmt.setObject(1, java.lang.String(class(obj.data))); | |
39 desc = obj.description; | |
40 if length(desc)>65535 | |
41 warning('Object description length exceeded. Truncating to 65535 characters'); | |
42 desc = desc(1:65535); | |
43 end | |
44 stmt.setObject(2, java.lang.String(desc)); | |
45 stmt.setObject(3, objid); | |
46 stmt.executeUpdate(); | |
47 stmt.close(); | |
48 | |
49 case 'cdata' | |
50 | |
51 stmt = conn.prepareStatement(... | |
52 'UPDATE cdata SET yunits=? WHERE obj_id = ?'); | |
53 stmt.setObject(1, java.lang.String(char(obj.yunits))); | |
54 stmt.setObject(2, objid); | |
55 stmt.executeUpdate(); | |
56 stmt.close(); | |
57 | |
58 case 'fsdata' | |
59 | |
60 % possible bad entries | |
61 fs = obj.fs; | |
62 if ~isfinite(fs) | |
63 fs = []; | |
64 end | |
65 | |
66 stmt = conn.prepareStatement(... | |
67 'UPDATE fsdata SET xunits=?, yunits=?, fs=? WHERE obj_id = ?'); | |
68 stmt.setObject(1, java.lang.String(char(obj.xunits))); | |
69 stmt.setObject(2, java.lang.String(char(obj.yunits))); | |
70 stmt.setObject(3, fs); | |
71 stmt.setObject(4, objid); | |
72 stmt.executeUpdate(); | |
73 stmt.close(); | |
74 | |
75 case 'tsdata' | |
76 | |
77 stmt = conn.prepareStatement(... | |
78 'UPDATE tsdata SET xunits=?, yunits=?, fs=?, t0=?, nsecs=?, toffset=? WHERE obj_id = ?'); | |
79 stmt.setObject(1, java.lang.String(char(obj.xunits))); | |
80 stmt.setObject(2, java.lang.String(char(obj.yunits))); | |
81 stmt.setObject(3, obj.fs); | |
82 stmt.setObject(4, java.lang.String(format(obj.t0 + obj.toffset/1000, 'yyyy-mm-dd HH:MM:SS', 'UTC'))); | |
83 stmt.setObject(5, obj.nsecs); | |
84 stmt.setObject(6, obj.toffset); | |
85 stmt.setObject(7, objid); | |
86 stmt.execute(); | |
87 stmt.close(); | |
88 | |
89 case 'xydata' | |
90 | |
91 stmt = conn.prepareStatement(... | |
92 'UPDATE xydata SET xunits=?, yunits=? WHERE obj_id = ?'); | |
93 stmt.setObject(1, java.lang.String(char(obj.xunits))); | |
94 stmt.setObject(2, java.lang.String(char(obj.yunits))); | |
95 stmt.setObject(3, objid); | |
96 stmt.execute(); | |
97 stmt.close(); | |
98 | |
99 case 'mfir' | |
100 | |
101 stmt = conn.prepareStatement(... | |
102 'UPDATE mfir SET in_file=?, fs=? WHERE obj_id = ?'); | |
103 stmt.setObject(1, java.lang.String(obj.infile)); | |
104 stmt.setObject(2, obj.fs); | |
105 stmt.setObject(3, objid); | |
106 stmt.execute(); | |
107 stmt.close(); | |
108 | |
109 case 'miir' | |
110 | |
111 stmt = conn.prepareStatement(... | |
112 'UPDATE miir SET in_file=?, fs=? WHERE obj_id = ?'); | |
113 stmt.setObject(1, java.lang.String(obj.infile)); | |
114 stmt.setObject(2, obj.fs); | |
115 stmt.setObject(3, objid); | |
116 stmt.execute(); | |
117 stmt.close(); | |
118 | |
119 otherwise | |
120 utils.helper.msg(msg.PROC2, 'no meta data table for %s object', cl); | |
121 | |
122 end | |
123 | |
124 end |