Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/repo_retrieve_content.html @ 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 <p> | |
2 Objects can be retrieved from the repository either by specifying an object ID or a collection ID. The LTPDA | |
3 Toolbox provides class construtors to retrieve objects. In additon, to retrieve a collection of objects, the <tt>collection</tt> class | |
4 can be used. | |
5 </p> | |
6 <br> | |
7 <h2>The retrieval process</h2> | |
8 <p> | |
9 When an object is retrieved, the following steps are taken: | |
10 <ol> | |
11 <li>The object type for the requested ID is retrieved from the <tt>objmeta</tt> table</li> | |
12 <li>A call is made to the appropriate class constructor</li> | |
13 <li>The class constructor retrieves the XML string from the objs table</li> | |
14 <li>The XML string is then converted into an XML Xdoc object</li> | |
15 <li>The Xdoc object is then parsed to recreate the desired object</li> | |
16 </ol> | |
17 </p> | |
18 | |
19 <br> | |
20 <h2>Retrieving objects</h2> | |
21 | |
22 <p> | |
23 To retrieve an object, you must know its object ID, or the ID of the collection that contains that object. If you don't know the | |
24 class of the object, you can use the <tt>collection</tt> class as a container, as follows: | |
25 <div class="fragment"><pre> | |
26 >> a = collection(plist('hostname', 'localhost', 'database', 'ltpda_test', 'id', 1)) | |
27 | |
28 ** Connection status: | |
29 LWB: Disconnected from localhost/ltpda_test as hewitson | |
30 ---- collection 1 ---- | |
31 name: none | |
32 num objs: 1 | |
33 01: ao | New Block/tsdataNdata=[10x1], fs=1, nsecs=10, t0=1970-01-01 00:00:00.000 | |
34 description: | |
35 UUID: 9ec7a613-9442-4451-9b40-af18f4afea00 | |
36 ---------------------- | |
37 </pre></div> | |
38 </p> | |
39 <p> | |
40 If you already know the class of the object (for example, <tt>ao</tt>), you can directly call the class constructor method: | |
41 <div class="fragment"><pre> | |
42 <span class="comment">% Define the hostname and database</span> | |
43 hostname = <span class="string">'localhost'</span>; | |
44 database = <span class="string">'ltpda_test'</span>; | |
45 | |
46 <span class="comment">% Retrieve the object</span> | |
47 q = ao(plist(<span class="string">'hostname'</span>, hostname, <span class="string">'database'</span>, dbname, <span class="string">'ID'</span>, 12)); | |
48 </pre></div> | |
49 </p> | |
50 | |
51 <br> | |
52 <p> | |
53 Multiple objects can be retrieved simultaneously by giving a list of object IDs. For example | |
54 <div class="fragment"><pre> | |
55 >> a = ao(plist('hostname', 'localhost', 'database', 'ltpda_test', 'id', [1 2 3])) | |
56 </pre></div> | |
57 </p> | |
58 <br> | |
59 <h2>Retrieving object collections</h2> | |
60 <p> | |
61 Collections of objects can be retrieved by specifying the collection ID. The following script retrieves a collection: | |
62 <div class="fragment"><pre> | |
63 >> a = collection(plist('hostname', 'localhost', 'database', 'ltpda_test', 'cid', 1)) | |
64 </pre></div> | |
65 The output is a <tt>collection</tt> object containing the objects retrieved. | |
66 </p> | |
67 | |
68 <h2>Retrieving binary objects</h2> | |
69 <p>The retrieval process may be speeded up by taking advantage of the fact that the objects are stored in the databases also in binary form. | |
70 This can be achieved by using the parameter 'binary', that will build the object from the corresponding binary representation, if | |
71 stored in the database. | |
72 <div class="fragment"><pre> | |
73 <span class="comment">% Retrieve the collection</span> | |
74 q = ao(plist(<span class="string">'hostname'</span>, hostname, <span class="string">'database'</span>, dbname, <span class="string">'ID'</span>, 12, <span class="string">'binary'</span>, <span class="string">'yes'</span>)); | |
75 </pre></div> | |
76 If the binary representation is not in the database, the object will be built from the xml one. | |
77 </p> |