Grima 2018-08
Whispering into Alma's ear
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
Bib Class Reference
Inheritance diagram for Bib:
AlmaObjectWithMARC AlmaObject

Public Member Functions

  offsetGet ($offset)
 
  offsetSet ($offset, $value)
 
  loadFromAlma ($mms_id)
  populates the bib with a record from Alma More...
 
  addToAlma ()
  adds record as a new record to Alma, updates Bib with current Alma version More...
 
  updateAlma ()
  replaces the Bib in Alma More...
 
  deleteFromAlma ()
  deletes the Bib from Alma More...
 
  deleteTreeFromAlma ()
  deletes the Bib and its inventory #XXX More...
 
  hasInventory ()
  populate holdings property with Holdings items More...
 
  linkedToCZ ()
  is the bib linked to the community zone? More...
 
  unlinkFromCZ ()
  does this work @XXX: Not supported for CZ More...
 
  getHoldings ()
  populate holdings property with Holdings items More...
 
  deleteAllPortfolios ()
  delete all portfolios from the bib More...
 
  getHoldingsList ()
  populate holdingsList property with info from Alma More...
 
  getPortfolioList ()
  populate portfolioList property with brief info from Alma More...
 
  getPortfolios ()
  get full portfolios for the bib More...
 
  getItems ()
  populate items property with Items objects ## XXX TEST More...
 
  getItemList ()
  populates itemList property from Alma More...
 
  get_title_proper ()
  a tidy title proper More...
 
  getLCCallNumber ()
  get LC call number, giving pref to 090 and later fields 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  getMmsFromOCLC ($oclc) # XXX
  populates the MMS ID More...
 

Public Attributes

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

Protected Attributes

  $el_address
 

Detailed Description

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

Member Function Documentation

◆ addToAlma()

Bib::addToAlma ( )

adds record as a new record to Alma, updates Bib with current Alma version

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

2621 {
2622 global $grima;
2623 $this->normacToXML();
2624 $this->xml = $grima->postBib($this->xml);
2625 }
normacToXML()
convert normac fields back to XML
Definition: grima-lib.php:2307
$grima
Definition: grima-lib.php:5143

References $grima, and AlmaObjectWithMARC\normacToXML().

◆ deleteAllPortfolios()

Bib::deleteAllPortfolios ( )

delete all portfolios from the bib

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

2771 {
2772 global $grima;
2773 while ($this->getPortfolioList()) {
2774 foreach ($this->portfolioList as $portfolio) {
2775 error_log("deleting " . $portfolio['pid'] . "\n");
2776 $portfolio->deleteFromAlma();
2777 }
2778 $this->portfolioList = array();
2779 sleep(3);
2780 }
2781 }
getPortfolioList()
populate portfolioList property with brief info from Alma
Definition: grima-lib.php:2798

References $grima, and getPortfolioList().

Referenced by deleteTreeFromAlma().

◆ deleteFromAlma()

Bib::deleteFromAlma ( )

deletes the Bib from Alma

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

2646 {
2647 global $grima;
2648 $grima->deleteBib($this['mms_id']);
2649 }

References $grima.

◆ deleteTreeFromAlma()

Bib::deleteTreeFromAlma ( )

deletes the Bib and its inventory #XXX

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

2690 {
2691 global $grima;
2692 $this->getHoldings();
2693 foreach ($this->holdings as $holding) {
2694 $holding->deleteTreeFromAlma(); // XXX
2695 }
2696 $this->deleteAllPortfolios($this['mms_id']); // XXX
2697 $grima->deleteBib($this['mms_id']);
2698 }
deleteAllPortfolios()
delete all portfolios from the bib
Definition: grima-lib.php:2770
getHoldings()
populate holdings property with Holdings items
Definition: grima-lib.php:2753

References $grima, deleteAllPortfolios(), and getHoldings().

◆ get_title_proper()

Bib::get_title_proper ( )

a tidy title proper

Returns
string 245$a with ISBD punctuation removed

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

2859 {
2860 $xpath = new DomXpath($this->xml);
2861 $title = $xpath->query("//record/datafield[@tag='245']/subfield[@code='a']");
2862 return preg_replace("/[ \/=:,;\.]*$/", "", $title[0]->nodeValue);
2863 }

◆ getHoldings()

Bib::getHoldings ( )

populate holdings property with Holdings items

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

2754 {
2755 $this->getHoldingsList();
2756 foreach ($this->holdingsList->entries as $entry) {
2757 $holding = new Holding();
2758 $holding->loadFromAlma($this['mms_id'], $entry['holding_id']);
2759 $holding['mms_id'] = $this['mms_id'];
2760 $this->holdings[] = $holding;
2761 }
2762 return $this->holdings;
2763 }
getHoldingsList()
populate holdingsList property with info from Alma
Definition: grima-lib.php:2788
$holdings
Definition: grima-lib.php:2535
class Holding
Definition: grima-lib.php:3034

References $holdings, and getHoldingsList().

Referenced by deleteTreeFromAlma().

◆ getHoldingsList()

Bib::getHoldingsList ( )

populate holdingsList property with info from Alma

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

2789 {
2790 $this->holdingsList = new HoldingsList($this['mms_id']);
2791 }
class HoldingsList
Definition: grima-lib.php:2915

Referenced by getHoldings(), and hasInventory().

◆ getItemList()

Bib::getItemList ( )

populates itemList property from Alma

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

2846 {
2847 // XXX
2848 global $grima;
2849 $this->itemList = new ItemList($this['mms_id'], 'ALL');
2850 }
class ItemList
Definition: grima-lib.php:2987

References $grima.

Referenced by getItems().

◆ getItems()

Bib::getItems ( )

populate items property with Items objects ## XXX TEST

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

2834 {
2835 $this->getItemList();
2836 $this->items =& $this->itemList->items;
2837 return $this->items;
2838 }
getItemList()
populates itemList property from Alma
Definition: grima-lib.php:2845
$items
Definition: grima-lib.php:2538

References $items, and getItemList().

◆ getLCCallNumber()

Bib::getLCCallNumber ( )

get LC call number, giving pref to 090 and later fields

Returns
Array(class,item) for two parts of call number

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

2885 {
2886 $xpath = new DomXPath($this->xml);
2887 $calls = array();
2888 foreach (array('050','090') as $tag) {
2889 foreach ($xpath->query("//datafield[@tag='$tag']") as $call) {
2890 $calls[] = $call;
2891 }
2892 }
2893 $ret = array();
2894
2895 foreach ($calls as $node) {
2896 $classs = $xpath->query("subfield[@code='a']", $node);
2897 $items = $xpath->query("subfield[@code='b']", $node);
2898 if ((count($classs) > 0) and (count($items) > 0)) {
2899 $ret = array($classs[0]->nodeValue,$items[0]->nodeValue);
2900 }
2901 }
2902 return $ret;
2903 }

References $items.

◆ getMmsFromOCLC()

static Bib::getMmsFromOCLC (   $oclc )
static

populates the MMS ID

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

2657 {
2658 global $grima;
2659
2660 $report = new AnalyticsReport();
2661 $report->path = "/shared/Community/Reports/Institutions/University of Kentucky/Kathryn/OclcToMMS";
2662 $report->filter = '
2663<sawx:expr xsi:type="sawx:comparison" op="equal" xmlns:saw="com.siebel.analytics.web/report/v1.1"
2664xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2665xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2666 <sawx:expr xsi:type="sawx:sqlExpression">"Holding Details"."Holding Id"</sawx:expr><sawx:expr xsi:type="xsd:string">{holding_id}</sawx:expr>
2667</sawx:expr>';
2668
2669 $report->filter = '
2670<sawx:expr xsi:type="sawx:comparison" op="equal" xmlns:saw="com.siebel.analytics.web/report/v1.1"
2671xmlns:sawx="com.siebel.analytics.web/expression/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2672xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2673 <sawx:expr xsi:type="sawx:sqlExpression">"Bibliographic Details"."OCLC Control Number (035a)"</sawx:expr></sawx:expr>
2674';
2675
2676 $report->runReport(array('oclc' => $oclc), 1);
2677 if (count($report->rows) == 1) {
2678 return $report->rows[0][1];
2679 } else {
2680 throw new Exception("No MMS for OCLC #$oclc");
2681 }
2682 }
class AnalyticsReport
Definition: grima-lib.php:4587

References $grima.

◆ getPortfolioList()

Bib::getPortfolioList ( )

populate portfolioList property with brief info from Alma

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

2799 {
2800 // maybe rename
2801 global $grima;
2802 $limit = 10; $offset = 0; // where to allow passing
2803 $ret = $grima->getElectronicPortfoliosForBib($this['mms_id'], $limit, $offset);
2804 $xpath = new DOMXpath($ret);
2805 $ports = $xpath->query('//portfolio');
2806 foreach ($ports as $portnode) {
2807 $newport = new ElectronicPortfolio();
2808 $newport->loadFromPortfolioListNode($portnode);
2809 $this->portfolioList[] = $newport;
2810 }
2811 return count($ports); // XXX is this the right thing to return?
2812 }
class ElectronicPortfolio
Definition: grima-lib.php:3937

References $grima.

Referenced by deleteAllPortfolios(), getPortfolios(), and hasInventory().

◆ getPortfolios()

Bib::getPortfolios ( )

get full portfolios for the bib

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

2820 {
2821 $this->getPortfolioList();
2822 foreach ($this->portfolioList as $port) {
2823 $port->loadFromAlma($port['portfolio_id']);
2824 }
2825 return $this->portfolioList;
2826 }
$portfolioList
Definition: grima-lib.php:2540

References $portfolioList, and getPortfolioList().

◆ hasInventory()

Bib::hasInventory ( )

populate holdings property with Holdings items

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

2706 {
2707 $this->getHoldingsList();
2708 if (count($this->holdingsList->entries) > 0) {
2709 return true;
2710 }
2711 $this->getPortfolioList();
2712 if (count($this->portfolioList) > 0) {
2713 print_r($this->portfolioList);
2714 return true;
2715 } else {
2716 return false;
2717 }
2718 }

References getHoldingsList(), and getPortfolioList().

◆ linkedToCZ()

Bib::linkedToCZ ( )

is the bib linked to the community zone?

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

2726 {
2727 $xpath = new DomXPath($this->xml);
2728 $nodes = $xpath->query("//linked_record_id[@type='CZ']");
2729 return (count($nodes) > 0);
2730 }

◆ loadFromAlma()

Bib::loadFromAlma (   $mms_id )

populates the bib with a record from Alma

Parameters
string $mms_id MMS ID of record to load from Alma

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

2608 {
2609 global $grima;
2610 $this->xml = $grima->getBib($mms_id);
2611 $this->useNormac(); # XXX okay?
2612 }

References $grima, and AlmaObjectWithMARC\useNormac().

◆ offsetGet()

Bib::offsetGet (   $offset )

Reimplemented from AlmaObject.

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

2557 {
2558 if ($offset == 'Type') {
2559 $leader = $this['leader'];
2560 return $leader[6];
2561 }
2562 if ($offset == 'BLvl') {
2563 $leader = $this['leader'];
2564 return $leader[7];
2565 }
2566 if ($offset == 'ELvl') {
2567 $leader = $this['leader'];
2568 return $leader[17];
2569 }
2570 if ($offset == 'Desc') {
2571 $leader = $this['leader'];
2572 return $leader[18];
2573 }
2574 if ($offset == 'Lang') {
2575 $my008s = $this->getFields('008');
2576 $my008 = $my008s[0];
2577 $data = $my008->data;
2578 return substr($data,35,3);
2579 }
2580 return parent::offsetGet($offset);
2581 }
getFields($tag)
get fields for the given MARC tag
Definition: grima-lib.php:2369

References AlmaObjectWithMARC\getFields().

◆ offsetSet()

Bib::offsetSet (   $offset,
  $value 
)

Reimplemented from AlmaObject.

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

2585 {
2586 parent::offsetSet($offset, $value);
2587 if ($offset == 'author') {
2588 $this->replaceOrAddSubfield('100', 'a', $value);
2589 }
2590 if ($offset == 'title') {
2591 $this->replaceOrAddSubfield('245', 'a', $value);
2592 }
2593 if (($offset == 'publisher_const') or ($offset == 'publisher')) {
2594 $this->replaceOrAddSubfield('264', 'b', $value);
2595 }
2596 if ($offset == 'place_of_publication') {
2597 $this->replaceOrAddSubfield('264', 'a', $value);
2598 }
2599 }
replaceOrAddSubfield($tag, $code, $value) ## XXX
replace or add subfield value in marc
Definition: grima-lib.php:2494

References AlmaObjectWithMARC\replaceOrAddSubfield().

◆ unlinkFromCZ()

Bib::unlinkFromCZ ( )

does this work @XXX: Not supported for CZ

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

2739 {
2740 $xpath = new DomXPath($this->xml);
2741 $nodes = $xpath->query("//linked_record_id[@type='CZ']");
2742 foreach ($nodes as $node) {
2743 $node->parentNode->removeChild($node);
2744 }
2745 $this->updateAlma();
2746 }
updateAlma()
replaces the Bib in Alma
Definition: grima-lib.php:2632

References updateAlma().

◆ updateAlma()

Bib::updateAlma ( )

replaces the Bib in Alma

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

2633 {
2634 global $grima;
2635 // XXX parent here?
2636 $this->normacToXML();
2637 $this->xml = $grima->putBib($this['mms_id'], $this->xml);
2638 }

References $grima, and AlmaObjectWithMARC\normacToXML().

Referenced by unlinkFromCZ().

Member Data Documentation

◆ $el_address

Bib::$el_address
protected
Initial value:
= array(
'mms_id' => '//mms_id',
'leader' => '//leader',
'record_format' => '//record_format',
'title' => '//title',
'author' => '//author',
'place_of_publication' => '//place_of_publication',
'publisher_const' => '//publisher_const',
'publisher' => '//publisher_const',
'suppress_from_publishing' => '//suppress_from_publishing',
)

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

◆ $holdings

Bib::$holdings = array()

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

Referenced by getHoldings().

◆ $holdingsList

Bib::$holdingsList

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

◆ $itemList

Bib::$itemList

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

◆ $items

Bib::$items = array()

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

Referenced by getItems(), and getLCCallNumber().

◆ $portfolioList

Bib::$portfolioList = array()

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

Referenced by getPortfolios().


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