private function doResolveInnerConditionRecursively(DIProperty $property, Description $description) { $innerOrderByProperty = null; // Find out if we should order by the values of this property if (array_key_exists($property->getKey(), $this->compoundConditionBuilder->getSortKeys())) { $innerOrderByProperty = $property; } // Prepare inner condition $innerJoinVariable = $this->compoundConditionBuilder->getNextVariable(); $innerCondition = $this->compoundConditionBuilder->mapDescriptionToCondition($description, $innerJoinVariable, $innerOrderByProperty); return array($innerOrderByProperty, $innerCondition, $innerJoinVariable); }
/** * @note rdfs:subPropertyOf* where * means a property path of arbitrary length * can be found using the "zero or more" will resolve the complete path * * @see http://www.w3.org/TR/sparql11-query/#propertypath-arbitrary-length */ private function tryToAddPropertyPathForSaturatedHierarchy(&$condition, DIProperty $property, &$propertyName) { if (!$this->compoundConditionBuilder->canUseQFeature(SMW_SPARQL_QF_SUBP) || !$property->isUserDefined()) { return null; } if ($this->compoundConditionBuilder->getPropertyHierarchyLookup() == null || !$this->compoundConditionBuilder->getPropertyHierarchyLookup()->hasSubpropertyFor($property)) { return null; } $subPropExpElement = $this->exporter->getSpecialPropertyResource('_SUBP', SMW_NS_PROPERTY); $propertyByVariable = '?' . $this->compoundConditionBuilder->getNextVariable('sp'); $condition->weakConditions[$propertyName] = "\n" . "{$propertyByVariable} " . $subPropExpElement->getQName() . "*" . " {$propertyName} .\n" . ""; $propertyName = $propertyByVariable; }
private function tryToAddClassHierarchyPattern($category, &$categoryExpName) { if (!$this->compoundConditionBuilder->canUseQFeature(SMW_SPARQL_QF_SUBC)) { return ''; } if ($this->compoundConditionBuilder->getPropertyHierarchyLookup() === null || !$this->compoundConditionBuilder->getPropertyHierarchyLookup()->hasSubcategoryFor($category)) { return ''; } $subClassExpElement = $this->exporter->getSpecialPropertyResource('_SUBC'); $classHierarchyByVariable = "?" . $this->compoundConditionBuilder->getNextVariable('sc'); $condition = "{$classHierarchyByVariable} " . $subClassExpElement->getQName() . "*" . " {$categoryExpName} .\n"; $categoryExpName = "{$classHierarchyByVariable}"; return $condition; }
private function createConditionFromSubConditionElements($subConditionElements, $joinVariable) { if ($subConditionElements->unionCondition === '') { return $this->createFilterCondition($subConditionElements); } if ($subConditionElements->filter === '') { return $this->createWhereCondition($subConditionElements); } $subJoinVariable = $this->compoundConditionBuilder->getNextVariable(); $subConditionElements->unionCondition = str_replace("?{$joinVariable} ", "?{$subJoinVariable} ", $subConditionElements->unionCondition); $subConditionElements->filter .= " || ?{$joinVariable} = ?{$subJoinVariable}"; $subConditionElements->hasSafeSubconditions = false; $subConditionElements->unionCondition = "OPTIONAL { {$subConditionElements->unionCondition} }\n FILTER( {$subConditionElements->filter} )\n"; return $this->createWhereCondition($subConditionElements); }
private function createFilterConditionToMatchRegexPattern($dataItem, &$joinVariable, $comparator, $pattern) { if ($dataItem instanceof DIBlob) { return new FilterCondition("{$comparator}( ?{$joinVariable}, \"{$pattern}\", \"s\")", array()); } if ($dataItem instanceof DIUri) { return new FilterCondition("{$comparator}( str( ?{$joinVariable} ), \"{$pattern}\", \"i\")", array()); } // Pattern search for a wikipage object can only be done on the sortkey // literal and not on it's resource $skeyExpElement = Exporter::getInstance()->getSpecialPropertyResource('_SKEY'); $expElement = $this->exporter->getDataItemExpElement($dataItem->getSortKeyDataItem()); $condition = new SingletonCondition($expElement); $filterVariable = $this->compoundConditionBuilder->getNextVariable(); $condition->condition = "?{$joinVariable} " . $skeyExpElement->getQName() . " ?{$filterVariable} .\n"; $condition->matchElement = "?{$joinVariable}"; $filterCondition = new FilterCondition("{$comparator}( ?{$filterVariable}, \"{$pattern}\", \"s\")", array()); $condition->weakConditions = array($filterVariable => $filterCondition->getCondition()); return $condition; }