Semantic MediaWiki and related extensions
Public Member Functions | Protected Member Functions | List of all members
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder Class Reference

Public Member Functions

 __construct (DescriptionInterpreterFactory $descriptionInterpreterFactory, EngineOptions $engineOptions=null)
 
 setResultVariable ($resultVariable)
 
 getNextVariable ($prefix= 'v')
 
 setSortKeys ($sortKeys)
 
 getSortKeys ()
 
 getErrors ()
 
 addError ($error, $type=Message::TEXT)
 
 setCircularReferenceGuard (CircularReferenceGuard $circularReferenceGuard)
 
 getCircularReferenceGuard ()
 
 setPropertyHierarchyLookup (PropertyHierarchyLookup $propertyHierarchyLookup)
 
 getPropertyHierarchyLookup ()
 
 setJoinVariable ($joinVariable)
 
 getJoinVariable ()
 
 setOrderByProperty ($orderByProperty)
 
 getOrderByProperty ()
 
 getConditionFrom (Description $description)
 
 mapDescriptionToCondition (Description $description)
 
 convertConditionToString (Condition &$condition)
 
 newTrueCondition ($joinVariable, $orderByProperty)
 
 tryToFindRedirectVariableForDataItem (DataItem $dataItem=null)
 
 canUseQFeature ($queryFeatureFlag)
 
 addOrderByDataForProperty (Condition &$sparqlCondition, $mainVariable, $orderByProperty, $diType=DataItem::TYPE_NOTYPE)
 
 addOrderByData (Condition &$condition, $mainVariable, $diType)
 

Protected Member Functions

 addMissingOrderByConditions (Condition &$condition)
 

Detailed Description

Build an internal representation for a SPARQL condition from individual query descriptions

GNU GPL v2+

Since
2.0
Author
Markus Krötzsch
mwjames

Constructor & Destructor Documentation

SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::__construct ( DescriptionInterpreterFactory  $descriptionInterpreterFactory,
EngineOptions  $engineOptions = null 
)
Since
2.2
Parameters
DescriptionInterpreterFactory$descriptionInterpreterFactory
EngineOptions | null$engineOptions

Member Function Documentation

SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::addError (   $error,
  $type = Message::TEXT 
)
Since
2.2
Parameters
string$error
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::addMissingOrderByConditions ( Condition $condition)
protected

Extend the given Condition with additional conditions to ensure that it can be ordered by all requested properties. After this operation, every key in sortKeys is assigned to a query variable by $sparqlCondition->orderVariables.

Parameters
Condition$conditioncondition to modify
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::addOrderByData ( Condition $condition,
  $mainVariable,
  $diType 
)

Extend the given SPARQL condition by a suitable order by variable, possibly adding conditions if required for the type of data.

Parameters
Condition$sparqlConditioncondition to modify
string$mainVariablethe variable that represents the value to be ordered
integer$diTypeDataItem type id
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::addOrderByDataForProperty ( Condition $sparqlCondition,
  $mainVariable,
  $orderByProperty,
  $diType = DataItem::TYPE_NOTYPE 
)

Extend the given SPARQL condition by a suitable order by variable, if an order by property is set.

Parameters
Condition$sparqlConditioncondition to modify
string$mainVariablethe variable that represents the value to be ordered
mixed$orderByPropertyDIProperty or null
integer$diTypeDataItem type id if known, or DataItem::TYPE_NOTYPE to determine it from the property
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::canUseQFeature (   $queryFeatureFlag)
Since
2.3
Parameters
integer$queryFeatureFlag
Returns
boolean
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::convertConditionToString ( Condition $condition)

Build the condition (WHERE) string for a given Condition. The function also expresses the single value of SingletonCondition objects in the condition, which may lead to additional namespaces for serializing its URI.

Parameters
Condition$condition
Returns
string
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getCircularReferenceGuard ( )
Since
2.2
Returns
CircularReferenceGuard
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getConditionFrom ( Description  $description)

Get a Condition object for a Description.

This conversion is implemented by a number of recursive functions, and this is the main entry point for this recursion. In particular, it resets global variables that are used for the construction.

If property value variables should be recorded for ordering results later on, the keys of the respective properties need to be given in sortKeys earlier.

Parameters
Description$description
Returns
Condition
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getErrors ( )
Since
2.2
Returns
array
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getJoinVariable ( )
Since
2.2
Returns
string
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getNextVariable (   $prefix = 'v')

Get a fresh unused variable name for building SPARQL conditions.

Returns
string
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getOrderByProperty ( )
Since
2.2
Returns
DIProperty|null
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getPropertyHierarchyLookup ( )
Since
2.3
Returns
PropertyHierarchyLookup
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::getSortKeys ( )
Since
2.1
Returns
array
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::mapDescriptionToCondition ( Description  $description)

Recursively create a Condition from a Description

Parameters
Description$description
Returns
Condition
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::newTrueCondition (   $joinVariable,
  $orderByProperty 
)

Create an Condition from an empty (true) description. May still require helper conditions for ordering.

Parameters
$joinVariablestring name, see mapDescriptionToCondition()
$orderByPropertymixed DIProperty or null, see mapDescriptionToCondition()
Returns
Condition
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::setCircularReferenceGuard ( CircularReferenceGuard  $circularReferenceGuard)
Since
2.2
Parameters
CircularReferenceGuard$circularReferenceGuard
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::setJoinVariable (   $joinVariable)
Since
2.2
Parameters
string$joinVariablename of the variable that conditions will refer to
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::setOrderByProperty (   $orderByProperty)
Since
2.2
Parameters
DIProperty | null$orderByPropertyif given then this is the property the values of which this condition will refer to, and the condition should also enable ordering by this value
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::setPropertyHierarchyLookup ( PropertyHierarchyLookup  $propertyHierarchyLookup)
Since
2.3
Parameters
PropertyHierarchyLookup$propertyHierarchyLookup
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::setResultVariable (   $resultVariable)
Since
2.0
Parameters
string$resultVariable
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::setSortKeys (   $sortKeys)
Since
2.0
Parameters
array$sortKeys
SMW\SPARQLStore\QueryEngine\CompoundConditionBuilder::tryToFindRedirectVariableForDataItem ( DataItem  $dataItem = null)
Since
2.3
Parameters
DataItem | null$dataItem
Returns
string|null

The documentation for this class was generated from the following file: