Soprano.NRLModel

KDE 4.5 PyKDE API Reference

- KDE's Python API

# NRLModel Class Reference

`from PyKDE4.soprano import *`

Inherits: Soprano.FilterModel → Soprano.Model → QObject
Namespace: Soprano

## Detailed Description

\class NRLModel nrlmodel.h Soprano/NRLModel

Model filter that makes working with NRL data simpler.

The NRLModel enforces NRL cardinality rules. That means predicates with a cardinality of maximum 1 are always udpated while statements that define predicates with a maximum cardinality bigger than 1 are rejected once the maximum is reached (future versions might remove an earlier defined statement based on the time the old statements were added).

Thus, at the moment NRLModel is mostly usable for handling properties with a maximum cardinality of 1.

NRLModel also provides automatic query prefix expansion and named graph creation and removal with automatic metadata graph handling.

THE API AND EVEN THE COMPLETE CLASS IS SUBJECT TO CHANGE!

Author:
  Sebastian Trueg <trueg@kde.org>

\sa Vocabulary.NRL

## Methods
| __init__ (self)
| __init__ (self, Soprano.Model parent)
Soprano.Error.ErrorCode | addNrlStatement (self, Soprano.Statement s)
QUrl | createGraph (self, QUrl type, QUrl metadataGraph=0)
Soprano.QueryResultIterator | executeQuery (self, QString query, Soprano.Query.QueryLanguage language, QString userQueryLanguage=QString())
bool | ignoreContext (self)
bool | queryPrefixExpansionEnabled (self)
{QString:QUrl} | queryPrefixes (self)
Soprano.Error.ErrorCode | removeAllStatements (self, Soprano.Statement statement)
Soprano.Error.ErrorCode | removeGraph (self, QUrl graph)
| setEnableQueryPrefixExpansion (self, bool enable)
| setIgnoreContext (self, bool b)

## Method Documentation

__init__ | ( |  | self ) |

__init__ | ( | self, |
|  | Soprano.Model | parent
| ) |  |  |

Soprano.Error.ErrorCode addNrlStatement | ( | self, |
|  | Soprano.Statement | s
| ) |  |  |

Add a statement.

Parameters:

  | s | The statement containing the property to be set. If the predicate has NRL cardinality restrictions existing statements will be updated. Otherwise this method has the same effect as Model.addStatement().

Adding a statement that defines a predicate with a maximum cardinality bigger than 1 which has already been reached fails with an error.

Returns:
  Error.ErrorNone on success.

QUrl createGraph | ( | self, |
|  | QUrl | type,
|  | QUrl | metadataGraph=0
| ) |  |  |

Create a new graph of type type.

This will actually create two graphs: the requested one and its metadata graph which will already contain basic metadata like creation date.

Returns:
  The URI of the newly created graph.

Since:
  2.3

Soprano.QueryResultIterator executeQuery | ( | self, |
|  | QString | query,
|  | Soprano.Query.QueryLanguage | language,
|  | QString | userQueryLanguage=QString()
| ) |  |  |

If queryPrefixExpansionEnabled is true query prefixes will be expanded before sending the query to the underlying model.

Since:
  2.4

bool ignoreContext | ( |  | self ) |

Returns:
  true if contexts should be ignored when enforcing NRL rules.

\sa setIgnoreContext()

bool queryPrefixExpansionEnabled | ( |  | self ) |

Returns:
  true if query prefix expansion is enabled.

Since:
  2.4

{QString:QUrl} queryPrefixes | ( |  | self ) |

The prefixes that have been read from the underlying model.

Returns:
  A list of prefixes mapping to the namespaces read from the model. This list is empty if queryPrefixExpansion is disabled.

Since:
  2.4

Soprano.Error.ErrorCode removeAllStatements | ( | self, |
|  | Soprano.Statement | statement
| ) |  |  |

If the only node defined in statement is the context the graph including its metadata is removed.

\sa removeGraph

Since:
  2.4

Soprano.Error.ErrorCode removeGraph | ( | self, |
|  | QUrl | graph
| ) |  |  |

Remove a complete graph including its metadata graph

This method can be seen as the counterpart to createGraph

Since:
  2.3

setEnableQueryPrefixExpansion | ( | self, |
|  | bool | enable
| ) |  |  |

Enable automatic query prefix expansion based on nao:hasDefaultNamespaceAbbreviation. This will trigger reading all prefixes stored in the underlying model.

By default query prefix expansion is disabled.

Since:
  2.4

setIgnoreContext | ( | self, |
|  | bool | b
| ) |  |  |

When enforcing the NRL cardinality rules NRLModel can either ignore the context of statements or treat different contexts as separate sets, each resetting the cardinality.

Parameters:

  | b | If true (the default) NRLModel does ignore the context when enforcing rules. If false the NRL rules can be violated across contexts.

By default contexts are ignored.

\sa ignoreContext()