Open Semantic Framework PHP API  3.0
 All Data Structures Namespaces Files Functions Variables Pages
ExtendedFiltersBuilder Class Reference

Class used to generate a set of extended attribute filters that should be added to a SearchQuery. More...

Public Member Functions

 __construct ()
 
 getExtendedFilters ()
 Return the list of filters generated by the ExtendedFiltersBuilder class used by the OSF Search endpoint for the "extended_filters" parameter. More...
 
 datasetFilter ($dataset)
 Add a dataset URI to filter. More...
 
 typeFilter ($type, $enableInference=FALSE)
 Add a type URI to filter. More...
 
 attributeValueFilter ($attribute, $value="*", $valueIsUri=FALSE)
 Add an attribute/value filter. More...
 
 and_ ()
 Add a AND operator to the extended filters query. More...
 
 or_ ()
 Add a OR operator to the extended filters query. More...
 
 not_ ()
 Add a NOT operator to the extended filters query. More...
 
 startGrouping ()
 Start grouping a series of filters. More...
 
 endGrouping ()
 End grouping a series of filters. More...
 

Detailed Description

Class used to generate a set of extended attribute filters that should be added to a SearchQuery.

These extended attributes filters support grouping of attributes/values filters along with the boolean operators AND, OR and NOT.

Here is an example of how this API should be used to create an extended search filters for the SearchQuery class:

$search = new SearchQuery($network);
$extendedFiltersBuilder = new ExtendedFiltersBuilder();
$results = $search->mime("resultset")
->extendedFilters(
$extendedFiltersBuilder->startGrouping()
->attributeValueFilter("http://purl.org/ontology/iron#prefLabel", "cancer AND NOT (breast OR ovarian)")
->endGrouping()
->and_()
->startGrouping()
->attributeValueFilter("http://purl.org/ontology/nhccn#useGroupSignificant", "http://purl.org/ontology/doha#liver_cancer", TRUE)
->or_()
->attributeValueFilter("http://purl.org/ontology/nhccn#useGroupSignificant", "cancer")
->endGrouping()
->and_()
->datasetFilter("file://localhost/data/ontologies/files/doha.owl")
->getExtendedFilters())
->send()
->getResultset();

This code will produce this "extended_filters" parameter value:

(http%253A%252F%252Fpurl.org%252Fontology%252Firon%2523prefLabel:cancer%2BAND%2BNOT%2B%2528breast%2BOR%2Bovarian%2529) AND (http%253A%252F%252Fpurl.org%252Fontology%252Fnhccn%2523useGroupSignificant[uri]:http%255C%253A%252F%252Fpurl.org%252Fontology%252Fdoha%2523liver_cancer OR http%253A%252F%252Fpurl.org%252Fontology%252Fnhccn%2523useGroupSignificant:cancer) AND dataset:%22file%3A%2F%2Flocalhost%2Fdata%2Fontologies%2Ffiles%2Fdoha.owl%22

See also
http://wiki.opensemanticframework.org/index.php/Search
Author
Frederick Giasson, Structured Dynamics LLC.

Definition at line 56 of file ExtendedFiltersBuilder.php.

Constructor & Destructor Documentation

__construct ( )

Definition at line 63 of file ExtendedFiltersBuilder.php.

Member Function Documentation

and_ ( )

Add a AND operator to the extended filters query.

Definition at line 147 of file ExtendedFiltersBuilder.php.

attributeValueFilter (   $attribute,
  $value = "*",
  $valueIsUri = FALSE 
)

Add an attribute/value filter.

Parameters
mixed$attributeAttribute URI to add to the extended filters query.
mixed$valueValue to filter by. By default, all values are used ("*")
boolean$valueIsUriSpecify if the value (or set of values) for this attribute have to be considered as URIs (this should be specified to TRUE if the attribute is an object property)
Returns
ExtendedFiltersBuilder

Definition at line 118 of file ExtendedFiltersBuilder.php.

datasetFilter (   $dataset)

Add a dataset URI to filter.

Parameters
mixed$datasetDataset URI to add to the extended filters query.
Returns
ExtendedFiltersBuilder

Definition at line 80 of file ExtendedFiltersBuilder.php.

endGrouping ( )

End grouping a series of filters.

Definition at line 187 of file ExtendedFiltersBuilder.php.

getExtendedFilters ( )

Return the list of filters generated by the ExtendedFiltersBuilder class used by the OSF Search endpoint for the "extended_filters" parameter.

Definition at line 69 of file ExtendedFiltersBuilder.php.

not_ ( )

Add a NOT operator to the extended filters query.

Definition at line 167 of file ExtendedFiltersBuilder.php.

or_ ( )

Add a OR operator to the extended filters query.

Definition at line 157 of file ExtendedFiltersBuilder.php.

startGrouping ( )

Start grouping a series of filters.

Definition at line 177 of file ExtendedFiltersBuilder.php.

typeFilter (   $type,
  $enableInference = FALSE 
)

Add a type URI to filter.

Parameters
mixed$typeType URI to add to the extended filters query.
mixed$enableInferenceEnable inferencing for this type filter.
Returns
ExtendedFiltersBuilder

Definition at line 94 of file ExtendedFiltersBuilder.php.