Objects can be retrieved from the repository either by specifying an object ID or a collection ID. The LTPDA Toolbox provides the function ltpda_obj_retrieve to retrieve objects.
The retrieval process
When an object is retrieved, the following steps are taken:
- The object type for the requested ID is retrieved from the objmeta table
- A call is made to the appropriate class constructor
- The class constructor retrieves the XML string from the objs table
- The XML string is then converted into an XML Xdoc object
- The Xdoc object is then parsed to recreate the desired object
Retrieving objects
To retrieve an object, you must know its object ID. The following script shows an example of retrieving a single object:
[conn, username] = mysql_connect('130.75.117.67', 'ltpda_test');
q = ltpda_obj_retrieve(conn, 12);
close(conn);
Multiple objects can be retrieved simultaneously by giving a list of object IDs. For example
q = ltpda_obj_retrieve(conn, 1,2,3);
When multiple objects are requested, the results are returned in a cell array.
Retrieving object collections
Collections of objects can be retrieved by specifying the collection ID. The following script retrieves a collection:
[conn, username] = mysql_connect('130.75.117.67', 'ltpda_test');
q = ltpda_obj_retrieve(conn, 'Collection', 1);
close(conn);
The output is a cell array containing the objects retrieved.