本文整理汇总了PHP中SMWPropertyValue::setDataItem方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWPropertyValue::setDataItem方法的具体用法?PHP SMWPropertyValue::setDataItem怎么用?PHP SMWPropertyValue::setDataItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWPropertyValue
的用法示例。
在下文中一共展示了SMWPropertyValue::setDataItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeProperty
/**
* Static function for creating a new property object from a property
* identifier (string) as it might be used internally. This might be
* the DB key version of some property title text or the id of a
* predefined property (such as '_TYPE').
* @note This function strictly requires an internal identifier, i.e.
* predefined properties must be referred to by their ID, and '-' is
* not supported for indicating inverses.
* @note The resulting property object might be invalid if
* the provided name is not allowed. An object is returned
* in any case.
*/
public static function makeProperty($propertyid)
{
$diProperty = new SMWDIProperty($propertyid);
$dvProperty = new SMWPropertyValue('__pro');
$dvProperty->setDataItem($diProperty);
return $dvProperty;
}
示例2: newPropertyPrintRequest
/**
* @since 2.1
*
* @param DIProperty $property
*
* @return PrintRequest
*/
public function newPropertyPrintRequest(DIProperty $property)
{
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$instance = new PrintRequest(PrintRequest::PRINT_PROP, $propertyValue->getWikiValue(), $propertyValue);
return $instance;
}
示例3: searchForResultsThatCompareEqualToClassOf
private function searchForResultsThatCompareEqualToClassOf($categoryName)
{
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem(new DIProperty('_INST'));
$description = new ClassDescription(new DIWikiPage($categoryName, NS_CATEGORY, ''));
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
return $this->getStore()->getQueryResult($query);
}
示例4: searchForResultsThatCompareEqualToOnlySingularPropertyOf
private function searchForResultsThatCompareEqualToOnlySingularPropertyOf(DIProperty $property)
{
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description = new SomeProperty($property, new ThingDescription());
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description);
$query->querymode = Query::MODE_INSTANCES;
return $this->getStore()->getQueryResult($query);
}
示例5: testSetLabel
public function testSetLabel()
{
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem(new DIProperty('Foo'));
$instance = new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue);
$this->assertEquals(null, $instance->getLabel());
$this->assertEquals(null, $instance->getWikiText());
$instance->setLabel('Bar');
$this->assertEquals('Bar', $instance->getLabel());
$this->assertEquals('Bar', $instance->getWikiText());
}
示例6: testCreatePageWithSubobjectParserFunctionForQueryResultLookup
public function testCreatePageWithSubobjectParserFunctionForQueryResultLookup()
{
$this->titles[] = Title::newFromText('CreatePageWithSubobjectParserFunction');
$pageCreator = new PageCreator();
$pageCreator->createPage(Title::newFromText('Has subobject parser function test', SMW_NS_PROPERTY))->doEdit('[[Has type::Page]]');
$property = DIProperty::newFromUserLabel('Has subobject parser function test');
$pageCreator->createPage($this->titles[0])->doEdit('{{#subobject:|Has subobject parser function test=WXYZ|@sortkey=B}}' . '{{#subobject:|Has subobject parser function test=ABCD|@sortkey=A}}' . '{{#subobject:|Has subobject parser function test=ABCD|@sortkey=A}}' . '{{#subobject:|Has subobject parser function test=ABCD|@sortkey=C}}');
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description = new SomeProperty($property, new ThingDescription());
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_COUNT;
$result = $this->getStore()->getQueryResult($query);
$this->assertEquals(3, $result instanceof \SMWQueryResult ? $result->getCountValue() : $result);
$query->querymode = Query::MODE_INSTANCES;
$this->assertCount(3, $this->getStore()->getQueryResult($query)->getResults());
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:18,代码来源:ParserFunctionInPageEmbeddedForQueryResultLookupDBIntegrationTest.php
示例7: testUserDefinedBlobProperty
public function testUserDefinedBlobProperty()
{
$property = new DIProperty('SomeBlobProperty');
$property->setPropertyTypeId('_txt');
$dataItem = new DIBlob('SomePropertyBlobValue');
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$semanticData->addDataValue($this->dataValueFactory->newDataItemValue($dataItem, $property));
$this->getStore()->updateData($semanticData);
$this->assertArrayHasKey($property->getKey(), $this->getStore()->getSemanticData($semanticData->getSubject())->getProperties());
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description = new SomeProperty($property, new ThingDescription());
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$queryResult = $this->getStore()->getQueryResult($query);
$this->queryResultValidator->assertThatQueryResultContains($dataItem, $queryResult);
}
示例8: testSpecialCharactersInQuery
/**
* @dataProvider specialCharactersNameProvider
*/
public function testSpecialCharactersInQuery($subject, $subobjectId, $property, $dataItem)
{
$dataValue = $this->dataValueFactory->newDataItemValue($dataItem, $property);
$semanticData = $this->semanticDataFactory->newEmptySemanticData($subject);
$semanticData->addDataValue($dataValue);
$subobject = new Subobject($semanticData->getSubject()->getTitle());
$subobject->setEmptyContainerForId($subobjectId);
$subobject->addDataValue($dataValue);
$semanticData->addSubobject($subobject);
$this->getStore()->updateData($semanticData);
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description = new SomeProperty($property, new ThingDescription());
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$this->queryResultValidator->assertThatQueryResultHasSubjects(array($semanticData->getSubject(), $subobject->getSubject()), $this->getStore()->getQueryResult($query));
$this->queryResultValidator->assertThatQueryResultContains($dataValue, $this->getStore()->getQueryResult($query));
$this->subjectsToBeCleared = array($semanticData->getSubject(), $subobject->getSubject(), $property->getDIWikiPage());
}
示例9: testRandomOrder
public function testRandomOrder()
{
$factsheet = $this->fixturesProvider->getFactsheet('Berlin');
$populationValue = $factsheet->getPopulationValue();
$this->getStore()->updateData($factsheet->asEntity());
/**
* @query [[Population::+]]
*/
$property = $this->fixturesProvider->getProperty('Population');
$description = new SomeProperty($property, new ThingDescription());
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$query->sort = true;
$query->sortkeys = array('Population' => 'RANDOM');
$queryResult = $this->getStore()->getQueryResult($query);
$this->assertEquals(3, $queryResult->getCount());
}
示例10: testSortableRecordQuery
public function testSortableRecordQuery()
{
$this->getStore()->updateData($this->fixturesProvider->getFactsheet('Berlin')->asEntity());
$this->getStore()->updateData($this->fixturesProvider->getFactsheet('Paris')->asEntity());
/**
* PopulationDensity is specified as `_rec`
*
* @query {{#ask: [[PopulationDensity::SomeDistinctValue]] }}
*/
$populationDensityValue = $this->fixturesProvider->getFactsheet('Berlin')->getPopulationDensityValue();
$description = new SomeProperty($populationDensityValue->getProperty(), $populationDensityValue->getQueryDescription($populationDensityValue->getWikiValue()));
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($populationDensityValue->getProperty());
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$query->sortkeys = array($populationDensityValue->getProperty()->getKey() => 'ASC');
$query->setLimit(100);
$query->setExtraPrintouts(array(new PrintRequest(PrintRequest::PRINT_THIS, ''), new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)));
$expected = array($this->fixturesProvider->getFactsheet('Berlin')->asSubject(), $this->fixturesProvider->getFactsheet('Berlin')->getDemographics()->getSubject());
$this->queryResultValidator->assertThatQueryResultHasSubjects($expected, $this->getStore()->getQueryResult($query));
}
示例11: testSubpropertyToQueryFromTopHierarchy
public function testSubpropertyToQueryFromTopHierarchy()
{
if (!$this->getStore() instanceof \SMWSQLStore3) {
$this->markTestSkipped("Subproperty/property hierarchies are currently only supported by the SQLStore");
}
$semanticDataOfSpouse = $this->semanticDataFactory->setSubject(new DIWikiPage('Spouse', SMW_NS_PROPERTY, ''))->newEmptySemanticData();
$property = new DIProperty('Wife');
$property->setPropertyTypeId('_wpg');
$this->addPropertyHierarchy($property, 'Spouse');
$dataValue = $this->dataValueFactory->newPropertyObjectValue($property, 'Lien');
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$semanticData->addDataValue($dataValue);
$this->getStore()->updateData($semanticDataOfSpouse);
$this->getStore()->updateData($semanticData);
$description = new SomeProperty(new DIProperty('Spouse'), new ThingDescription());
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$queryResult = $this->getStore()->getQueryResult($query);
$this->queryResultValidator->assertThatQueryResultContains($dataValue, $queryResult);
$this->subjectsToBeCleared = array($semanticData->getSubject(), $semanticDataOfSpouse->getSubject(), $property->getDiWikiPage());
}
示例12: createQuery
private function createQuery($queryString, $mode, array $printouts = array())
{
$description = $this->queryParser->getQueryDescription($queryString);
foreach ($printouts as $printout) {
$property = DIProperty::newFromUserLabel($printout);
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
}
$query = new Query($description, false, false);
$query->setUnboundlimit($this->queryLimit);
$query->setOffset($this->queryOffset);
$query->querymode = $mode;
return $query;
}
示例13: testQueryToCompareEqualNumericPropertyValuesAssignedToDifferentSubject
/**
* {{#ask: [[SomeNumericPropertyToDifferentSubject::9999]]
* |?SomeNumericPropertyToDifferentSubject
* }}
*/
public function testQueryToCompareEqualNumericPropertyValuesAssignedToDifferentSubject()
{
$semanticDataWithSubobject = $this->semanticDataFactory->setTitle(__METHOD__ . '-withSobj')->newEmptySemanticData();
$semanticDataWithoutSubobject = $this->semanticDataFactory->setTitle(__METHOD__ . '-wwithoutSobj')->newEmptySemanticData();
$expectedDataValueToMatchCondition = $this->newDataValueForNumericPropertyValue('SomeNumericPropertyToDifferentSubject', 9999);
$dataValueWithSamePropertyButDifferentValue = $this->newDataValueForNumericPropertyValue('SomeNumericPropertyToDifferentSubject', 1111);
$subobject = new Subobject($semanticDataWithSubobject->getSubject()->getTitle());
$subobject->setEmptyContainerForId('SomeSubobjectToDifferentSubject');
$subobject->addDataValue($expectedDataValueToMatchCondition);
$semanticDataWithSubobject->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$semanticDataWithSubobject->addDataValue($dataValueWithSamePropertyButDifferentValue);
$semanticDataWithoutSubobject->addDataValue($expectedDataValueToMatchCondition);
$this->getStore()->updateData($semanticDataWithSubobject);
$this->getStore()->updateData($semanticDataWithoutSubobject);
$property = new DIProperty('SomeNumericPropertyToDifferentSubject');
$property->setPropertyTypeId('_num');
$dataItem = new DINumber(9999);
$description = new SomeProperty($property, new ValueDescription($dataItem, null, SMW_CMP_EQ));
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
$query = new Query($description, false, false);
$queryResult = $this->getStore()->getQueryResult($query);
$this->assertEquals(2, $queryResult->getCount());
$this->queryResultValidator->assertThatQueryResultContains($expectedDataValueToMatchCondition, $queryResult);
$expectedSubjects = array($subobject->getSemanticData()->getSubject(), $semanticDataWithoutSubobject->getSubject());
$this->queryResultValidator->assertThatQueryResultHasSubjects($expectedSubjects, $queryResult);
$this->subjectsToBeCleared = array($semanticDataWithoutSubobject->getSubject(), $semanticDataWithSubobject->getSubject());
}
示例14: testSortableDateQuery
/**
* #576
*/
public function testSortableDateQuery()
{
$this->getStore()->updateData($this->fixturesProvider->getFactsheet('Berlin')->asEntity());
// #576 introduced resource caching, therefore make sure that the
// instance is cleared after data have been created before further
// tests are carried out
Exporter::clear();
/**
* @query {{#ask: [[Founded::SomeDistinctValue]] }}
*/
$foundedValue = $this->fixturesProvider->getFactsheet('Berlin')->getFoundedValue();
$description = new SomeProperty($foundedValue->getProperty(), new ValueDescription($foundedValue->getDataItem(), null, SMW_CMP_EQ));
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($foundedValue->getProperty());
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$query->sortkeys = array($foundedValue->getProperty()->getLabel() => 'ASC');
// Be aware of
// Virtuoso 22023 Error SR353: Sorted TOP clause specifies more then
// 10001 rows to sort. Only 10000 are allowed. Either decrease the
// offset and/or row count or use a scrollable cursor
$query->setLimit(100);
$query->setExtraPrintouts(array(new PrintRequest(PrintRequest::PRINT_THIS, ''), new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)));
$queryResult = $this->getStore()->getQueryResult($query);
$this->queryResultValidator->assertThatQueryResultHasSubjects($this->fixturesProvider->getFactsheet('Berlin')->asSubject(), $queryResult);
}
示例15: getExtraPrintouts
/**
* @since 2.2
*
* @return array
*/
public function getExtraPrintouts()
{
$extraPrintouts = array();
if (!isset($this->contents['printouts']) || $this->contents['printouts'] === array()) {
return $extraPrintouts;
}
foreach ($this->contents['printouts'] as $printout) {
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem(DIProperty::newFromUserLabel($printout));
$extraPrintouts[] = new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue);
}
return $extraPrintouts;
}