[Midas] location of an item

Patrick Reynolds patrick.reynolds at kitware.com
Sat Aug 11 16:14:58 EDT 2012


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


On Friday, August 10, 2012 at 7:45 PM, Mona Wong wrote:

> 
> Hi:
> 
> How can I programmatically in my PHP plugin get the path of a file if I have its item ID?
> 
> thanks,
> Mona
> 
> *********************************************
> Mona Wong
> Web & iPad Application Developer
> San Diego Supercomputer Center
> 
> You are the light you wish to see.
> *********************************************
> 
> 
> 
> _______________________________________________
> Midas mailing list
> Midas at public.kitware.com (mailto:Midas at public.kitware.com)
> http://public.kitware.com/cgi-bin/mailman/listinfo/midas
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/midas/attachments/20120811/ecc27c95/attachment-0001.html>


More information about the Midas mailing list