Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
void NG::DotVisitor::enter_edge(const Soprano::Node &  currentNode, const Soprano::Node &  propertyNode, const Soprano::Node &  childNode)
{
    static QString edgeTemplate = QString(" v%1 -> v%2 [label=\"%3\"]\n");
    *d->stream << edgeTemplate.arg(
                  vertexID(currentNode),
                  vertexID(childNode),
                  propertyNode.uri().fragment()
              );
}
Exemplo n.º 3
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();
     }
 }
Exemplo n.º 4
0
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();
    }
}
Exemplo n.º 5
0
bool Nepomuk::Types::PropertyPrivate::addProperty( const QUrl& property, const Soprano::Node& value )
{
    // we avoid subclassing loops (as created for crappy inferencing) by checking for our own uri
    if( value.isResource() &&
        value.uri() != uri &&
        property == Soprano::Vocabulary::RDFS::subPropertyOf() ) {
        parents.append( value.uri() );
        return true;
    }

    else if( property == Soprano::Vocabulary::RDFS::domain() ) {
        domain = value.uri();
        return true;
    }

    else if( property == Soprano::Vocabulary::RDFS::range() ) {
        if ( value.toString().startsWith( Soprano::Vocabulary::XMLSchema::xsdNamespace().toString() ) ) {
            literalRange = Literal( value.uri() );
        }
        else if ( value.uri() == Soprano::Vocabulary::RDFS::Literal()) {
            literalRange = Literal( value.uri() );
        }
        else {
            range = value.uri();
        }
        return true;
    }

    else if( property == Soprano::Vocabulary::NRL::minCardinality() ) {
        minCardinality = value.literal().toInt();
        return true;
    }

    else if( property == Soprano::Vocabulary::NRL::maxCardinality() ) {
        maxCardinality = value.literal().toInt();
        return true;
    }

    else if ( property == Soprano::Vocabulary::NRL::cardinality() ) {
        cardinality = value.literal().toInt();
        return true;
    }

    else if ( property == Soprano::Vocabulary::NRL::inverseProperty() ) {
        inverse = value.uri();
        return true;
    }

    return false;
}