本文整理汇总了PHP中MetadataDescription::setSeq方法的典型用法代码示例。如果您正苦于以下问题:PHP MetadataDescription::setSeq方法的具体用法?PHP MetadataDescription::setSeq怎么用?PHP MetadataDescription::setSeq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MetadataDescription
的用法示例。
在下文中一共展示了MetadataDescription::setSeq方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMetadataDescriptionCrud
/**
* @covers MetadataDescriptionDAO
*
* FIXME: The test data used here and in the CitationDAOTest
* are very similar. We should find a way to not duplicate this
* test data.
*/
public function testMetadataDescriptionCrud()
{
$metadataDescriptionDao = DAORegistry::getDAO('MetadataDescriptionDAO');
$nameDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema', ASSOC_TYPE_AUTHOR);
$nameDescription->addStatement('given-names', $value = 'Peter');
$nameDescription->addStatement('given-names', $value = 'B');
$nameDescription->addStatement('surname', $value = 'Bork');
$nameDescription->addStatement('prefix', $value = 'Mr.');
$testDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema', ASSOC_TYPE_CITATION);
$testDescription->setAssocId(999999);
$testDescription->setDisplayName('test meta-data description');
$testDescription->setSeq(5);
$testDescription->addStatement('person-group[@person-group-type="author"]', $nameDescription);
$testDescription->addStatement('article-title', $value = 'PHPUnit in a nutshell', 'en_US');
$testDescription->addStatement('article-title', $value = 'PHPUnit in Kürze', 'de_DE');
$testDescription->addStatement('date', $value = '2009-08-17');
$testDescription->addStatement('size', $value = 320);
$testDescription->addStatement('uri', $value = 'http://phpunit.org/nutshell');
// Create meta-data description
$metadataDescriptionId = $metadataDescriptionDao->insertObject($testDescription);
self::assertTrue(is_numeric($metadataDescriptionId));
self::assertTrue($metadataDescriptionId > 0);
// Retrieve meta-data description by id
$metadataDescriptionById = $metadataDescriptionDao->getObjectById($metadataDescriptionId);
$testDescription->removeSupportedMetadataAdapter('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema');
// Required for comparison
$metadataDescriptionById->getMetadataSchema();
// Instantiates the internal metadata-schema.
self::assertEquals($testDescription, $metadataDescriptionById);
$metadataDescriptionsByAssocIdDaoFactory = $metadataDescriptionDao->getObjectsByAssocId(ASSOC_TYPE_CITATION, 999999);
$metadataDescriptionsByAssocId = $metadataDescriptionsByAssocIdDaoFactory->toArray();
self::assertEquals(1, count($metadataDescriptionsByAssocId));
$metadataDescriptionsByAssocId[0]->getMetadataSchema();
// Instantiates the internal metadata-schema.
self::assertEquals($testDescription, $metadataDescriptionsByAssocId[0]);
// Update meta-data description
$testDescription->removeStatement('date');
$testDescription->addStatement('article-title', $value = 'PHPUnit rápido', 'pt_BR');
$metadataDescriptionDao->updateObject($testDescription);
$testDescription->removeSupportedMetadataAdapter('lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema');
// Required for comparison
$metadataDescriptionAfterUpdate = $metadataDescriptionDao->getObjectById($metadataDescriptionId);
$metadataDescriptionAfterUpdate->getMetadataSchema();
// Instantiates the internal metadata-schema.
self::assertEquals($testDescription, $metadataDescriptionAfterUpdate);
// Delete meta-data description
$metadataDescriptionDao->deleteObjectsByAssocId(ASSOC_TYPE_CITATION, 999999);
self::assertNull($metadataDescriptionDao->getObjectById($metadataDescriptionId));
}
示例2: testCitationCrud
/**
* @covers CitationDAO
*/
public function testCitationCrud()
{
$citationDao = DAORegistry::getDAO('CitationDAO');
/* @var $citationDao CitationDAO */
$nameSchemaName = 'lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema';
$nameDescription = new MetadataDescription($nameSchemaName, ASSOC_TYPE_AUTHOR);
$nameDescription->addStatement('given-names', $value = 'Peter');
$nameDescription->addStatement('given-names', $value = 'B');
$nameDescription->addStatement('surname', $value = 'Bork');
$nameDescription->addStatement('prefix', $value = 'Mr.');
$citationSchemaName = 'lib.pkp.plugins.metadata.nlm30.schema.Nlm30CitationSchema';
$citationDescription = new MetadataDescription($citationSchemaName, ASSOC_TYPE_CITATION);
$citationDescription->addStatement('person-group[@person-group-type="author"]', $nameDescription);
$citationDescription->addStatement('article-title', $value = 'PHPUnit in a nutshell', 'en_US');
$citationDescription->addStatement('article-title', $value = 'PHPUnit in Kürze', 'de_DE');
$citationDescription->addStatement('date', $value = '2009-08-17');
$citationDescription->addStatement('size', $value = 320);
$citationDescription->addStatement('uri', $value = 'http://phpunit.org/nutshell');
// Add a simple source description.
$sourceDescription = new MetadataDescription($citationSchemaName, ASSOC_TYPE_CITATION);
$sourceDescription->setDisplayName('test');
$sourceDescription->addStatement('article-title', $value = 'a simple source description', 'en_US');
$sourceDescription->setSeq(0);
$citation = new Citation('raw citation');
$citation->setAssocType(ASSOC_TYPE_ARTICLE);
$citation->setAssocId(999999);
$citation->setSeq(50);
$citation->addSourceDescription($sourceDescription);
$citation->injectMetadata($citationDescription);
// Create citation.
$citationId = $citationDao->insertObject($citation);
self::assertTrue(is_numeric($citationId));
self::assertTrue($citationId > 0);
// Retrieve citation.
$citationById = $citationDao->getObjectById($citationId);
// Fix state differences for comparison.
$citation->removeSupportedMetadataAdapter($citationSchemaName);
$citationById->removeSupportedMetadataAdapter($citationSchemaName);
$citationById->_extractionAdaptersLoaded = true;
$citationById->_injectionAdaptersLoaded = true;
$sourceDescription->setAssocId($citationId);
$sourceDescription->removeSupportedMetadataAdapter($citationSchemaName);
$sourceDescriptions = $citationById->getSourceDescriptions();
$sourceDescriptions['test']->getMetadataSchema();
// this will instantiate the meta-data schema internally.
self::assertEquals($citation, $citationById);
$citationsByAssocIdDaoFactory = $citationDao->getObjectsByAssocId(ASSOC_TYPE_ARTICLE, 999999);
$citationsByAssocId = $citationsByAssocIdDaoFactory->toArray();
self::assertEquals(1, count($citationsByAssocId));
// Fix state differences for comparison.
$citationsByAssocId[0]->_extractionAdaptersLoaded = true;
$citationsByAssocId[0]->_injectionAdaptersLoaded = true;
$citationsByAssocId[0]->removeSupportedMetadataAdapter($citationSchemaName);
$sourceDescriptionsByAssocId = $citationsByAssocId[0]->getSourceDescriptions();
$sourceDescriptionsByAssocId['test']->getMetadataSchema();
// this will instantiate the meta-data schema internally.
self::assertEquals($citation, $citationsByAssocId[0]);
// Update citation.
$citationDescription->removeStatement('date');
$citationDescription->addStatement('article-title', $value = 'PHPUnit rápido', 'pt_BR');
// Update source descriptions.
$sourceDescription->addStatement('article-title', $value = 'edited source description', 'en_US', true);
$updatedCitation = new Citation('another raw citation');
$updatedCitation->setId($citationId);
$updatedCitation->setAssocType(ASSOC_TYPE_ARTICLE);
$updatedCitation->setAssocId(999998);
$updatedCitation->setSeq(50);
$updatedCitation->addSourceDescription($sourceDescription);
$updatedCitation->injectMetadata($citationDescription);
$citationDao->updateObject($updatedCitation);
$citationAfterUpdate = $citationDao->getObjectById($citationId);
// Fix state differences for comparison.
$updatedCitation->removeSupportedMetadataAdapter($citationSchemaName);
$citationAfterUpdate->removeSupportedMetadataAdapter($citationSchemaName);
$citationAfterUpdate->_extractionAdaptersLoaded = true;
$citationAfterUpdate->_injectionAdaptersLoaded = true;
$sourceDescriptionsAfterUpdate = $citationAfterUpdate->getSourceDescriptions();
$sourceDescriptionsAfterUpdate['test']->getMetadataSchema();
// this will instantiate the meta-data schema internally.
$sourceDescription->removeSupportedMetadataAdapter($citationSchemaName);
self::assertEquals($updatedCitation, $citationAfterUpdate);
// Delete citation
$citationDao->deleteObjectsByAssocId(ASSOC_TYPE_ARTICLE, 999998);
self::assertNull($citationDao->getObjectById($citationId));
}
示例3: MetadataDescription
/**
* Creates a new NLM citation description and adds the data
* of an array of property/value pairs as statements.
* @param $metadataArray array
* @return MetadataDescription
*/
function &getNlmCitationDescriptionFromMetadataArray(&$metadataArray)
{
// Create a new citation description
$citationDescription = new MetadataDescription('lib.pkp.classes.metadata.nlm.NlmCitationSchema', ASSOC_TYPE_CITATION);
// Add the meta-data to the description
$metadataArray = arrayClean($metadataArray);
if (!$citationDescription->setStatements($metadataArray)) {
$translationParams = array('filterName' => $this->getDisplayName());
$this->addError(Locale::translate('submission.citations.filter.invalidMetadata', $translationParams));
$nullVar = null;
return $nullVar;
}
// Set display name and sequence id in the meta-data description
// to the corresponding values from the filter. This is important
// so that we later know which result came from which filter.
$citationDescription->setDisplayName($this->getDisplayName());
$citationDescription->setSeq($this->getSeq());
return $citationDescription;
}