Catman...Objects(3pm)

πŸ’– Catman...Objects(3pm) β€” no wait, bestie, come back, it's giving Catmandu::FedoraCommons::Model::findObjects πŸ’–

okay so this is a page from the User Contributed Perl Documentation collection, and it's a 3pm manual β€” a Perl module page. Buckle up, it's a short one but it's iconic.


✨ NAME ✨

Catmandu::FedoraCommons::Model::findObjects β€” it's a Perl model for the Fedora findObjects and resumeFindObjects REST calls. that's it, that's the whole job. she's a model. she models the REST calls. slay. πŸ’…


🌸 SYNOPSIS 🌸

okay so here's how you actually use her, no cap:

use Catmandu::FedoraCommons;

my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');

my $obj = $fedora->findObjects(terms=>'*')->parse_content;

{
  'token'  => '92b0ae4028f9459ce7cd0600f562adb2' ,
  'cursor' => 0,
  'expirationDate' => '2013-02-08T09:37:55.860Z',
  'results' => [
      {
      'pid'     => 'demo:29' ,
      'label'   => 'Data Object for Image Manipulation Demo' ,
      'state'   => 'I' ,
      'ownerId' => 'fedoraAdmin' ,
      'cDate'   => '2008-07-02T05:09:42.015Z' ,
      'mDate'   => '2013-02-07T19:57:27.140Z' ,
      'dcmDate' => '2008-07-02T05:09:43.234Z' ,
      'title'   => [ 'Coliseum in Rome' ] ,
      'creator' => [ 'Thornton Staples' ] ,
      'subject' => [ 'Architecture, Roman' ] ,
      'description' => [ 'Image of Coliseum in Rome' ] ,
      'publisher'   => [ 'University of Virginia Library' ] ,
      'format'      => [ 'image/jpeg' ] ,
      'identifier'  => [ 'demo:29' ],
      },
  ] ,
}

so like β€” you use Catmandu::FedoraCommons, you build a $fedora object with Catmandu::FedoraCommons->new(...) and you hand it the base URL 'http://localhost:8080/fedora' plus the user and password, which in the example are both 'fedoraAdmin' (not me clocking the security vibe πŸ’€).

then you call $fedora->findObjects(terms=>'*') and chain ->parse_content on the end, and boom ✨ β€” you get back a hashref. $obj is your main character now.

and look at that hashref, it's so structured:

  • 'token' β€” '92b0ae4028f9459ce7cd0600f562adb2' β€” that's your continuation token, for when you need to come back and grab more. it's also the whole reason resumeFindObjects exists, iykyk.
  • 'cursor' β€” 0 β€” where you're at in the results.
  • 'expirationDate' β€” '2013-02-08T09:37:55.860Z' β€” when that token stops being valid. she expires, she's dramatic like that.
  • 'results' β€” an arrayref of the actual objects, and each one has:
    • 'pid' β€” 'demo:29'
    • 'label' β€” 'Data Object for Image Manipulation Demo'
    • 'state' β€” 'I'
    • 'ownerId' β€” 'fedoraAdmin'
    • 'cDate' β€” '2008-07-02T05:09:42.015Z'
    • 'mDate' β€” '2013-02-07T19:57:27.140Z'
    • 'dcmDate' β€” '2008-07-02T05:09:43.234Z'
    • 'title' β€” [ 'Coliseum in Rome' ]
    • 'creator' β€” [ 'Thornton Staples' ]
    • 'subject' β€” [ 'Architecture, Roman' ]
    • 'description' β€” [ 'Image of Coliseum in Rome' ]
    • 'publisher' β€” [ 'University of Virginia Library' ]
    • 'format' β€” [ 'image/jpeg' ]
    • 'identifier' β€” [ 'demo:29' ]

notice how title, creator, subject, description, publisher, format and identifier are all arrayrefs β€” like, multiple values per field, because metadata said "why have one when you can have a list" πŸ’…. and the single-value-ish ones (pid, label, state, ownerId, cDate, mDate, dcmDate) are just plain scalars. also not me noticing 'demo:29' showing up twice β€” once as pid and once inside identifier. consistent queen. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹

  • Catmandu::FedoraCommons β€” go read that one too, she's the parent vibe, the blueprint, the blueprint. 🫢

πŸŽ€ the sign-off πŸŽ€

and that's the whole page, bestie! this little beauty lives in perl v5.36.0 and she was last touched on 2023-02-05 β€” shoutout to the User Contributed Perl Documentation crew for keeping her on the shelf. now go query some Fedora repos and thrive. πŸŒˆβ­πŸ’œ

periodt.

πŸ“¦ where this page comes from