[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Soprano] c5dc7ba: Fixed addinf of literals with language set. Redlan
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-10-26 12:01:02
Message-ID: 20101026120102.BC0F3A6312 () git ! kde ! org
[Download RAW message or body]

commit c5dc7ba42123386d226ecdeea96b4ea5f96c1044
branch 2.2
Author: Sebastian Trueg <sebastian@trueg.de>
Date:   Fri Oct 17 09:43:30 2008 +0000

    Fixed addinf of literals with language set. Redland apparently does only handle \
datatype OR language, but not both  
    svn path=/trunk/kdesupport/soprano/; revision=872463

diff --git a/backends/redland/redlandmodel.cpp b/backends/redland/redlandmodel.cpp
index a6b8e25..a7e4a18 100644
--- a/backends/redland/redlandmodel.cpp
+++ b/backends/redland/redlandmodel.cpp
@@ -122,17 +122,21 @@ Soprano::Error::ErrorCode \
Soprano::Redland::RedlandModel::addStatement( const St  \
d->readWriteLock.lockForWrite();  
     librdf_statement* redlandStatement = d->world->createStatement( statement );
-    if ( !redlandStatement ) {
-        setError( d->world->lastError( Error::Error( "Could not convert redland \
statement", +    if ( !redlandStatement ||
+         !librdf_statement_get_subject( redlandStatement ) ||
+         !librdf_statement_get_predicate( redlandStatement ) ||
+         !librdf_statement_get_object( redlandStatement ) ) {
+        setError( d->world->lastError( Error::Error( "Could not convert to redland \
                statement",
                                                      Error::ErrorInvalidArgument ) ) \
);  d->readWriteLock.unlock();
         return Error::ErrorInvalidArgument;
     }
 
     if ( statement.context().isEmpty() ) {
-        if ( librdf_model_add_statement( d->model, redlandStatement ) ) {
+        if ( int r = librdf_model_add_statement( d->model, redlandStatement ) ) {
             d->world->freeStatement( redlandStatement );
-            setError( d->world->lastError() );
+            setError( d->world->lastError( Error::Error( QString( "Failed to add \
statement. Redland error code %1." ).arg( r ), +                                      \
Error::ErrorUnknown ) ) );  d->readWriteLock.unlock();
             return Error::ErrorUnknown;
         }
@@ -143,7 +147,7 @@ Soprano::Error::ErrorCode \
Soprano::Redland::RedlandModel::addStatement( const St  d->world->freeStatement( \
redlandStatement );  d->world->freeNode( redlandContext );
             setError( d->world->lastError( Error::Error( "Failed to add statement",
-                                                                       \
Error::ErrorUnknown ) ) ); +                                                         \
Error::ErrorUnknown ) ) );  d->readWriteLock.unlock();
             return Error::ErrorUnknown;
         }
diff --git a/backends/redland/redlandworld.cpp b/backends/redland/redlandworld.cpp
index ddab8f5..77911db 100644
--- a/backends/redland/redlandworld.cpp
+++ b/backends/redland/redlandworld.cpp
@@ -143,7 +143,7 @@ librdf_world* Soprano::Redland::World::worldPtr() const
 }
 
 
-librdf_node *Soprano::Redland::World::createNode( const Node &node )
+librdf_node *Soprano::Redland::World::createNode( const Node& node )
 {
     librdf_world *world = worldPtr();
 
@@ -157,7 +157,9 @@ librdf_node *Soprano::Redland::World::createNode( const Node \
&node )  return librdf_new_node_from_typed_literal( world,
                                                    (unsigned char \
                *)node.literal().toString().toUtf8().data(),
                                                    node.language().toUtf8().data(),
-                                                   librdf_new_uri( world, (const \
unsigned char*)node.dataType().toEncoded().data() ) ); +                              \
node.language().isEmpty() // redland does only handle non-empty lang values for \
rdfs:Literal +                                                   ? librdf_new_uri( \
world, (const unsigned char*)node.dataType().toEncoded().data() ) +                   \
: 0 );  }
 
     return 0;
@@ -209,7 +211,7 @@ Soprano::Statement Soprano::Redland::World::createStatement( \
librdf_statement *s  librdf_node *predicate = librdf_statement_get_predicate( st );
     librdf_node *object = librdf_statement_get_object( st );
 
-    return Soprano::Statement( createNode( subject), createNode( predicate), \
createNode( object ) ); +    return Soprano::Statement( createNode( subject ), \
createNode( predicate ), createNode( object ) );  }
 
 void Soprano::Redland::World::freeNode( librdf_node* node )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic