QString KoRdfSemanticItemViewSite::getProperty(const QString &prop, const QString &defval) const
{
    Soprano::Node ls = linkingSubject();
    QString fqprop = "http://koffice.org/rdf/site#" + prop;
    KoDocumentRdf *rdf = d->m_semItem->documentRdf();
    Soprano::Model *m = rdf->model();
    StatementIterator it = m->listStatements(ls, Node::createResourceNode(QUrl(fqprop)),
                               Node(), rdf->manifestRdfNode());
    QList<Statement> allStatements = it.allElements();
    foreach (Soprano::Statement s, allStatements) {
        return s.object().toString();
    }
    return defval;
}
예제 #2
0
void SkosSerializer::serializeStatemetsToFile(
  const QString &p_fileName,
  const Soprano::RdfSerialization &p_fileType)
{ 
  const Soprano::Serializer* serializer =
    Soprano::PluginManager::instance()->discoverSerializerForSerialization( 
      p_fileType);
  QFile l_outputFile(p_fileName);
  l_outputFile.open(QIODevice::WriteOnly);
  QTextStream l_stream(&l_outputFile);
  Soprano::Model* sopranoModel = Soprano::createModel();
  sopranoModel->addStatements(m_statements);
  serializer->serialize(sopranoModel->listStatements(), 
                        l_stream, 
                        p_fileType);
}
Soprano::Node KoRdfSemanticItemViewSite::linkingSubject() const
{
    KoDocumentRdf *rdf = d->m_semItem->documentRdf();
    Soprano::Model *m = rdf->model();
    Node pred(QUrl("http://koffice.org/rdf/site/package/common#idref"));
    Node obj = Node::createLiteralNode(d->m_xmlid);
    Node context = rdf->manifestRdfNode();
    // try to find it if it already exists
    StatementIterator it = m->listStatements(Node(), pred, obj, context);
    QList<Statement> allStatements = it.allElements();
    foreach (Soprano::Statement s, allStatements) {
        return s.subject();
    }
    Node ret = m->createBlankNode();
    m->addStatement(ret, pred, obj, context);
    return ret;
}