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

This object lets grima store data in a catalog record. More...

Inheritance diagram for GrimaDataStore:

Public Member Functions

  __construct ()
  make sure it exists More...
 
  offsetExists ($offset)
 
  offsetGet ($offset)
 
  offsetSet ($offset, $value)
 
  offsetUnset ($offset)
 
  setup ()
  create the record structure in Alma More...
 
  destroy ()
  remove the grima data store from Alma More...
 

Static Public Member Functions

static  exists ()
  checks whether a grima data store has been set up in Alma More...
 

Public Attributes

  $marc
 
  $bib
 
  $holding
 
  $item
 

Detailed Description

This object lets grima store data in a catalog record.

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

Constructor & Destructor Documentation

◆ __construct()

GrimaDataStore::__construct ( )

make sure it exists

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

1919 {
1920 global $ds_barcode;
1921 $this->item = new Item();
1922 try {
1923 $this->item->loadFromAlmaBarcode($ds_barcode);
1924 } catch (Exception $e) {
1925 $this->setup();
1926 }
1927 $this->bib = new Bib();
1928 $this->bib->loadFromAlma($this->item['mms_id']);
1929 $this->bib->useNormac();
1930 }
Definition: grima-lib.php:2533
setup()
create the record structure in Alma
Definition: grima-lib.php:2000
class Item
Definition: grima-lib.php:3501
bib records returned from alma
$ds_barcode
Definition: grima-lib.php:1900

References $ds_barcode, and setup().

Member Function Documentation

◆ destroy()

GrimaDataStore::destroy ( )

remove the grima data store from Alma

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

2052 {
2053 global $ds_barcode;
2054 $item = new Item();
2055 $item->loadFromAlmaBarcode($ds_barcode);
2056 $bib = new Bib();
2057 $bib->loadFromAlma($item['mms_id']);
2058 $bib->deleteTreeFromAlma();
2059 }

References $bib, $ds_barcode, and $item.

◆ exists()

static GrimaDataStore::exists ( )
static

checks whether a grima data store has been set up in Alma

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

2034 {
2035 global $ds_barcode;
2036 $item = new Item();
2037 try {
2038 $item->loadFromAlmaBarcode($ds_barcode);
2039 return true;
2040 } catch (Exception $e) {
2041 return false;
2042 }
2043 }

References $ds_barcode, and $item.

◆ offsetExists()

GrimaDataStore::offsetExists (   $offset )

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

1935 {
1936 $fields = $this->bib->marc->getFields('ZEM');
1937 foreach ($fields as $field) {
1938 $keys = $field->getSubfields('k');
1939 if ($keys[0]->data == $offset) {
1940 return true;
1941 }
1942 }
1943 return false;
1944 }

◆ offsetGet()

GrimaDataStore::offsetGet (   $offset )

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

1947 {
1948 $fields = $this->bib->marc->getFields('ZEM');
1949 foreach ($fields as $field) {
1950 $keys = $field->getSubfields('k');
1951 if ($keys[0]->data == $offset) {
1952 $values = $field->getSubfields('v');
1953 return $values[0]->data;
1954 }
1955 }
1956 return false;
1957 }

◆ offsetSet()

GrimaDataStore::offsetSet (   $offset,
  $value 
)

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

1960 {
1961 $fields = $this->bib->marc->getFields('ZEM');
1962 foreach ($fields as $field) {
1963 $keys = $field->getSubfields('k');
1964 if ($keys[0]->data == $offset) {
1965 $values = $field->getSubfields('v');
1966 $values[0]->data = $value;
1967 $this->bib->updateAlma();
1968 return true;
1969 }
1970 }
1971 $subarray = array(
1972 new ISO2709Subfield('k', $offset),
1973 new ISO2709Subfield('v', $value),
1974 );
1975 $field = new ISO2709Field('ZEM', null, " ", $subarray);
1976 $this->bib->marc->appendField($field);
1977 $this->bib->updateAlma();
1978 return false;
1979 }

◆ offsetUnset()

GrimaDataStore::offsetUnset (   $offset )

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

1982 {
1983 $fields = $this->bib->marc->getFields('ZEM');
1984 foreach ($fields as $field) {
1985 $keys = $field->getSubfields('k');
1986 if ($keys[0]->data == $offset) {
1987 $field->delete();
1988 $this->bib->updateAlma();
1989 return true;
1990 }
1991 }
1992 return false;
1993 }

◆ setup()

GrimaDataStore::setup ( )

create the record structure in Alma

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

2001 {
2002 global $ds_barcode;
2003 $bib = new Bib();
2004 $bib['title'] = "GRIMA'S DATA STORE"; // XXX indicators 00?
2005 $bib['suppress_from_publishing'] = "true";
2006 $bib->addToAlma();
2007 $this->bib = $bib;
2008 $this->bib->useNormac();
2009
2010 $library = Library::getOneLibrary();
2011 $location = $library->getOneLocation();
2012
2013 $holding = new Holding();
2014 $holding['library_code'] = $library['code'];
2015 $holding['location_code'] = $location['code'];
2016 $holding->addToAlmaBib($bib['mms_id']);
2017 $this->holding = $holding;
2018
2019 $item = new Item();
2020 $item['barcode'] = $ds_barcode;
2021 $item->addToAlmaHolding($bib['mms_id'], $holding['holding_id']);
2022 $this->item = $item;
2023
2024 preg_match('/\d{5}$/', $bib['mms_id'], $m);
2025 $this['alma institution code'] = $m[0];
2026 }
class Holding
Definition: grima-lib.php:3034
static getOneLibrary($otherthan=array())
get one library configured by the institution
Definition: grima-lib.php:4366

References $bib, $ds_barcode, $holding, $item, and Library\getOneLibrary().

Referenced by __construct().

Member Data Documentation

◆ $bib

GrimaDataStore::$bib

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

Referenced by destroy(), and setup().

◆ $holding

GrimaDataStore::$holding

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

Referenced by setup().

◆ $item

GrimaDataStore::$item

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

Referenced by destroy(), exists(), and setup().

◆ $marc

GrimaDataStore::$marc

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


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