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...
 
  getMethodOfAcquisition ()
  retrieves method of acquisition, fixed field 008/07 https://www.loc.gov/marc/holdings/hd008.html More...
 
  setMethodOfAcquisition ($code)
  sets method of acquisition, fixed field 008/07 https://www.loc.gov/marc/holdings/hd008.html More...
 
  getInstitutionCode ()
  retrieves institution code from 852a More...
 
  setInstitutionCode ($code)
  sets institution code from 852a More...
 
  getLibraryCode ()
  retrieves library code from 852b More...
 
  setLibraryCode ($code)
  sets library code from 852b More...
 
  getLocationCode ()
  retrieves location code from 852c More...
 
  setLocationCode ($code)
  sets location code from 852c More...
 
  setCallNumberType ($ind1) # upgrade to normac
 
  setCallNumber ($h, $i, $ind1) # upgrade to normac
 
  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...
 
  deleteSubfieldMatching ($tag, $code, $regex)
  delete subfields matching a regex More...
 
  deleteFieldMatching ($tag, $code, $regex)
  delete fields with subfields matching a regex 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) ## XXX
  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...
 
  deleteFieldMatching ($tag, $code, $regex)
  delete fields with subfields matching a regex More...
 
  replaceOrAddSubfield ($tag, $code, $value) ## XXX
  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 3033 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 3187 of file grima-lib.php.

3188 {
3189 global $grima;
3190 $this->normacToXML();
3191 $this->xml = $grima->postHolding($mms_id, $this->xml);
3192 $this['mms_id'] = $mms_id;
3193 }
normacToXML()
convert normac fields back to XML
Definition: grima-lib.php:2307
$grima
Definition: grima-lib.php:5143

References $grima, and AlmaObjectWithMARC\normacToXML().

Referenced by moveToBib().

◆ deleteFieldMatching()

Holding::deleteFieldMatching (   $tag,
  $code,
  $regex 
)

delete fields with subfields matching a regex

For example, delete all 856 fields with $u that contain "ezproxy" case insensitively, like: $this->deleteFieldMatching("856","u","/ezproxy/i");

Parameters
string $tag a three character MARC tag
string $code a subfield code
string $regex a regular expression

Reimplemented from AlmaObjectWithMARC.

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

3478 {
3479 $this->useNormac();
3480 foreach ($this->getFields($tag) as $field) {
3481 foreach ($field->getSubfields($code) as $subfield) {
3482 if (preg_match($regex,$subfield->data)) {
3483 $field->delete();
3484 break;
3485 }
3486 }
3487 }
3488 }
getFields($tag)
get fields for the given MARC tag
Definition: grima-lib.php:2369

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ deleteFromAlma()

Holding::deleteFromAlma ( )

delete the holding record from Alma

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

3225 {
3226 global $grima;
3227 $grima->deleteHolding($this['mms_id'], $this['holding_id']);
3228 }

References $grima.

Referenced by deleteTreeFromAlma(), and moveToBib().

◆ deleteSubfieldMatching()

Holding::deleteSubfieldMatching (   $tag,
  $code,
  $regex 
)

delete subfields matching a regex

For example, delete all subfield $z in an 856 that contain "click" case insensitively, like: $this->deleteSubfieldMatching("856","z","/click/i");

Parameters
string $tag a three character MARC tag
string $code a subfield code
string $regex a regular expression

Reimplemented from AlmaObjectWithMARC.

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

3453 {
3454 $this->useNormac();
3455 foreach ($this->getFields($tag) as $field) {
3456 foreach ($field->getSubfields($code) as $subfield) {
3457 if (preg_match($regex,$subfield->data)) {
3458 $subfield->delete();
3459 }
3460 }
3461 }
3462 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ deleteTreeFromAlma()

Holding::deleteTreeFromAlma ( )

delete the holding and all of its items

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

3430 {
3431 global $grima;
3432 $this->getItemList();
3433 foreach ($this->itemList->items as $item) {
3434 $item->deleteFromAlma("true");
3435 }
3436 $this->deleteFromAlma();
3437 }
deleteFromAlma()
delete the holding record from Alma
Definition: grima-lib.php:3224
getItemList()
populates itemList property from Alma
Definition: grima-lib.php:3417

References $grima, deleteFromAlma(), and getItemList().

◆ getInstitutionCode()

Holding::getInstitutionCode ( )

retrieves institution code from 852a

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

3267 {
3268 $this->useNormac();
3269 return $this->getFields("852")[0]->getSubFields("a")[0]->data;
3270 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

Referenced by offsetGet().

◆ getItemList()

Holding::getItemList ( )

populates itemList property from Alma

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

3418 {
3419 global $grima;
3420 $this->getMmsIfNeeded();
3421 $this->itemList = new ItemList($this['mms_id'], $this['holding_id']);
3422 }
getMmsIfNeeded()
populates the MMS ID if not already known
Definition: grima-lib.php:3155
class ItemList
Definition: grima-lib.php:2987

References $grima, and getMmsIfNeeded().

Referenced by deleteTreeFromAlma(), getItems(), and hasItems().

◆ getItems()

Holding::getItems ( )

populate items property with Items objects ## XXX TEST

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

3406 {
3407 $this->getItemList();
3408 $this->items =& $this->itemList->items;
3409 return $this->items;
3410 }
$items
Definition: grima-lib.php:3036

References $items, and getItemList().

◆ getLibraryCode()

Holding::getLibraryCode ( )

retrieves library code from 852b

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

3293 {
3294 $this->useNormac();
3295 return $this->getFields("852")[0]->getSubFields("b")[0]->data;
3296 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

Referenced by offsetGet().

◆ getLocationCode()

Holding::getLocationCode ( )

retrieves location code from 852c

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

3319 {
3320 $this->useNormac();
3321 return $this->getFields("852")[0]->getSubFields("c")[0]->data;
3322 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

Referenced by offsetGet().

◆ getMethodOfAcquisition()

Holding::getMethodOfAcquisition ( )

retrieves method of acquisition, fixed field 008/07 https://www.loc.gov/marc/holdings/hd008.html

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

3238 {
3239 $this->useNormac();
3240 $fixed_fields = $this->getFields("008")[0];
3241 return substr($fixed_fields->data, 7, 1);
3242 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ getMmsFromHoldingID()

static Holding::getMmsFromHoldingID (   $holding_id )
static

populates the MMS ID

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

3129 {
3130 global $grima;
3131
3132 $report = new AnalyticsReport();
3133 // $report->path = "/shared/UK Libraries- University of Kentucky (UKY)/Reports/Kathryn/HoldingToMMS";
3134 $report->path = "/shared/Community/Reports/Institutions/University of Kentucky/Kathryn/HoldingToMMS";
3135 $report->filter = '
3136<sawx:expr xsi:type="sawx:comparison" op="equal" xmlns:saw="com.siebel.analytics.web/report/v1.1"
3137xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3138xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3139 <sawx:expr xsi:type="sawx:sqlExpression">"Holding Details"."Holding Id"</sawx:expr><sawx:expr xsi:type="xsd:string">{holding_id}</sawx:expr>
3140</sawx:expr>';
3141
3142 $report->runReport(array('holding_id' => $holding_id), 1);
3143 if (count($report->rows) == 1) {
3144 return $report->rows[0][1];
3145 } else {
3146 throw new Exception("No MMS for Holding ID $holding_id");
3147 }
3148 }
class AnalyticsReport
Definition: grima-lib.php:4587

References $grima.

Referenced by getMmsIfNeeded(), and loadFromAlmaX().

◆ getMmsIfNeeded()

Holding::getMmsIfNeeded ( )

populates the MMS ID if not already known

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

3156 {
3157 global $grima;
3158
3159 if (!isset($this['mms_id']) or (!$this['mms_id'])) {
3160 $this['mms_id'] = Holding::getMmsFromHoldingID($this['holding_id']);
3161 }
3162 }
static getMmsFromHoldingID($holding_id)
populates the MMS ID
Definition: grima-lib.php:3128

References $grima, and getMmsFromHoldingID().

Referenced by getItemList().

◆ hasItems()

Holding::hasItems ( )

checks whether a holding record has any items

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

3201 {
3202 $this->getItemList();
3203 return (sizeof($this->itemList->items) > 0); // XXX test
3204 }

References getItemList().

◆ 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 3116 of file grima-lib.php.

3117 {
3118 global $grima;
3119 $this->xml = $grima->getHolding($mms_id, $holding_id);
3120 $this['mms_id'] = $mms_id;
3121 }

References $grima.

◆ loadFromAlmaX()

Holding::loadFromAlmaX (   $holding_id )

populates the record from Alma - only requires holding_id

Parameters
$holding_id Holding ID of holding

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

3172 {
3173 global $grima;
3174
3175 $mms_id = Holding::getMmsFromHoldingID($holding_id);
3176 $this->xml = $grima->getHolding($mms_id, $holding_id);
3177 $this['mms_id'] = $mms_id;
3178 }

References $grima, and getMmsFromHoldingID().

◆ moveToBib()

Holding::moveToBib (   $mms_id )

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

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

3395 {
3396 $this->deleteFromAlma();
3397 $this->addToAlmaBib($mms_id);
3398 }
addToAlmaBib($mms_id)
adds a new holding record to the specified bib
Definition: grima-lib.php:3187

References addToAlmaBib(), and deleteFromAlma().

◆ offsetGet()

Holding::offsetGet (   $offset )

Reimplemented from AlmaObject.

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

3053 {
3054 // XXX TEST
3055 if ($offset == "library") {
3056 $lib = new Library();
3057 $lib->loadFromAlma($this['library_code']);
3058 return $lib['name'];
3059 }
3060 if ($offset == "location") {
3061 $loc = new Location();
3062 $loc->loadFromAlma($this['library_code'], $this['location_code']);
3063 return $loc['name'];
3064 }
3065 if ($offset == "inst_code") {
3066 return $this->getInstitutionCode();
3067 }
3068 if ($offset == "library_code") {
3069 return $this->getLibraryCode();
3070 }
3071 if ($offset == "location_code") {
3072 return $this->getLocationCode();
3073 }
3074 if ($offset == "call_number") {
3075 $Hs = $this->getSubfieldValues("852", "h");
3076 $Is = $this->getSubfieldValues("852", "i");
3077 $acc = "";
3078 foreach ($Hs as $h) {
3079 $acc .= "$h ";
3080 }
3081 foreach ($Is as $i) {
3082 $acc .= "$i ";
3083 }
3084 return rtrim($acc);
3085 }
3086 return parent::offsetGet($offset);
3087 }
getSubfieldValues($tag, $code)
get subfield value
Definition: grima-lib.php:2414
getLibraryCode()
retrieves library code from 852b
Definition: grima-lib.php:3292
getInstitutionCode()
retrieves institution code from 852a
Definition: grima-lib.php:3266
getLocationCode()
retrieves location code from 852c
Definition: grima-lib.php:3318
class Library
Definition: grima-lib.php:4316
class Location
Definition: grima-lib.php:4475

References getInstitutionCode(), getLibraryCode(), getLocationCode(), and AlmaObjectWithMARC\getSubfieldValues().

◆ offsetSet()

Holding::offsetSet (   $offset,
  $value 
)

Reimplemented from AlmaObject.

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

3040 {
3041 if ($offset == "mms_id") {
3042 $this->el_override['mms_id'] = $value;
3043 return;
3044 }
3045 if ($offset == "location_code") {
3046 $this->setLocationCode($value);
3047 return;
3048 }
3049 parent::offsetSet($offset, $value);
3050 }
setLocationCode($code)
sets location code from 852c
Definition: grima-lib.php:3331

References setLocationCode().

◆ setCallNumber()

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

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

3369 {
3370 $this->normacToXML();
3371 $xpath = new DomXpath($this->xml);
3372 $xpath->query("//record/datafield[@tag='852']")->item(0)->setAttribute("ind1", $ind1);
3373
3374 $field852 = $xpath->query("//record/datafield[@tag='852']")->item(0);
3375 $subfieldHs = $xpath->query("subfield[@code='h']", $field852);
3376 foreach ($subfieldHs as $subfieldH) {
3377 $subfieldH->parentNode->removeChild($subfieldH);
3378 }
3379 $subfieldIs = $xpath->query("subfield[@code='i']", $field852);
3380 foreach ($subfieldIs as $subfieldI) {
3381 $subfieldI->parentNode->removeChild($subfieldI);
3382 }
3383
3384 appendInnerXML($field852, "<subfield code=\"h\">$h</subfield>");
3385 if ($i) {
3386 appendInnerXML($field852, "<subfield code=\"i\">$i</subfield>");
3387 }
3388 }
appendInnerXML( $elt, $xmlString)
Definition: grima-util.php:20

References appendInnerXML(), and AlmaObjectWithMARC\normacToXML().

◆ setCallNumberType()

Holding::setCallNumberType (   $ind1 )

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

3340 {
3341 # XXX check argument
3342 $this->useNormac();
3343 $the852 = $this->getFields("852")[0];
3344 $the852->indicators[0] = $ind1;
3345
3346 /*
3347 $this->normacToXML();
3348 $xpath = new DomXpath($this->xml);
3349 $xpath->query("//record/datafield[@tag='852']")->item(0)->setAttribute("ind1", $ind1);
3350
3351 $field852 = $xpath->query("//record/datafield[@tag='852']")->item(0);
3352 $subfieldHs = $xpath->query("subfield[@code='h']", $field852);
3353 foreach ($subfieldHs as $subfieldH) {
3354 $subfieldH->parentNode->removeChild($subfieldH);
3355 }
3356 $subfieldIs = $xpath->query("subfield[@code='i']", $field852);
3357 foreach ($subfieldIs as $subfieldI) {
3358 $subfieldI->parentNode->removeChild($subfieldI);
3359 }
3360
3361 appendInnerXML($field852, "<subfield code=\"h\">$h</subfield>");
3362 if ($i) {
3363 appendInnerXML($field852, "<subfield code=\"i\">$i</subfield>");
3364 }
3365 */
3366 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ setInstitutionCode()

Holding::setInstitutionCode (   $code )

sets institution code from 852a

Parameters
string $code - institution code

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

3280 {
3281 $this->useNormac();
3282 $instsf = $this->getFields("852")[0]->getSubFields("a")[0];
3283 $instsf->data = $code;
3284 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ setLibraryCode()

Holding::setLibraryCode (   $code )

sets library code from 852b

Parameters
string $code - library code

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

3306 {
3307 $this->useNormac();
3308 $libsf = $this->getFields("852")[0]->getSubFields("b")[0];
3309 $libsf->data = $code;
3310 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ setLocationCode()

Holding::setLocationCode (   $code )

sets location code from 852c

Parameters
string $code - location code

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

3332 {
3333 $this->useNormac();
3334 $locsf = $this->getFields("852")[0]->getSubFields("c")[0];
3335 $locsf->data = $code;
3336 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

Referenced by offsetSet().

◆ setMethodOfAcquisition()

Holding::setMethodOfAcquisition (   $code )

sets method of acquisition, fixed field 008/07 https://www.loc.gov/marc/holdings/hd008.html

Parameters
char $code - code for method of acquisition

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

3253 {
3254 $this->useNormac();
3255 $fixed_fields = $this->getFields("008")[0];
3256 $newstr = substr_replace($fixed_fields->data,$code,7,1);
3257 $fixed_fields->data = $newstr;
3258 }

References AlmaObjectWithMARC\getFields(), and AlmaObjectWithMARC\useNormac().

◆ updateAlma()

Holding::updateAlma ( )

update holding record in Alma

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

3212 {
3213 global $grima;
3214 $this->normacToXML(); # XXX
3215 #error_log($this->xml->saveXML());
3216 $grima->putHolding($this['mms_id'], $this['holding_id'], $this->xml);
3217 }

References $grima, and AlmaObjectWithMARC\normacToXML().

Member Data Documentation

◆ $el_address

Holding::$el_address
Initial value:
= array(
'holding_id' => '//holding_id',
'shelving_scheme' => "/holding/record/datafield[@tag='852']/@ind1",
'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']",
)

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

◆ $itemList

Holding::$itemList

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

◆ $items

Holding::$items = array()

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

Referenced by getItems().

◆ $xml

Holding::$xml

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


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