Open Journal Systems  3.3.0
NativeXmlRepresentationFilter.inc.php
1 <?php
2 
16 import('lib.pkp.plugins.importexport.native.filter.NativeImportFilter');
17 
23  function __construct($filterGroup) {
24  $this->setDisplayName('Native XML representation import');
25  parent::__construct($filterGroup);
26  }
27 
28  //
29  // Implement template methods from PersistableFilter
30  //
34  function getClassName() {
35  return 'lib.pkp.plugins.importexport.native.filter.NativeXmlRepresentationFilter';
36  }
37 
38 
44  function handleElement($node) {
45  $deployment = $this->getDeployment();
46  $context = $deployment->getContext();
47 
48  $publication = $deployment->getPublication();
49  assert(is_a($publication, 'PKPPublication'));
50 
51  // Create the data object
52  $representationDao = Application::getRepresentationDAO();
53  $representation = $representationDao->newDataObject();
55  $representation->setData('publicationId', $publication->getId());
56 
57  // Handle metadata in subelements. Look for the 'name' and 'seq' elements.
58  // All other elements are handled by subclasses.
59  for ($n = $node->firstChild; $n !== null; $n=$n->nextSibling) if (is_a($n, 'DOMElement')) switch($n->tagName) {
60  case 'id': $this->parseIdentifier($n, $representation); break;
61  case 'name':
62  $locale = $n->getAttribute('locale');
63  if (empty($locale)) $locale = $publication->getData('locale');
64  $representation->setName($n->textContent, $locale);
65  break;
66  case 'seq': $representation->setSequence($n->textContent); break;
67  case 'remote': $representation->setRemoteURL($n->getAttribute('src')); break;
68 
69  }
70 
71  return $representation; // database insert is handled by sub class.
72  }
73 
79  function parseIdentifier($element, $representation) {
80  $deployment = $this->getDeployment();
81  $advice = $element->getAttribute('advice');
82  switch ($element->getAttribute('type')) {
83  case 'internal':
84  // "update" advice not supported yet.
85  assert(!$advice || $advice == 'ignore');
86  break;
87  case 'public':
88  if ($advice == 'update') {
89  $representation->setStoredPubId('publisher-id', $element->textContent);
90  }
91  break;
92  default:
93  if ($advice == 'update') {
94  // Load pub id plugins
95  $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $deployment->getContext()->getId());
96  $representation->setStoredPubId($element->getAttribute('type'), $element->textContent);
97  }
98  }
99  }
100 }
101 
102 
NativeXmlRepresentationFilter\parseIdentifier
parseIdentifier($element, $representation)
Definition: NativeXmlRepresentationFilter.inc.php:79
Application\getRepresentationDAO
static getRepresentationDAO()
Definition: Application.inc.php:162
NativeXmlRepresentationFilter
Base class that converts a Native XML document to a set of authors.
Definition: NativeXmlRepresentationFilter.inc.php:18
NativeImportExportFilter\getDeployment
getDeployment()
Definition: NativeImportExportFilter.inc.php:49
NativeXmlRepresentationFilter\handleElement
handleElement($node)
Definition: NativeXmlRepresentationFilter.inc.php:44
PluginRegistry\loadCategory
static loadCategory($category, $enabledOnly=false, $mainContextId=null)
Definition: PluginRegistry.inc.php:103
NativeImportFilter
Base class that converts a Native XML document to a DataObject.
Definition: NativeImportFilter.inc.php:18
NativeXmlRepresentationFilter\__construct
__construct($filterGroup)
Definition: NativeXmlRepresentationFilter.inc.php:23
NativeXmlRepresentationFilter\getClassName
getClassName()
Definition: NativeXmlRepresentationFilter.inc.php:34
Filter\setDisplayName
setDisplayName($displayName)
Definition: Filter.inc.php:140