Objects can be retrieved from the repository either by specifying an object ID or a collection ID. The LTPDA Toolbox provides the function ltpda_uo.retrieve to retrieve objects. In additon, the constructors of each user class can be used to retrieve objects of that class.
When an object is retrieved, the following steps are taken:
To retrieve an object, you must know its object ID, or the ID of the collection that contains that object. The following script shows an example of retrieving a single object:
% Connect to a repository [conn, username] = utils.mysql.connect('130.75.117.67', 'ltpda_test'); % Retrieve the object q = ltpda_uo.retrieve(conn, 12); % Close connection close(conn);
If you already know the class of the object (for example, ao), you can do
% Retrieve the object q = ao(plist('hostname', hostname, 'database', dbname, 'ID', 12));
If you know the collection that contains the object, and the class, then you can do
% Retrieve the object q = ao(plist('hostname', hostname, 'database', dbname, 'CID', 2));
Multiple objects can be retrieved simultaneously by giving a list of object IDs. For example
q = ltpda_uo.retrieve(conn, 1,2,3);
Collections of objects can be retrieved by specifying the collection ID. The following script retrieves a collection:
% Connect to a repository [conn, username] = utils.mysql.connect('130.75.117.67', 'ltpda_test'); % Retrieve the collection q = ltpda_uo.retrieve(conn, 'Collection', 1); % Close connection close(conn);