Soprano.Model

KDE 4.2 PyKDE API Reference

- KDE's Python API

# Model Class Reference

`from PyKDE4.soprano import *`

Inherits: QObject,Soprano::Error::ErrorCache
Subclasses: Soprano.FilterModel, Soprano.StorageModel, Soprano::Util::DummyModel, Soprano::Util::ReadOnlyModel
Namespace: Soprano

## Detailed Description

Abstract class:
  This class can be used as a base class for new classes, but can not be instantiated directly.

## Signals
| statementAdded (Soprano.Statement statement)
| statementRemoved (Soprano.Statement statement)
| statementsAdded ()
| statementsRemoved ()
## Methods
| __init__ (self)
| __init__ (self, Soprano.Model a0)
Soprano.Error.ErrorCode | addStatement (self, Soprano.Statement statement)
Soprano.Error.ErrorCode | addStatement (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
Soprano.Error.ErrorCode | addStatements (self, [Soprano.Statement] statements)
bool | containsAnyStatement (self, Soprano.Statement statement)
bool | containsAnyStatement (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
bool | containsContext (self, Soprano.Node context)
bool | containsStatement (self, Soprano.Statement statement)
bool | containsStatement (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
Soprano.Node | createBlankNode (self)
Soprano.QueryResultIterator | executeQuery (self, QString query, Soprano.Query.QueryLanguage language, QString userQueryLanguage=QString())
bool | isEmpty (self)
Soprano.NodeIterator | listContexts (self)
Soprano.StatementIterator | listStatements (self, Soprano.Statement partial)
Soprano.StatementIterator | listStatements (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
Soprano.StatementIterator | listStatements (self)
Soprano.StatementIterator | listStatementsInContext (self, Soprano.Node context)
Soprano.Error.ErrorCode | removeAllStatements (self, Soprano.Statement statement)
Soprano.Error.ErrorCode | removeAllStatements (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
Soprano.Error.ErrorCode | removeAllStatements (self)
Soprano.Error.ErrorCode | removeContext (self, Soprano.Node a0)
Soprano.Error.ErrorCode | removeStatement (self, Soprano.Statement statement)
Soprano.Error.ErrorCode | removeStatement (self, Soprano.Node subject, Soprano.Node predicate, Soprano.Node object, Soprano.Node context=Soprano.Node())
Soprano.Error.ErrorCode | removeStatements (self, [Soprano.Statement] statements)
| statementAdded (self, Soprano.Statement statement)
int | statementCount (self)
| statementRemoved (self, Soprano.Statement statement)
| statementsAdded (self)
| statementsRemoved (self)
Soprano.Error.ErrorCode | write (self, QTextStream os)

## Method Documentation

__init__ | ( |  | self ) |

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

Model instances are not meant to be copied.

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

Abstract method:
  This method is abstract and can be overridden but not called directly.

Add the Statement to the Model.

Parameters:

  | statement | The Statement to add.

Soprano.Error.ErrorCode addStatement | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Soprano.Error.ErrorCode addStatements | ( | self, |
|  | [Soprano.Statement] | statements
| ) |  |  |

bool containsAnyStatement | ( | self, |
|  | Soprano.Statement | statement
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Check if the model contains certain statements.

Parameters:

  | statement | A partially defined statement that serves as a pattern.

Returns:
  true if the Model contains a Statement matching the given statement pattern.

bool containsAnyStatement | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Parameters:

  | subject | The subject node to match. Can be empty as a wildcard.

Parameters:

  | predicate | The predicate node to match. Can be empty as a wildcard.

Parameters:

  | object | The object node to match. Can be empty as a wildcard.

Parameters:

  | context | The context node to match. Can be empty as a wildcard.

bool containsContext | ( | self, |
|  | Soprano.Node | context
| ) |  |  |

Convenience method which is based on containsAnyStatement

bool containsStatement | ( | self, |
|  | Soprano.Statement | statement
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Check if the model contains a statements.

Parameters:

  | statement | The statement in question. This has to be a valid statement, i.e. subject, predicate, and object need to be defined. If the context node is empty the default graph is searched.

Returns:
  true if the Model contains the Statement, false otherwise or is statement is invalid.

bool containsStatement | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Soprano.Node createBlankNode | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Creates a new blank node with a unique identifier.

Returns:
  A blank node that can be used to create new statements.

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

Abstract method:
  This method is abstract and can be overridden but not called directly.

Execute the given query over the Model.

This is a const read-only method. As such Model implementations should not support SPARQL extensions such as INSERT or UPDATE through this method. A future version of %Soprano will provide an additional API for queries that change the Model.

Parameters:

  | query | The query to evaluate.

Parameters:

  | language | The %query language used to encode query.

Parameters:

  | userQueryLanguage | If language equals Query.QueryLanguageUser userQueryLanguage defines the language to use.

Returns:
  An iterator over all results matching the query, on error an invalid iterator is returned.

bool isEmpty | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Returns:
  true if the Model doesn't contains any Statement.

Soprano.NodeIterator listContexts | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

List all contexts in the model, i.e. all named graphs.

Returns:
  An iterator over context Nodes, on error an invalid iterator is returned.

Soprano.StatementIterator listStatements | ( | self, |
|  | Soprano.Statement | partial
| ) |  |  |

Abstract method:
  This method is abstract and can be overridden but not called directly.

Return an iterator over Model Statements that "partial" match the input Statement.

Parameters:

  | partial | The partial Statement to match.

Returns:
  An iterator for all the matched Statements, on error an invalid iterator is returned.

Soprano.StatementIterator listStatements | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Parameters:

  | subject | The subject node to match. Can be empty as a wildcard.

Parameters:

  | predicate | The predicate node to match. Can be empty as a wildcard.

Parameters:

  | object | The object node to match. Can be empty as a wildcard.

Parameters:

  | context | The context node to match. Can be empty as a wildcard.

Returns:
  An iterator for all the matched Statements, on error an invalid iterator is returned.

Soprano.StatementIterator listStatements | ( |  | self ) |

Returns:
  An iterator for all statements in the model, on error an invalid iterator is returned.

Soprano.StatementIterator listStatementsInContext | ( | self, |
|  | Soprano.Node | context
| ) |  |  |

Convenience method which lists all statements in context.

Returns:
  An iterator for all the matched Statements, on error an invalid iterator is returned.

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

Abstract method:
  This method is abstract and can be overridden but not called directly.

Remove all statements that match the partial statement. For removing one specific statement see removeStatement().

Parameters:

  | statement | A possible partially defined statement that serves as a filter for all statements that should be removed.

Soprano.Error.ErrorCode removeAllStatements | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Parameters:

  | subject | The subject node to match. Can be empty as a wildcard.

Parameters:

  | predicate | The predicate node to match. Can be empty as a wildcard.

Parameters:

  | object | The object node to match. Can be empty as a wildcard.

Parameters:

  | context | The context node to match. Can be empty as a wildcard.

Soprano.Error.ErrorCode removeAllStatements | ( |  | self ) |

Convenience method that clear the Model of all statements

Soprano.Error.ErrorCode removeContext | ( | self, |
|  | Soprano.Node | a0
| ) |  |  |

Convenience method that removes all statements in the context.

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

Abstract method:
  This method is abstract and can be overridden but not called directly.

Remove one statement. For removing statements with wildward matching see removeAllStatements().

Parameters:

  | statement | The statement that should be removed. This has to be a valid statement.

Returns:
  Error.ErrorNone on success and an error code if statement was invalid or an error occured.

Soprano.Error.ErrorCode removeStatement | ( | self, |
|  | Soprano.Node | subject,
|  | Soprano.Node | predicate,
|  | Soprano.Node | object,
|  | Soprano.Node | context=Soprano.Node()
| ) |  |  |

Soprano.Error.ErrorCode removeStatements | ( | self, |
|  | [Soprano.Statement] | statements
| ) |  |  |

Convenience method which removes all %statements in statements.

statementAdded | ( | self, |
|  | Soprano.Statement | statement
| ) |  |  |

Notification signal for new statements. Model implementations should emit this signal for each newly added statement.

Signal syntax:
  `QObject.connect(source, SIGNAL("statementAdded(const Statement&)"), target_slot)`

int statementCount | ( |  | self ) |

Abstract method:
  This method is abstract and can be overridden but not called directly.

The number of statements stored in this Model.

Returns:
  The size of the Model, or -1 on error.

statementRemoved | ( | self, |
|  | Soprano.Statement | statement
| ) |  |  |

Notification signal for removed statements. Model implementations should emit this signal for each removed statement.

Warning:
  Backends may choose not to emit this signal for each removed statement but only for a statement pattern (i.e. an invalid statement as used in removeAllStatements()) to prevent massive performance loss.

Signal syntax:
  `QObject.connect(source, SIGNAL("statementRemoved(const Statement&)"), target_slot)`

statementsAdded | ( |  | self ) |

Emitted when new statements have been added to the model.

Implementations of this interface have to emit this signal.

Signal syntax:
  `QObject.connect(source, SIGNAL("statementsAdded()"), target_slot)`

statementsRemoved | ( |  | self ) |

Emitted when statements have been removed from the model.

Implementations of this interface have to emit this signal.

Signal syntax:
  `QObject.connect(source, SIGNAL("statementsRemoved()"), target_slot)`

Soprano.Error.ErrorCode write | ( | self, |
|  | QTextStream | os
| ) |  |  |

Write all statements in this Model to os.

Default implementation is based on Model.listStatements