[Midas] location of an item
Mona Wong
mona at sdsc.edu
Thu Aug 16 20:18:26 EDT 2012
Just to make sure I understand...
I just did a test where I uploaded a new revision for a text file and in the web interface, under "HISTORY", it lists revision 2 (latest copy) on top and then revision (earlier copy) at the bottom. I assume this always the order, latest on top?
So from what I can see:
$lastRevisionDao->getBitstreams();
will always return an array of 1 item which is the latest copy (revision #2 from my test above).
Mona
On Aug 15, 2012, at 5:33 PM, Patrick Reynolds wrote:
> It should be in order by id, that is to say the same order as in the web interface.
>
> Thanks,
> Patrick Reynolds
> Technical Leader
> Kitware, Inc.
> 919 869 8848
>
> On Wednesday, August 15, 2012 at 8:27 PM, Mona Wong wrote:
>
>> Hi Patrick:
>>
>> Thanks for the code!
>>
>> So the most recent bitstream for an item id is the last bitstream or the first bitstream in the foreach loop below?
>>
>> Mona
>>
>>
>> On Aug 11, 2012, at 1:14 PM, Patrick Reynolds wrote:
>>
>>> Mona,
>>>
>>> First, a bit about how items correspond to files. Items are made up of revisions. Most items contain one revision (the head or latest revision). Within each revision are bitstreams. These bitstreams are analogous to the files on the file system. With all that in mind, the following code should get you what you want (I'm going to assume the item ID is in a variable called, appropriately, $itemId.):
>>>
>>> // Load our models
>>> $ItemModel = MidasLoader::loadModel('Item');
>>> $ItemRevisionModel = MidasLoader::loadModel('ItemRevision');
>>> $BitstreamModel = MidasLoader::loadModel('Bitstream');
>>>
>>> // Get the item and its last revision from the time id
>>> $itemDao = $ItemModel->load($itemId);
>>> $lastRevisionDao = $ItemModel->getLastRevision($itemDao);
>>>
>>> // loop through the bitstreams and print their paths
>>> foreach($lastRevisionDao->getBitstreams() as $bitstreamDao)
>>> {
>>> print($bitstreamDao->getPath());
>>> }
>>>
>>> Hope that helps!
>>>
>>> Thanks,
>>> Patrick Reynolds
>>> Technical Leader
>>> Kitware, Inc.
>>> 919 869 8848
*********************************************
Mona Wong
Web & iPad Application Developer
San Diego Supercomputer Center
Believing we are in control is an
illusion that brings suffering.
*********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/midas/attachments/20120816/4b566043/attachment.html>
More information about the Midas
mailing list