Soprano::Node NG::CopyVisitor::vertexProxy(const Soprano::Node & node) 
{
    if(node.isBlank())
	return node;

    if(node.isLiteral())
	return node;

    Soprano::Node answer;
    QHash< QUrl, QUrl >::const_iterator it =
	d->proxyUrls->find(node.uri());
    if(it == d->proxyUrls->end()) {
	// Create new

	// Create new url
	// FIXME What label should be passed to the generateUniqueUri
	answer = Soprano::Node(
		     d->targetManager->generateUniqueUri("unknown")
		 );
	Q_ASSERT(!answer.uri().isEmpty());

	// Add to table
	//kDebug() << "Adding proxy to " << node.uri() << " : " << answer.uri();
	d->proxyUrls->insert(node.uri(), answer.uri());
    } else {
	answer  = Soprano::Node(it.value());
    }

    return answer;
}
Beispiel #2
0
 QString getId( const Soprano::Node& node ) {
     if ( node.isResource() ) {
         return QString::fromLatin1( node.uri().toEncoded() );
     }
     else if ( node.isBlank() ) {
         return bnodeIdPrefix() + node.toString();
     }
     else {
         return QString();
     }
 }
QString NG::DotVisitor::vertexDescription(const Soprano::Node & node)
{
    if(node.isBlank()) {
        static QString blank("blank");
        return blank;
    } else if(node.isLiteral())
        return node.toString().replace('\"', "'");
    else { // Node is resource
        return node.uri().toString();
    }
}
QString NG::DotVisitor::vertexID(const Soprano::Node & node)
{
    if(node.isBlank()) {
        static QString blankTemplate("blank%1");
        d->vnum++;
        return blankTemplate.arg(QString::number(d->vnum));
    } else {
        QHash< Soprano::Node , int >::const_iterator fit =
            d->vertices.find(node);
        if(fit == d->vertices.end()) {
            // Write new node
            d->vnum++;
            d->vertices.insert(node, d->vnum);
            return QString::number(d->vnum);
        } else {
            return QString::number(fit.value());
        }
    }

}