Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
Openurl10Nlm30CitationSchemaCrosswalkFilter.inc.php
1 <?php
2 
21 import('lib.pkp.plugins.metadata.nlm30.filter.Nlm30Openurl10CrosswalkFilter');
22 
28  $this->setDisplayName('Crosswalk from Open URL to NLM Citation');
29  parent::Nlm30Openurl10CrosswalkFilter('lib.pkp.plugins.metadata.openurl10.schema.Openurl10BaseSchema',
30  'lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema');
31  }
32 
33 
34  //
35  // Implement template methods from Filter
36  //
45  function &process(&$input) {
46  $nullVar = null;
47 
48  // Instantiate the target description.
49  $output = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema', $input->getAssocType());
50 
51  // Parse au statements into name descriptions
52  import('lib.pkp.plugins.metadata.nlm30.filter.PersonStringNlm30NameSchemaFilter');
53  $personStringFilter = new PersonStringNlm30NameSchemaFilter(ASSOC_TYPE_AUTHOR);
54  $authors =& $input->getStatement('au');
55  if (is_array($authors) && count($authors)) {
56  // TODO: We might improve results here by constructing the
57  // first author from aufirst, aulast fields.
58  foreach ($authors as $author) {
59  $authorDescription =& $personStringFilter->execute($author);
60  $success = $output->addStatement('person-group[@person-group-type="author"]', $authorDescription);
61  assert($success);
62  unset($authorDescription);
63  }
64  }
65 
66  // Publication type
67  $publicationType = null;
68  if ($input->hasStatement('genre')) {
69  $genre = $input->getStatement('genre');
70  $genreMap = $this->_getOpenurl10GenreTranslationMapping();
71  $publicationType = (isset($genreMap[$genre]) ? $genreMap[$genre] : $genre);
72  $success = $output->addStatement('[@publication-type]', $publicationType);
73  assert($success);
74  }
75 
76  // Get NLM => OpenURL property mapping.
77  $propertyMap =& $this->nlmOpenurl10Mapping($publicationType, $input->getMetadataSchema());
78 
79  // Transfer mapped properties with default locale
80  foreach ($propertyMap as $nlm30Property => $openurl10Property) {
81  if ($input->hasStatement($openurl10Property)) {
82  $success = $output->addStatement($nlm30Property, $input->getStatement($openurl10Property));
83  assert($success);
84  }
85  }
86 
87  return $output;
88  }
89 
90  //
91  // Private helper methods
92  //
99  static $openurl10GenreTranslationMapping = array(
100  OPENURL10_GENRE_ARTICLE => NLM30_PUBLICATION_TYPE_JOURNAL,
101  OPENURL10_GENRE_ISSUE => NLM30_PUBLICATION_TYPE_JOURNAL,
102  OPENURL10_GENRE_CONFERENCE => NLM30_PUBLICATION_TYPE_CONFPROC,
103  OPENURL10_GENRE_PROCEEDING => NLM30_PUBLICATION_TYPE_CONFPROC,
104  OPENURL10_GENRE_PREPRINT => NLM30_PUBLICATION_TYPE_JOURNAL,
105  OPENURL10_GENRE_BOOKITEM => NLM30_PUBLICATION_TYPE_BOOK,
106  OPENURL10_GENRE_BOOK => NLM30_PUBLICATION_TYPE_BOOK,
107  OPENURL10_GENRE_REPORT => NLM30_PUBLICATION_TYPE_BOOK,
108  OPENURL10_GENRE_DOCUMENT => NLM30_PUBLICATION_TYPE_BOOK,
109  OPENURL10_PSEUDOGENRE_DISSERTATION => NLM30_PUBLICATION_TYPE_THESIS
110  );
111 
112  return $openurl10GenreTranslationMapping;
113  }
114 }
115 
116 ?>
& nlmOpenurl10Mapping($publicationType, &$openurl10Schema)
setDisplayName($displayName)
Definition: Filter.inc.php:140
Filter that converts from NLM citation to OpenURL schemas.
addStatement($propertyName, $value, $locale=null, $replace=false)
Filter that converts from NLM citation to OpenURL schemas.
Class modeling a description (DCMI abstract model) or subject- predicate-object graph (RDF)...
Filter that converts from a string to an (array of) NLM name description(s).