本文整理汇总了PHP中SMWExporter::getResourceElementForProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWExporter::getResourceElementForProperty方法的具体用法?PHP SMWExporter::getResourceElementForProperty怎么用?PHP SMWExporter::getResourceElementForProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWExporter
的用法示例。
在下文中一共展示了SMWExporter::getResourceElementForProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doMapSomeProperty
private function doMapSomeProperty(SomeProperty $description, &$exact)
{
$result = new ExpData(new ExpResource(''));
$result->addPropertyObjectValue($this->exporter->getSpecialNsResource('rdf', 'type'), new ExpData($this->exporter->getSpecialNsResource('owl', 'Restriction')));
$property = $description->getProperty();
if ($property->isInverse()) {
$property = new DIProperty($property->getKey());
}
$result->addPropertyObjectValue($this->exporter->getSpecialNsResource('owl', 'onProperty'), new ExpData($this->exporter->getResourceElementForProperty($property)));
$subdata = $this->getExpDataFromDescription($description->getDescription(), $exact);
if ($description->getDescription() instanceof ValueDescription && $description->getDescription()->getComparator() === SMW_CMP_EQ) {
$result->addPropertyObjectValue($this->exporter->getSpecialNsResource('owl', 'hasValue'), $subdata);
} else {
if ($subdata === false) {
$owltype = $this->exporter->getOWLPropertyType($description->getProperty()->findPropertyTypeID());
if ($owltype == 'ObjectProperty') {
$subdata = new ExpData($this->exporter->getSpecialNsResource('owl', 'Thing'));
} elseif ($owltype == 'DatatypeProperty') {
$subdata = new ExpData($this->exporter->getSpecialNsResource('rdfs', 'Literal'));
} else {
// no restrictions at all with annotation properties ...
return new ExpData($this->exporter->getSpecialNsResource('owl', 'Thing'));
}
}
$result->addPropertyObjectValue($this->exporter->getSpecialNsResource('owl', 'someValuesFrom'), $subdata);
}
return $result;
}
示例2: getResourceElementHelperForProperty
protected function getResourceElementHelperForProperty($property)
{
$key = 'resource:builder:aux:' . $property->getKey();
if (($resourceElement = $this->inMemoryPoolCache->fetch($key)) !== false) {
return $resourceElement;
}
$resourceElement = $this->exporter->getResourceElementForProperty($property, true);
$this->inMemoryPoolCache->save($key, $resourceElement);
return $resourceElement;
}
示例3: getPropertyNameByUsingTurtleSerializer
private function getPropertyNameByUsingTurtleSerializer(DIProperty $property, DIProperty $nonInverseProperty, &$namespaces)
{
// Use helper properties in encoding values, refer to this helper property:
if ($this->exporter->hasHelperExpElement($property)) {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty, true);
} else {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty);
}
if ($propertyExpElement instanceof ExpNsResource) {
$namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
}
return TurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
}
示例4: findMostSuitablePropertyRepresentation
private function findMostSuitablePropertyRepresentation(DIProperty $property, DIProperty $nonInverseProperty, &$namespaces)
{
$redirectByVariable = $this->compoundConditionBuilder->tryToFindRedirectVariableForDataItem($nonInverseProperty->getDiWikiPage());
// If the property is represented by a redirect then use the variable instead
if ($redirectByVariable !== null) {
return $redirectByVariable;
}
// Use helper properties in encoding values, refer to this helper property:
if ($this->exporter->hasHelperExpElement($property)) {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty, true);
} elseif (!$property->isUserDefined()) {
$propertyExpElement = $this->exporter->getSpecialPropertyResource($nonInverseProperty->getKey(), SMW_NS_PROPERTY);
} else {
$propertyExpElement = $this->exporter->getResourceElementForProperty($nonInverseProperty);
}
if ($propertyExpElement instanceof ExpNsResource) {
$namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
}
return TurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
}
示例5: buildPropertyCondition
/**
* Recursively create an SMWSparqlCondition from an SMWSomeProperty.
*
* @param $description SMWSomeProperty
* @param $joinVariable string name, see buildSparqlCondition()
* @param $orderByProperty mixed SMWDIProperty or null, see buildSparqlCondition()
* @return SMWSparqlCondition
*/
protected function buildPropertyCondition(SMWSomeProperty $description, $joinVariable, $orderByProperty)
{
$diProperty = $description->getProperty();
//*** Find out if we should order by the values of this property ***//
if (array_key_exists($diProperty->getKey(), $this->m_sortkeys)) {
$innerOrderByProperty = $diProperty;
} else {
$innerOrderByProperty = null;
}
//*** Prepare inner condition ***//
$innerJoinVariable = $this->getNextVariable();
$innerCondition = $this->buildSparqlCondition($description->getDescription(), $innerJoinVariable, $innerOrderByProperty);
$namespaces = $innerCondition->namespaces;
if ($innerCondition instanceof SMWSparqlFalseCondition) {
return new SMWSparqlFalseCondition();
} elseif ($innerCondition instanceof SMWSparqlSingletonCondition) {
$matchElement = $innerCondition->matchElement;
$objectName = SMWTurtleSerializer::getTurtleNameForExpElement($matchElement);
if ($matchElement instanceof SMWExpNsResource) {
$namespaces[$matchElement->getNamespaceId()] = $matchElement->getNamespace();
}
} else {
$objectName = '?' . $innerJoinVariable;
}
//*** Exchange arguments when property is inverse ***//
if ($diProperty->isInverse()) {
// don't check if this really makes sense
$subjectName = $objectName;
$objectName = '?' . $joinVariable;
$diNonInverseProperty = new SMWDIProperty($diProperty->getKey(), false);
} else {
$subjectName = '?' . $joinVariable;
$diNonInverseProperty = $diProperty;
}
//*** Build the condition ***//
$typeId = $diProperty->findPropertyTypeID();
$diType = SMWDataValueFactory::getDataItemId($typeId);
// for types that use helper properties in encoding values, refer to this helper property:
if (SMWExporter::hasHelperExpElement($diType)) {
$propertyExpElement = SMWExporter::getResourceElementForProperty($diNonInverseProperty, true);
} else {
$propertyExpElement = SMWExporter::getResourceElementForProperty($diNonInverseProperty);
}
$propertyName = SMWTurtleSerializer::getTurtleNameForExpElement($propertyExpElement);
if ($propertyExpElement instanceof SMWExpNsResource) {
$namespaces[$propertyExpElement->getNamespaceId()] = $propertyExpElement->getNamespace();
}
$condition = "{$subjectName} {$propertyName} {$objectName} .\n";
$innerConditionString = $innerCondition->getCondition() . $innerCondition->getWeakConditionString();
if ($innerConditionString !== '') {
if ($innerCondition instanceof SMWSparqlFilterCondition) {
$condition .= $innerConditionString;
} else {
$condition .= "{ {$innerConditionString}}\n";
}
}
$result = new SMWSparqlWhereCondition($condition, true, $namespaces);
//*** Record inner ordering variable if found ***//
$result->orderVariables = $innerCondition->orderVariables;
if (!is_null($innerOrderByProperty) && $innerCondition->orderByVariable !== '') {
$result->orderVariables[$diProperty->getKey()] = $innerCondition->orderByVariable;
}
$this->addOrderByDataForProperty($result, $joinVariable, $orderByProperty, SMWDataItem::TYPE_WIKIPAGE);
return $result;
}