Hey Christian
On Fri, Jun 24, 2011 at 12:42 AM, Christian Mollekopf
<[email protected]>wrote:
> btw. also DataManagementModelTest::testStoreResources_duplicates fails for
> me, don't know if it is related or not.
>
No. That's something I need to fix, but it's not a priority.
I investigated the problem. And here is what I found -
* In the test suite nie:isPartOf had been given the wrong range. I've
corrected it.
* The test I wrote for you was wrong. The resource with label
"testresource2" should have a nie:isPartOf connecting it to the resource
with label "testResource1". I've fixed the test, and it runs fine. Almost.
* The correct nie:isPartOf relation is added
Now, here is the problem -
nao:prefLabel has a rdfs:range of rdfs:Literal. And if I create a
Soprano::LiteralValue("something"), that turns into a literal with the data
type xsd:string. So, I'm not sure how I should write this test.
@ Trueg:
Please take a look at the attached patch.
@ Christain:
The test runs perfectly otherwise. Something else is wrong. If you tell me
what exactly you're doing maybe we can figure it out.
> On Thu, 23 Jun 2011 20:58:23 +0200, Christian Mollekopf
> <[email protected]> wrote:
>
> > Hey,
> >
> > Today I faced a problem when setting the nie:isPartOf property on a
> > SimpleResource item.
> > In the akonadi feeder storing would always fail with a message like:
> > "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf has a
> > rdfs:range of
> >
> http://www.semanticdesktop.org/ontologies/2007/01/19/nie#InformationElement
> ."
> >
> > which is at least a correct statement, but I made sure that all resources
> > have the types informationelement and DataObject, so it should work.
> >
> > Second I wrote a little test app:
> >
> > SimpleResourceGraph graph;
> > SimpleResource res;
> > res.setProperty( Soprano::Vocabulary::NAO::prefLabel(),
> > "testresource"
> > );
> > res.setTypes(QList <QUrl>() << Vocabulary::NIE::DataObject() <<
> > Vocabulary::NIE::InformationElement());
> > graph.insert(res);
> > SimpleResource res2;
> > res2.setProperty( Soprano::Vocabulary::NAO::prefLabel(),
> > "testresource2" );
> > res2.setTypes(QList <QUrl>() << Vocabulary::NIE::DataObject() <<
> > Vocabulary::NIE::InformationElement());
> > res2.addProperty( Vocabulary::NIE::isPartOf(), res );
> > graph.insert(res2);
> > KJob *job = graph.save();
> >
> > This actually worked without errors, but the property ended up on the
> > wrong resource (testresource instead of tesetresource2).
> > Vishesh had a quick look at this one.
> >
> > He then put this into a unittest in datamanagementmodeltest.cpp, here we
> > both experienced the same issue:
> >
> > QDEBUG : DataManagementModelTest::testStoreResource_nieIsPartOf()
> > qttest(30079)/nepomuk (storage service) Nepomuk::ResourceMerger::merge:
> > Invalid resource range. QUrl( "_:zb" ) has types
> > (QUrl("
> http://www.semanticdesktop.org/ontologies/2007/01/19/nie#DataObject")
> > , QUrl(
> > "
> http://www.semanticdesktop.org/ontologies/2007/01/19/nie#InformationElement
> "
> > ) )
> > QDEBUG : DataManagementModelTest::testStoreResource_nieIsPartOf()
> >
> "/home/chrigi/devel/kde/build/kde-runtime/nepomuk/services/storage/test/datamanagementmodeltest(30079)"
> > Soprano: "Invalid argument (1)":
> > "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf has a
> > rdfs:range of
> > http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject
> ."
> > QDEBUG : DataManagementModelTest::testStoreResource_nieIsPartOf()
> > qttest(30079)/nepomuk (storage service)
> > Nepomuk::DataManagementModel::storeResources: MERGING FAILED!
> > QDEBUG : DataManagementModelTest::testStoreResource_nieIsPartOf()
> >
> "/home/chrigi/devel/kde/build/kde-runtime/nepomuk/services/storage/test/datamanagementmodeltest(30079)"
> > Soprano: "Invalid argument (1)":
> > "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf has a
> > rdfs:range of
> > http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject
> ."
> >
> > The reported range is actually wrong, as nie:isPartOf has a range of
> > nie:InformationElement, and not nie:DataObject (repectively
> > nfo:FileDataObject).
> >
> > Here are the tests I used: http://paste.kde.org/86809/
> > The first one doesn't work it seems. It is very well possible that it is
> > also not supposed to work this way.
> >
> > Anyways, I'm stuck, any help appreciated =)
> >
> > Cheers,
> >
> > Chris
> > _______________________________________________
> > Nepomuk mailing list
> > [email protected]
> > https://mail.kde.org/mailman/listinfo/nepomuk
>
>
> --
> Using Opera's revolutionary email client: http://www.opera.com/mail/
> _______________________________________________
> Nepomuk mailing list
> [email protected]
> https://mail.kde.org/mailman/listinfo/nepomuk
>
--
Vishesh Handa
diff --git a/nepomuk/services/storage/test/datamanagementmodeltest.cpp b/nepomuk/services/storage/test/datamanagementmodeltest.cpp
index 1594bc5..c36900d 100644
--- a/nepomuk/services/storage/test/datamanagementmodeltest.cpp
+++ b/nepomuk/services/storage/test/datamanagementmodeltest.cpp
@@ -162,7 +162,8 @@ void DataManagementModelTest::resetModel()
m_model->addStatement( NFO::hasHash(), RDFS::domain(), NFO::FileDataObject(), graph );
m_model->addStatement( NIE::isPartOf(), RDF::type(), RDF::Property(), graph );
- m_model->addStatement( NIE::isPartOf(), RDFS::range(), NFO::FileDataObject(), graph );
+ m_model->addStatement( NIE::isPartOf(), RDFS::domain(), NIE::DataObject(), graph );
+ m_model->addStatement( NIE::isPartOf(), RDFS::range(), NIE::InformationElement(), graph );
m_model->addStatement( NIE::lastModified(), RDF::type(), RDF::Property(), graph );
m_model->addStatement( NIE::lastModified(), RDFS::range(), XMLSchema::dateTime(), graph );
@@ -4068,6 +4069,46 @@ void DataManagementModelTest::testStoreResources_correctRangeInStore()
QVERIFY(!m_dmModel->lastError());
}
+void DataManagementModelTest::testStoreResource_nieIsPartOf()
+{
+ SimpleResourceGraph graph;
+ SimpleResource res;
+ res.setProperty( NAO::prefLabel(), "testresource" );
+ res.addType( NIE::DataObject() );
+ res.addType( NIE::InformationElement() );
+ graph << res;
+
+ SimpleResource res2;
+ res2.setProperty( NAO::prefLabel(), QLatin1String("testresource2") );
+ res2.addType( NIE::DataObject() );
+ res2.addType( NIE::InformationElement() );
+ res2.addProperty( NIE::isPartOf(), res );
+ graph << res2;
+
+ m_dmModel->storeResources( graph, QLatin1String("app") );
+
+ QList< Statement > stList = m_model->listStatements( Node(), NIE::isPartOf(), Node() ).allStatements();
+ QCOMPARE( stList.size(), 1 );
+
+ Statement st = stList.first();
+
+ QList<Statement> l1 = m_model->listStatements( st.subject(), NAO::prefLabel(), Node() ).allStatements();
+ QList<Statement> l2 = m_model->listStatements( st.object(), NAO::prefLabel(), Node() ).allStatements();
+
+ QCOMPARE( l1.size(), 1 );
+ QCOMPARE( l2.size(), 1 );
+
+ Statement s1 = l1.first();
+ Statement s2 = l2.first();
+
+ // s1 should have nao:prefLabel "testresource2"
+ QCOMPARE( s1.object().literal().toString(), QLatin1String("testresource2") );
+
+ // s1 should have nao:prefLabel "testresource2"
+ QCOMPARE( s2.object().literal().toString(), QLatin1String("testresource") );
+}
+
+
void DataManagementModelTest::testMergeResources()
{
// first we need to create the two resources we want to merge as well as one that should not be touched
diff --git a/nepomuk/services/storage/test/datamanagementmodeltest.h b/nepomuk/services/storage/test/datamanagementmodeltest.h
index 4ca9894..d1cc8c4 100644
--- a/nepomuk/services/storage/test/datamanagementmodeltest.h
+++ b/nepomuk/services/storage/test/datamanagementmodeltest.h
@@ -125,6 +125,7 @@ private Q_SLOTS:
void testStoreResources_duplicates();
void testStoreResources_correctDomainInStore();
void testStoreResources_correctRangeInStore();
+ void testStoreResource_nieIsPartOf();
void testMergeResources();
void testMergeResources_protectedTypes();
_______________________________________________
Nepomuk mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/nepomuk