Open Journal Systems  3.3.0
MetadataDescriptionDummyAdapter.inc.php
1 <?php
2 
18 import('lib.pkp.classes.metadata.MetadataDataObjectAdapter');
19 
26  function __construct(&$metadataDescription, $mode = null) {
27  $this->setDisplayName('Inject/Extract Metadata into/from a MetadataDescription');
28 
29  // Configure the adapter
30  $inputType = $outputType = 'metadata::'.$metadataDescription->getMetadataSchemaName().'(*)';
31  parent::__construct(PersistableFilter::tempGroup($inputType, $outputType), $mode);
32  $this->_assocType = $metadataDescription->getAssocType();
33  }
34 
35 
36  //
37  // Implement template methods from PersistableFilter
38  //
42  function getClassName() {
43  return 'lib.pkp.classes.metadata.MetadataDescriptionDummyAdapter';
44  }
45 
46 
47  //
48  // Implement template methods from MetadataDataObjectAdapter
49  //
56  function &injectMetadataIntoDataObject(&$sourceMetadataDescription, &$targetMetadataDescription) {
57  // Inject data from the source description into the target description.
58  assert($sourceMetadataDescription->getMetadataSchema() == $targetMetadataDescription->getMetadataSchema());
59  $targetMetadataDescription->setStatements($sourceMetadataDescription->getStatements());
60  return $targetMetadataDescription;
61  }
62 
68  function extractMetadataFromDataObject(&$sourceMetadataDescription) {
69  // Create a copy of the meta-data description to decouple
70  // it from the original.
71  return clone($sourceMetadataDescription);
72  }
73 
84  function getMetadataFieldNames($translated = true) {
85  // Do we need to build the field name cache first?
86  if (is_null($this->_metadataFieldNames)) {
87  // Initialize the cache array
88  $this->_metadataFieldNames = array();
89 
90  // Retrieve all properties and add
91  // their names to the cache
92  $metadataSchema =& $this->getMetadataSchema();
93  $properties =& $metadataSchema->getProperties();
94  foreach($properties as $property) {
95  $propertyAssocTypes = $property->getAssocTypes();
96  if (in_array($this->_assocType, $propertyAssocTypes)) {
97  // Separate translated and non-translated property names
98  // and add the name space so that field names are unique
99  // across various meta-data schemas.
100  $this->_metadataFieldNames[$property->getTranslated()][] = $property->getName();
101  }
102  }
103  }
104 
105  // Return the field names
106  return $this->_metadataFieldNames[$translated];
107  }
108 }
109 
MetadataDescriptionDummyAdapter\getMetadataFieldNames
getMetadataFieldNames($translated=true)
Definition: MetadataDescriptionDummyAdapter.inc.php:84
MetadataDescriptionDummyAdapter\injectMetadataIntoDataObject
& injectMetadataIntoDataObject(&$sourceMetadataDescription, &$targetMetadataDescription)
Definition: MetadataDescriptionDummyAdapter.inc.php:56
MetadataDataObjectAdapter
Class that injects/extracts a meta-data description into/from an application entity object (DataObjec...
Definition: MetadataDataObjectAdapter.inc.php:29
PersistableFilter\tempGroup
static tempGroup($inputType, $outputType)
Definition: PersistableFilter.inc.php:274
MetadataDescriptionDummyAdapter\getClassName
getClassName()
Definition: MetadataDescriptionDummyAdapter.inc.php:42
MetadataDescriptionDummyAdapter\extractMetadataFromDataObject
extractMetadataFromDataObject(&$sourceMetadataDescription)
Definition: MetadataDescriptionDummyAdapter.inc.php:68
MetadataDataObjectAdapter\getMetadataSchema
& getMetadataSchema()
Definition: MetadataDataObjectAdapter.inc.php:147
MetadataDescriptionDummyAdapter
Class that simulates a metadata adapter for metadata description object for direct metadata descripti...
Definition: MetadataDescriptionDummyAdapter.inc.php:20
Filter\setDisplayName
setDisplayName($displayName)
Definition: Filter.inc.php:140
MetadataDescriptionDummyAdapter\__construct
__construct(&$metadataDescription, $mode=null)
Definition: MetadataDescriptionDummyAdapter.inc.php:26