Grima  2018-08
Whispering into Alma's ear
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Holding Class Reference

class Holding More...

Inheritance diagram for Holding:
AlmaObjectWithMARC AlmaObject

Public Member Functions

  offsetSet ($offset, $value)
 
  offsetGet ($offset)
 
  loadFromAlma ($mms_id, $holding_id)
  populates the record from Alma More...
 
  getMmsIfNeeded ()
  populates the MMS ID if not already known More...
 
  loadFromAlmaX ($holding_id)
  populates the record from Alma - only requires holding_id More...
 
  addToAlmaBib ($mms_id)
  adds a new holding record to the specified bib More...
 
  hasItems ()
  checks whether a holding record has any items More...
 
  updateAlma ()
  update holding record in Alma More...
 
  deleteFromAlma ()
  delete the holding record from Alma More...
 
  setCallNumberFromBib ()
 
  setCallNumber ($h, $i, $ind1)
 
  moveToBib ($mms_id)
  moves the holding from one bib to another – only for empty holdings! More...
 
  getItems ()
  populate items property with Items objects ## XXX TEST More...
 
  getItemList ()
  populates itemList property from Alma More...
 
  deleteTreeFromAlma ()
  delete the holding and all of its items More...
 
- Public Member Functions inherited from AlmaObjectWithMARC
  useNormac ()
 
  addControlField ($tag, $data)
  add a data field to the MARC record using Normac More...
 
  addDataField ($tag, $indicators, $subfields)
  add a data field to the MARC record using Normac More...
 
  normacToXML ()
  convert normac fields back to XML More...
 
  appendField ($tag, $ind1, $ind2, $subfields)
  add a field to the MARC record More...
 
  getFields ($tag)
  get fields for the given MARC tag More...
 
  getMarcFields ($tag)
  get fields for the given MARC tag More...
 
  getSubfieldValues ($tag, $code)
  get subfield value More...
 
  deleteField ($tag)
  delete all $tag fields from the MARC record More...
 
  deleteSubfieldMatching ($tag, $code, $regex)
  delete subfields matching a regex More...
 
  replaceOrAddSubfield ($tag, $code, $value)
  replace or add subfield value in marc More...
 
- Public Member Functions inherited from AlmaObject
  __construct ()
  create new blank Alma Object More...
 
  offsetExists ($offset)
 
  offsetGet ($offset)
 
  offsetSet ($offset, $value)
 
  offsetUnset ($offset)
 

Static Public Member Functions

static  getMmsFromHoldingID ($holding_id)
  populates the MMS ID More...
 

Public Attributes

  $itemList
 
  $items = array()
 
  $xml
 
  $el_address
 
- Public Attributes inherited from AlmaObjectWithMARC
  $marc
 
- Public Attributes inherited from AlmaObject
  $el_access = array()
 
  $xml
 
  $templateDir = __DIR__ . "/templates"
 

Detailed Description

class Holding

Definition at line 2579 of file grima-lib.php.

Member Function Documentation

◆ addToAlmaBib()

Holding::addToAlmaBib (   $mms_id )

adds a new holding record to the specified bib

Parameters
string $mms_id bib record to add the holdings record

Definition at line 2710 of file grima-lib.php.

References $grima.

2710  {
2711  global $grima;
2712  $this->xml = $grima->postHolding($mms_id,$this->xml);
2713  $this['mms_id'] = $mms_id;
2714  }
$grima
Definition: grima-lib.php:4293

◆ deleteFromAlma()

Holding::deleteFromAlma ( )

delete the holding record from Alma

Definition at line 2742 of file grima-lib.php.

References $grima.

2742  {
2743  global $grima;
2744  $grima->deleteHolding($this['mms_id'],$this['holding_id']);
2745  }
$grima
Definition: grima-lib.php:4293

◆ deleteTreeFromAlma()

Holding::deleteTreeFromAlma ( )

delete the holding and all of its items

Definition at line 2830 of file grima-lib.php.

References $grima, and Grima\getItemList().

2830  {
2831  global $grima;
2832  $this->getItemList();
2833  foreach ($this->itemList->items as $item) {
2834  $item->deleteFromAlma("true");
2835  }
2836  $this->deleteFromAlma();
2837  }
getItemList()
populates itemList property from Alma
Definition: grima-lib.php:2819
deleteFromAlma()
delete the holding record from Alma
Definition: grima-lib.php:2742
$grima
Definition: grima-lib.php:4293

◆ getItemList()

Holding::getItemList ( )

populates itemList property from Alma

Definition at line 2819 of file grima-lib.php.

References $grima.

2819  {
2820  global $grima;
2821  $this->getMmsIfNeeded();
2822  $this->itemList = new ItemList($this['mms_id'],$this['holding_id']);
2823  }
$grima
Definition: grima-lib.php:4293
getMmsIfNeeded()
populates the MMS ID if not already known
Definition: grima-lib.php:2680
class ItemList
Definition: grima-lib.php:2537

◆ getItems()

Holding::getItems ( )

populate items property with Items objects ## XXX TEST

Definition at line 2808 of file grima-lib.php.

References Grima\getItemList().

2808  {
2809  $this->getItemList();
2810  $this->items =& $this->itemList->items;
2811  return $this->items;
2812  }
getItemList()
populates itemList property from Alma
Definition: grima-lib.php:2819
$items
Definition: grima-lib.php:2581

◆ getMmsFromHoldingID()

static Holding::getMmsFromHoldingID (   $holding_id )
static

populates the MMS ID

Definition at line 2653 of file grima-lib.php.

References $grima.

Referenced by getMmsIfNeeded(), and loadFromAlmaX().

2653  {
2654  global $grima;
2655 
2656  $report = new AnalyticsReport();
2657  # $report->path = "/shared/UK Libraries- University of Kentucky (UKY)/Reports/Kathryn/HoldingToMMS";
2658  $report->path = "/shared/Community/Reports/Institutions/University of Kentucky/Kathryn/HoldingToMMS";
2659  $report->filter = '
2660 <sawx:expr xsi:type="sawx:comparison" op="equal" xmlns:saw="com.siebel.analytics.web/report/v1.1"
2661 xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2662 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2663  <sawx:expr xsi:type="sawx:sqlExpression">"Holding Details"."Holding Id"</sawx:expr><sawx:expr xsi:type="xsd:string">{holding_id}</sawx:expr>
2664 </sawx:expr>';
2665 
2666  $report->runReport(array('holding_id' => $holding_id), 1);
2667  if (count($report->rows) == 1) {
2668  return $report->rows[0][1];
2669  } else {
2670  throw new Exception("No MMS for Holding ID $holding_id");
2671  }
2672  }
$grima
Definition: grima-lib.php:4293
class AnalyticsReport
Definition: grima-lib.php:3824

◆ getMmsIfNeeded()

Holding::getMmsIfNeeded ( )

populates the MMS ID if not already known

Definition at line 2680 of file grima-lib.php.

References $grima, and getMmsFromHoldingID().

2680  {
2681  global $grima;
2682 
2683  if (!isset($this['mms_id']) or (!$this['mms_id'])) {
2684  $this['mms_id'] = Holding::getMmsFromHoldingID($this['holding_id']);
2685  }
2686  }
$grima
Definition: grima-lib.php:4293
static getMmsFromHoldingID($holding_id)
populates the MMS ID
Definition: grima-lib.php:2653

◆ hasItems()

Holding::hasItems ( )

checks whether a holding record has any items

Definition at line 2722 of file grima-lib.php.

References Grima\getItemList(), and test().

2722  {
2723  $this->getItemList();
2724  return (sizeof($this->itemList->items) > 0); # XXX test
2725  }
getItemList()
populates itemList property from Alma
Definition: grima-lib.php:2819
test()
Definition: grima-xmlbag.php:192

◆ loadFromAlma()

Holding::loadFromAlma (   $mms_id,
  $holding_id 
)

populates the record from Alma

Parameters
$mms_id MMS ID of bib record
$holding_id Holding ID of holding

Definition at line 2641 of file grima-lib.php.

References $grima.

2641  {
2642  global $grima;
2643  $this->xml = $grima->getHolding($mms_id,$holding_id);
2644  $this['mms_id'] = $mms_id;
2645  }
$grima
Definition: grima-lib.php:4293

◆ loadFromAlmaX()

Holding::loadFromAlmaX (   $holding_id )

populates the record from Alma - only requires holding_id

Parameters
$holding_id Holding ID of holding

Definition at line 2695 of file grima-lib.php.

References $grima, and getMmsFromHoldingID().

2695  {
2696  global $grima;
2697 
2698  $mms_id = Holding::getMmsFromHoldingID($holding_id);
2699  $this->xml = $grima->getHolding($mms_id,$holding_id);
2700  $this['mms_id'] = $mms_id;
2701  }
$grima
Definition: grima-lib.php:4293
static getMmsFromHoldingID($holding_id)
populates the MMS ID
Definition: grima-lib.php:2653

◆ moveToBib()

Holding::moveToBib (   $mms_id )

moves the holding from one bib to another – only for empty holdings!

Definition at line 2798 of file grima-lib.php.

2798  {
2799  $this->deleteFromAlma();
2800  $this->addToAlmaBib($mms_id);
2801  }
addToAlmaBib($mms_id)
adds a new holding record to the specified bib
Definition: grima-lib.php:2710
deleteFromAlma()
delete the holding record from Alma
Definition: grima-lib.php:2742

◆ offsetGet()

Holding::offsetGet (   $offset )

Definition at line 2592 of file grima-lib.php.

2592  { #XXX TEST
2593  if ($offset == "library") {
2594  $lib = new Library();
2595  $lib->loadFromAlma($this['library_code']);
2596  return $lib['name'];
2597  }
2598  if ($offset == "location") {
2599  $loc = new Location();
2600  $loc->loadFromAlma($this['library_code'],$this['location_code']);
2601  return $loc['name'];
2602  }
2603  if ($offset == "call_number") {
2604  $Hs = $this->getSubfieldValues("852","h");
2605  $Is = $this->getSubfieldValues("852","i");
2606  $acc = "";
2607  foreach ($Hs as $h) {
2608  $acc .= "$h ";
2609  }
2610  foreach ($Is as $i) {
2611  $acc .= "$i ";
2612  }
2613  return rtrim($acc);
2614  }
2615  return parent::offsetGet($offset);
2616  }
class Library
Definition: grima-lib.php:3572
getSubfieldValues($tag, $code)
get subfield value
Definition: grima-lib.php:2073
class Location
Definition: grima-lib.php:3722

◆ offsetSet()

Holding::offsetSet (   $offset,
  $value 
)

Definition at line 2584 of file grima-lib.php.

2584  {
2585  if ($offset == "mms_id") {
2586  $this->el_override['mms_id'] = $value;
2587  } else {
2588  parent::offsetSet($offset,$value);
2589  }
2590  }

◆ setCallNumber()

Holding::setCallNumber (   $h,
  $i,
  $ind1 
)

Definition at line 2774 of file grima-lib.php.

References appendInnerXML().

2774  {
2775  $xpath = new DomXpath($this->xml);
2776  $xpath->query("//record/datafield[@tag='852']")->item(0)->setAttribute("ind1",$ind1);
2777 
2778  $field852 = $xpath->query("//record/datafield[@tag='852']")->item(0);
2779  $subfieldHs = $xpath->query("subfield[@code='h']",$field852);
2780  foreach ($subfieldHs as $subfieldH) {
2781  $subfieldH->parentNode->removeChild($subfieldH);
2782  }
2783  $subfieldIs = $xpath->query("subfield[@code='i']",$field852);
2784  foreach ($subfieldIs as $subfieldI) {
2785  $subfieldI->parentNode->removeChild($subfieldI);
2786  }
2787 
2788  appendInnerXML($field852,"<subfield code=\"h\">$h</subfield>");
2789  if ($i) {
2790  appendInnerXML($field852,"<subfield code=\"i\">$i</subfield>");
2791  }
2792  }
appendInnerXML( $elt, $xmlString)
Definition: grima-util.php:20

◆ setCallNumberFromBib()

Holding::setCallNumberFromBib ( )

Definition at line 2750 of file grima-lib.php.

2750  {
2751  # must have mms_id set? confirm
2752  # must have shelving set? confirm
2753 
2754  $bib = new Bib();
2755  $bib->loadFromAlma(); # link?
2756 
2757  switch($this["shelving_scheme"]) {
2758  case '0': # Library of Congress
2759  $fields = $bib->getFields("090");
2760  foreach ($fields as $field) {
2761  $subfields = $field->getSubfields("a");
2762  print $field["ind1"];
2763  $field["ind1"] = "4";
2764  foreach ($subfields as $subfield) {
2765  print $subfield["value"];
2766  $subfield["value"] = "joe";
2767  }
2768  }
2769  break;
2770  }
2771 
2772  }
Definition: grima-lib.php:2159
class Library
Definition: grima-lib.php:3572

◆ updateAlma()

Holding::updateAlma ( )

update holding record in Alma

Definition at line 2732 of file grima-lib.php.

References $grima.

2732  {
2733  global $grima;
2734  $grima->putHolding($this['mms_id'],$this['holding_id'],$this->xml);
2735  }
$grima
Definition: grima-lib.php:4293

Member Data Documentation

◆ $el_address

Holding::$el_address
Initial value:
= array(
'holding_id' => '//holding_id',
'inst_code' => "/holding/record/datafield[@tag='852']/subfield[@code='a']",
'library_code' => "/holding/record/datafield[@tag='852']/subfield[@code='b']",
'location_code' => "/holding/record/datafield[@tag='852']/subfield[@code='c']",
'classification_part' => "/holding/record/datafield[@tag='852']/subfield[@code='h']",
'852h' => "/holding/record/datafield[@tag='852']/subfield[@code='h']",
'item_part' => "/holding/record/datafield[@tag='852']/subfield[@code='i']",
'852i' => "/holding/record/datafield[@tag='852']/subfield[@code='i']",
'shelving_scheme' => "/holding/record/datafield[@tag='852']/@ind1",
)

Definition at line 2619 of file grima-lib.php.

◆ $itemList

Holding::$itemList

Definition at line 2580 of file grima-lib.php.

◆ $items

Holding::$items = array()

Definition at line 2581 of file grima-lib.php.

◆ $xml

Holding::$xml

Definition at line 2582 of file grima-lib.php.


The documentation for this class was generated from the following file: