[Midas] Using pydas to identify bitstream location

BRIAN E CHAPMAN Brian.Chapman at utah.edu
Wed Oct 30 18:49:48 EDT 2013


Hello Midas World,

In 2012 Patrick posted the following code snippet to identify the location of a bitstream in the file system. Can the equivalent be done in pydas?


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


Brian E. Chapman, Ph.D.
Associate Professor
Department of Radiology
University of Utah

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/midas/attachments/20131030/37bb7d69/attachment.html>


More information about the Midas mailing list