Beispiel #1
0
 /**
  * Create a new Response
  *
  * @param  QuiteSimpleXMLElement  $dom
  * @return void
  */
 public function __construct(QuiteSimpleXMLElement $dom = null)
 {
     $this->dom = $dom;
     $this->success = false;
     if (is_null($this->dom)) {
         return;
     }
     if ($this->dom->first('ns1:Problem')) {
         $this->error = $this->dom->text('ns1:Problem/ns1:ProblemType');
         $this->errorDetails = $this->dom->text('ns1:Problem/ns1:ProblemDetail');
     } else {
         $this->success = true;
     }
 }
Beispiel #2
0
 public function loadPrimoRecord($filename)
 {
     $xml = file_get_contents(__DIR__ . '/data/' . $filename);
     $root = new QuiteSimpleXMLElement($xml);
     $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search');
     $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib');
     $doc = $root->first('//s:DOC');
     $dl = new DeepLink('', '');
     return PrimoRecord::make($doc, $dl, false, [])->toArray(true);
 }
Beispiel #3
0
 /**
  * Create a new record
  *
  * @param Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement $doc
  */
 public function __construct($doc)
 {
     $this->identifier = $doc->text('oai:header/oai:identifier');
     $this->datestamp = $doc->text('oai:header/oai:datestamp');
     $this->data = $doc->first('oai:metadata');
 }
Beispiel #4
0
 public function getRecord($docId, $options)
 {
     $institution = $options->get('institution', config('app.primo.institution'));
     $scope = $options->get('scope', config('app.primo.default_scope'));
     $queryObj = new Query($institution);
     $queryObj->local($scope);
     $queryObj->onCampus(true);
     $url = str_replace('json=true&', '', $this->primo->url('full', $queryObj));
     $url = str_replace('&indx=1&bulkSize=10', '', $url);
     $url .= '&docId=' . $docId . '&getDelivery=true';
     $client = new HttpClient();
     $request = $client->get($url);
     $body = $request->send()->getBody();
     if ($options->get('raw') == 'true') {
         return $body;
     }
     $root = new QuiteSimpleXMLElement(strval($body));
     $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search');
     $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib');
     $deeplinkProvider = $this->primo->createDeepLink();
     $error = $root->first('/s:SEGMENTS/s:JAGROOT/s:RESULT/s:ERROR');
     if ($error) {
         throw new PrimoException($error->attr('MESSAGE'), 0, null, $url);
     }
     $doc = $root->first('//s:DOC');
     if (!$doc) {
         throw new PrimoException('Invalid response from Primo', 0, null, $url);
     }
     $out = PrimoRecord::make($doc, $deeplinkProvider, true, $this->getRecordOptions($options))->toArray('full');
     return ['source' => $url, 'error' => null, 'result' => $out];
 }