Example #1
0
 /**
  * Map the source data to record properties
  */
 protected function map(array $document)
 {
     $json = new Json($document);
     $this->database_name = $json->extractValue('Header/DbLabel');
     $this->record_id = $json->extractValue('Header/DbId') . '-' . $json->extractValue('Header/An');
     $this->score = $json->extractValue('Header/RelevancyScore');
     // title
     $this->title = $json->extractValue('RecordInfo/BibRecord/BibEntity/Titles/0/TitleFull');
     $this->sub_title;
     // basic info
     $this->language = $json->extractValue("RecordInfo/BibRecord/BibEntity/Languages/0/Text");
     $this->extent = $json->extractValue("RecordInfo/BibRecord/BibEntity/PhysicalDescription/Pagination/PageCount");
     // date
     $this->year = (int) $json->extractValue('RecordInfo/BibRecord/BibRelationships/IsPartOfRelationships/0/BibEntity/Dates/0/Y');
     $this->month = (int) $json->extractValue('RecordInfo/BibRecord/BibRelationships/IsPartOfRelationships/0/BibEntity/Dates/0/M');
     $this->day = (int) $json->extractValue('RecordInfo/BibRecord/BibRelationships/IsPartOfRelationships/0/BibEntity/Dates/0/D');
     // format
     $format = $json->extractValue("Header/PubType");
     $this->format->setPublicFormat($format);
     $this->format->setInternalFormat($format);
     $this->format->setNormalizedFormat($this->normalizeFormat($format));
     // Item data
     foreach ($json->extractData('Items') as $item) {
         // title
         if ($item['Name'] == 'Title') {
             $this->title = $item['Data'];
         }
         // abstract
         if ($item['Name'] == 'Abstract') {
             $this->abstract = $item['Data'];
         }
         // publication source
         if ($item['Name'] == 'TitleSource' && $this->journal == "") {
             $this->journal = strip_tags(html_entity_decode($item['Data']));
         }
         // pmid
         if ($item['Label'] == 'PMID') {
             $this->pubmed_id = $item['Data'];
         }
         // notes
         if ($item['Label'] == 'Notes') {
             $this->notes[] = $item['Data'];
         }
     }
     // books
     $this->edition = $json->extractValue("Edition/0");
     $this->publisher = $this->toTitleCase($json->extractValue("Publisher/0"));
     $this->place = $json->extractValue("PublicationPlace_xml/0/name");
     // article
     $this->journal_title = $json->extractValue("RecordInfo/BibRecord/BibRelationships/IsPartOfRelationships/0/BibEntity/Titles/0/TitleFull");
     $this->start_page = $json->extractValue("RecordInfo/BibRecord/BibEntity/PhysicalDescription/Pagination/StartPage");
     if ($this->start_page != "" && $this->extent != "") {
         $this->end_page = $this->start_page + $this->extent - 1;
     }
     foreach ($json->extractData('RecordInfo/BibRecord/BibRelationships/IsPartOfRelationships/0/BibEntity/Numbering') as $number) {
         if ($number['Type'] == 'volume') {
             $this->volume = $number['Value'];
         } elseif ($number['Type'] == 'issue') {
             $this->issue = $number['Value'];
         }
     }
     // links
     foreach ($json->extractData('FullText/Links') as $link) {
         $type = $link['Type'];
         if (strstr($type, 'pdf')) {
             $type = Xerxes\Record\Link::PDF;
         }
         if (array_key_exists('Url', $link)) {
             $url = $link['Url'];
             $this->links[] = new Xerxes\Record\Link($url, $type);
         }
     }
     // subjects
     foreach ($json->extractData('RecordInfo/BibRecord/BibEntity/Subjects') as $subject) {
         $subject = Parser::toSentenceCase($subject['SubjectFull']);
         $subject_object = new Xerxes\Record\Subject();
         $subject_object->display = $subject;
         $subject_object->value = $subject;
         array_push($this->subjects, $subject_object);
     }
     // identifiers
     foreach ($json->extractData('RecordInfo/BibRecord/BibEntity/Identifiers') as $identifier) {
         // doi
         if ($identifier['Type'] == 'doi') {
             $this->doi = $identifier['Value'];
         }
     }
     foreach ($json->extractData('RecordInfo/BibRecord/BibRelationships/IsPartOfRelationships/0/BibEntity/Identifiers') as $identifier) {
         // isbn
         if (strstr($identifier['Type'], 'isbn')) {
             $this->isbns[] = $identifier['Value'];
         }
         // issn
         if (strstr($identifier['Type'], 'issn')) {
             $this->issns[] = $identifier['Value'];
         }
     }
     // authors
     foreach ($json->extractData('RecordInfo/BibRecord/BibRelationships/HasContributorRelationships') as $author) {
         $json_author = new Json($author);
         $author_object = new Xerxes\Record\Author($json_author->extractValue('PersonEntity/Name/NameFull'), null, 'personal');
         array_push($this->authors, $author_object);
     }
     if (array_key_exists('debugrec', $_GET)) {
         header('Content-type: text/plain');
         print_r($this);
         exit;
     }
 }
Example #2
0
 /**
  * Map the source data to record properties
  */
 protected function map($document)
 {
     // print_r($document); exit;
     $this->database_name = $this->extractValue($document, "Source/0");
     $this->record_id = $this->extractValue($document, "ID/0");
     $this->score = $this->extractValue($document, "Score/0");
     $this->open_url = $this->extractValue($document, "openUrl");
     // title
     $this->title = $this->extractValue($document, "Title/0");
     $this->sub_title = $this->extractValue($document, "Subtitle/0");
     // basic info
     $this->language = $this->extractValue($document, "Language/0");
     $this->extent = $this->extractValue($document, "PageCount/0");
     // date
     $this->year = (int) $this->extractValue($document, "PublicationDate_xml/0/year");
     $this->month = (int) $this->extractValue($document, "PublicationDate_xml/0/month");
     $this->day = (int) $this->extractValue($document, "PublicationDate_xml/0/day");
     // only use this if it has text in it
     $publication_date = $this->extractValue($document, "PublicationDate_xml/0/text");
     if (preg_match('/[a-zA-Z]{1}/', $publication_date)) {
         $this->publication_date = $publication_date;
     }
     // format
     $format = $this->extractValue($document, "ContentType/0");
     $this->format->setPublicFormat($format);
     $this->format->setInternalFormat($format);
     $this->format->setNormalizedFormat($this->normalizeFormat($format));
     // summary
     $this->snippet = $this->extractValue($document, "Snippet/0");
     $this->abstract = $this->extractValue($document, "Abstract/0");
     if (ord($this->abstract) == 194) {
         $this->abstract = substr($this->abstract, 2);
         // so strip it and the adjoining character
     }
     // books
     $this->edition = $this->extractValue($document, "Edition/0");
     $this->publisher = $this->toTitleCase($this->extractValue($document, "Publisher/0"));
     $this->place = $this->extractValue($document, "PublicationPlace_xml/0/name");
     // article
     $this->journal_title = $this->toTitleCase($this->extractValue($document, "PublicationTitle/0"));
     $this->issue = $this->extractValue($document, "Issue/0");
     $this->volume = $this->extractValue($document, "Volume/0");
     $this->start_page = $this->extractValue($document, "StartPage/0");
     $this->end_page = $this->extractValue($document, "EndPage/0");
     $this->doi = $this->extractValue($document, "DOI/0");
     // subscription
     $has_full_text = (int) $this->extractValue($document, 'hasFullText');
     $in_holdings = (int) $this->extractValue($document, 'inHoldings');
     if ($has_full_text == 1 && $in_holdings == 1) {
         $this->setSubscription(true);
     }
     // direct link
     if ($this->config()->getConfig('direct_linking', false, false)) {
         $direct_link = $this->extractValue($document, "link");
         $model = $this->extractValue($document, "LinkModel/0");
         if ($model == 'DirectLink') {
             $link = new Link($direct_link);
             if ($has_full_text == 1) {
                 $link->setType(Link::ONLINE);
             } else {
                 $link->setType(Link::ORIGINAL_RECORD);
             }
             $this->links[] = $link;
         }
     }
     // original record link
     $uri = $this->extractValue($document, "URI/0");
     if ($uri != '') {
         $this->links[] = new Link($uri, Link::ORIGINAL_RECORD);
     }
     // peer reviewed
     if ($this->extractValue($document, "IsPeerReviewed/0") == "true") {
         $this->refereed = true;
     }
     // subjects
     if (array_key_exists('SubjectTerms', $document)) {
         foreach ($document['SubjectTerms'] as $subject) {
             $subject = Parser::toSentenceCase($subject);
             $subject_object = new Xerxes\Record\Subject();
             $subject_object->display = $subject;
             $subject_object->value = $subject;
             array_push($this->subjects, $subject_object);
         }
     }
     // isbn
     if (array_key_exists('ISBN', $document)) {
         $this->isbns = $document['ISBN'];
     }
     // issn
     if (array_key_exists('ISSN', $document)) {
         $this->issns = $document['ISSN'];
     } elseif (array_key_exists('EISSN', $document)) {
         $this->issns = $document['EISSN'];
     }
     // notes
     if (array_key_exists('Notes', $document)) {
         $this->notes = $document['Notes'];
     }
     if (array_key_exists('Genre', $document)) {
         $this->notes = $document['Genre'];
     }
     // authors
     if (array_key_exists('Author_xml', $document)) {
         foreach ($document['Author_xml'] as $author) {
             $author_object = new Xerxes\Record\Author();
             if (array_key_exists('givenname', $author)) {
                 $author_object->type = "personal";
                 $author_object->last_name = $author['surname'];
                 $author_object->first_name = $author['givenname'];
             } elseif (array_key_exists('fullname', $author)) {
                 $author_object = new Xerxes\Record\Author($author['fullname'], null, 'personal');
             }
             array_push($this->authors, $author_object);
         }
     }
 }
Example #3
0
 protected function map($document)
 {
     $this->source = "Summon";
     $this->database_name = $this->extractValue($document, "Source/0");
     $this->record_id = $this->extractValue($document, "ID/0");
     $this->score = $this->extractValue($document, "Score/0");
     // title
     $this->title = $this->extractValue($document, "Title/0");
     $this->sub_title = $this->extractValue($document, "Subtitle/0");
     // basic info
     $this->language = $this->extractValue($document, "Language/0");
     $this->year = $this->extractValue($document, "PublicationDate_xml/0/year");
     $this->extent = $this->extractValue($document, "PageCount/0");
     // format
     $format = $this->extractValue($document, "ContentType/0");
     $this->format->setPublicFormat($format);
     $this->format->setInternalFormat($format);
     $this->format->setNormalizedFormat($this->normalizeFormat($format));
     // summary
     $this->snippet = $this->extractValue($document, "Snippet/0");
     $this->abstract = $this->extractValue($document, "Abstract/0");
     // books
     $this->edition = $this->extractValue($document, "Edition/0");
     $this->publisher = $this->toTitleCase($this->extractValue($document, "Publisher/0"));
     $this->place = $this->extractValue($document, "PublicationPlace_xml/0/name");
     // article
     $this->journal_title = $this->toTitleCase($this->extractValue($document, "PublicationTitle/0"));
     $this->issue = $this->extractValue($document, "Issue/0");
     $this->volume = $this->extractValue($document, "Volume/0");
     $this->start_page = $this->extractValue($document, "StartPage/0");
     $this->end_page = $this->extractValue($document, "EndPage/0");
     $this->doi = $this->extractValue($document, "DOI/0");
     $openurl = $this->extractValue($document, "openUrl");
     $direct_link = $this->extractValue($document, "link");
     $uri = $this->extractValue($document, "URI/0");
     // @todo: figure out black magic for direct linking
     // $this->links[] = new Xerxes\Record\Link($direct_link, Xerxes\Record\Link::ONLINE);
     // peer reviewed
     if ($this->extractValue($document, "IsPeerReviewed/0") == "true") {
         $this->refereed = true;
     }
     // subjects
     if (array_key_exists('SubjectTerms', $document)) {
         foreach ($document['SubjectTerms'] as $subject) {
             $subject = Parser::toSentenceCase($subject);
             $subject_object = new Xerxes\Record\Subject();
             $subject_object->display = $subject;
             $subject_object->value = $subject;
             array_push($this->subjects, $subject_object);
         }
     }
     // isbn
     if (array_key_exists('ISBN', $document)) {
         $this->isbns = $document['ISBN'];
     }
     // issn
     if (array_key_exists('ISSN', $document)) {
         $this->issns = $document['ISSN'];
     } elseif (array_key_exists('EISSN', $document)) {
         $this->issns = $document['EISSN'];
     }
     // notes
     if (array_key_exists('Notes', $document)) {
         $this->notes = $document['Notes'];
     }
     // authors
     if (array_key_exists('Author_xml', $document)) {
         foreach ($document['Author_xml'] as $author) {
             $author_object = new Xerxes\Record\Author();
             if (array_key_exists('givenname', $author)) {
                 $author_object->type = "personal";
                 $author_object->last_name = $author['surname'];
                 $author_object->first_name = $author['givenname'];
             } elseif (array_key_exists('fullname', $author)) {
                 $author_object = new Xerxes\Record\Author($author['fullname'], null, 'personal');
             }
             array_push($this->authors, $author_object);
         }
     }
 }