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

List:       kde-commits
Subject:    Re: [nepomuk-core/feature/virtuosoInference] services/storage: Remove visibility support from ClassA
From:       Sebastian_Trüg <trueg () kde ! org>
Date:       2012-04-01 10:04:49
Message-ID: 4F782841.5050103 () kde ! org
[Download RAW message or body]

It does not. But the crappy inferencer 2 also handled the visibility
updates.

On 03/31/2012 09:18 PM, Vishesh Handa wrote:
> 
> On Sun, Apr 1, 2012 at 12:30 AM, Sebastian Trueg <trueg@kde.org
> <mailto:trueg@kde.org>> wrote:
> 
>     Git commit dded30ce71027815817007b1e854fdabad2774c8 by Sebastian Trueg.
>     Committed on 31/03/2012 at 20:58.
>     Pushed by trueg into branch 'feature/virtuosoInference'.
> 
>     Remove visibility support from ClassAndPropertyTree.
> 
>     Now that we changed the visibility handling and removed the crappy
>     inferencer 2 there is no need for the visibility handling anymore.
> 
> 
> How does visibility handling having anything to do with inferencing?
>  
> 
> 
>     M  +4    -77   services/storage/classandpropertytree.cpp
>     M  +1    -6    services/storage/classandpropertytree.h
>     M  +5    -38   services/storage/test/classandpropertytreetest.cpp
>     M  +1    -3    services/storage/test/classandpropertytreetest.h
> 
>     http://commits.kde.org/nepomuk-core/dded30ce71027815817007b1e854fdabad2774c8
> 
>     diff --git a/services/storage/classandpropertytree.cpp
>     b/services/storage/classandpropertytree.cpp
>     index 046525b..98954ae 100644
>     --- a/services/storage/classandpropertytree.cpp
>     +++ b/services/storage/classandpropertytree.cpp
>     @@ -52,7 +52,6 @@ public:
>         ClassOrProperty()
>             : isProperty(false),
>               maxCardinality(0),
>     -          userVisible(0),
>               defining(0) {
>         }
> 
>     @@ -71,9 +70,6 @@ public:
>         /// the max cardinality if this is a property with a max
>     cardinality set, 0 otherwise
>         int maxCardinality;
> 
>     -    /// 0 - undecided, 1 - visible, -1 - non-visible
>     -    int userVisible;
>     -
>         /// 0 - undecided, 1 - defining, -1 - non-defining
>         int defining;
> 
>     @@ -148,15 +144,6 @@ int
>     Nepomuk::ClassAndPropertyTree::maxCardinality(const QUrl &type) const
>             return 0;
>      }
> 
>     -bool Nepomuk::ClassAndPropertyTree::isUserVisible(const QUrl &type)
>     const
>     -{
>     -    QMutexLocker lock(&m_mutex);
>     -    if(const ClassOrProperty* cop = findClassOrProperty(type))
>     -        return cop->userVisible == 1;
>     -    else
>     -        return true;
>     -}
>     -
>      QUrl Nepomuk::ClassAndPropertyTree::propertyDomain(const QUrl &uri)
>     const
>      {
>         QMutexLocker lock(&m_mutex);
>     @@ -345,14 +332,12 @@ void
>     Nepomuk::ClassAndPropertyTree::rebuildTree(Soprano::Model* model)
>                                       "OPTIONAL { ?r rdfs:subPropertyOf
>     ?p . ?p a rdf:Property . } . } "
>                                       "OPTIONAL { ?r %1 ?mc . } . "
>                                       "OPTIONAL { ?r %2 ?c . } . "
>     -                                  "OPTIONAL { ?r %3 ?v . } . "
>     -                                  "OPTIONAL { ?r %4 ?domain . } . "
>     -                                  "OPTIONAL { ?r %5 ?range . } . "
>     -                                  "FILTER(?r!=%6) . "
>     +                                  "OPTIONAL { ?r %3 ?domain . } . "
>     +                                  "OPTIONAL { ?r %4 ?range . } . "
>     +                                  "FILTER(?r!=%5) . "
>                                       "}" )
>                 .arg(Soprano::Node::resourceToN3(NRL::maxCardinality()),
>                      Soprano::Node::resourceToN3(NRL::cardinality()),
>     -                 Soprano::Node::resourceToN3(NAO::userVisible()),
>                      Soprano::Node::resourceToN3(RDFS::domain()),
>                      Soprano::Node::resourceToN3(RDFS::range()),
>                      Soprano::Node::resourceToN3(RDFS::Resource()));
>     @@ -381,10 +366,6 @@ void
>     Nepomuk::ClassAndPropertyTree::rebuildTree(Soprano::Model* model)
> 
>             r_cop->isProperty = it["pt"].isValid();
> 
>     -        if( v.isLiteral() ) {
>     -            r_cop->userVisible = (v.literal().toBool() ? 1 : -1);
>     -        }
>     -
>             if(mc > 0 || c > 0) {
>                 r_cop->maxCardinality = qMax(mc, c);
>             }
>     @@ -420,7 +401,7 @@ void
>     Nepomuk::ClassAndPropertyTree::rebuildTree(Soprano::Model* model)
>         if(m_tree.contains(NAO::identifier()))
>             m_tree[NAO::identifier()]->range = XMLSchema::string();
> 
>     -    // make sure rdfs:Resource is visible by default
>     +    // add rdfs:Resource as parent for all top-level classes
>         ClassOrProperty* rdfsResourceNode = 0;
>         QHash<QUrl, ClassOrProperty*>::iterator rdfsResourceIt =
>     m_tree.find(RDFS::Resource());
>         if( rdfsResourceIt == m_tree.end() ) {
>     @@ -431,10 +412,6 @@ void
>     Nepomuk::ClassAndPropertyTree::rebuildTree(Soprano::Model* model)
>         else {
>             rdfsResourceNode = rdfsResourceIt.value();
>         }
>     -    if( rdfsResourceNode->userVisible == 0 ) {
>     -        rdfsResourceNode->userVisible = 1;
>     -    }
>     -    // add rdfs:Resource as parent for all top-level classes
>         for ( QHash<QUrl, ClassOrProperty*>::iterator it = m_tree.begin();
>               it != m_tree.end(); ++it ) {
>             if( it.value() != rdfsResourceNode &&
>     it.value()->directParents.isEmpty() ) {
>     @@ -442,13 +419,6 @@ void
>     Nepomuk::ClassAndPropertyTree::rebuildTree(Soprano::Model* model)
>             }
>         }
> 
>     -    // update all visibility
>     -    for ( QHash<QUrl, ClassOrProperty*>::iterator it = m_tree.begin();
>     -          it != m_tree.end(); ++it ) {
>     -        QSet<QUrl> visitedNodes;
>     -        updateUserVisibility( it.value(), visitedNodes );
>     -    }
>     -
>         // complete the allParents lists
>         for ( QHash<QUrl, ClassOrProperty*>::iterator it = m_tree.begin();
>               it != m_tree.end(); ++it ) {
>     @@ -508,36 +478,6 @@ bool
>     Nepomuk::ClassAndPropertyTree::contains(const QUrl& uri) const
> 
> 
>      /**
>     - * Set the value of nao:userVisible.
>     - * A class is visible if it has at least one visible direct parent
>     class.
>     - */
>     -int Nepomuk::ClassAndPropertyTree::updateUserVisibility(
>     ClassOrProperty* cop, QSet<QUrl>& visitedNodes )
>     -{
>     -    if ( cop->userVisible != 0 ) {
>     -        return cop->userVisible;
>     -    }
>     -    else {
>     -        for ( QSet<QUrl>::iterator it = cop->directParents.begin();
>     -             it != cop->directParents.end(); ++it ) {
>     -            // avoid endless loops
>     -            if( visitedNodes.contains(*it) )
>     -                continue;
>     -            visitedNodes.insert(*it);
>     -            if ( updateUserVisibility( m_tree[*it], visitedNodes )
>     == 1 ) {
>     -                cop->userVisible = 1;
>     -                break;
>     -            }
>     -        }
>     -        if ( cop->userVisible == 0 ) {
>     -            // default to invisible
>     -            cop->userVisible = -1;
>     -        }
>     -        //kDebug() << "Setting nao:userVisible of" <<
>     cop->uri.toString() << ( cop->userVisible == 1 );
>     -        return cop->userVisible;
>     -    }
>     -}
>     -
>     -/**
>      * Set the value of defining.
>      * An defining property has at least one defining direct parent
>     property.
>      */
>     @@ -625,19 +565,6 @@ QList<Soprano::Statement>
>     Nepomuk::ClassAndPropertyTree::simpleResourceGraphToSt
>         return list;
>      }
> 
>     -QList<QUrl> Nepomuk::ClassAndPropertyTree::visibleTypes() const
>     -{
>     -    QList<QUrl> types;
>     -    QHash<QUrl, ClassOrProperty*>::const_iterator end =
>     m_tree.constEnd();
>     -    for(QHash<QUrl, ClassOrProperty*>::const_iterator it =
>     m_tree.constBegin(); it != end; ++it) {
>     -        const ClassOrProperty* cop = *it;
>     -        if(!cop->isProperty && cop->userVisible == 1) {
>     -            types << cop->uri;
>     -        }
>     -    }
>     -    return types;
>     -}
>     -
>      Nepomuk::ClassAndPropertyTree * Nepomuk::ClassAndPropertyTree::self()
>      {
>         return s_self;
>     diff --git a/services/storage/classandpropertytree.h
>     b/services/storage/classandpropertytree.h
>     index b54daeb..508004a 100644
>     --- a/services/storage/classandpropertytree.h
>     +++ b/services/storage/classandpropertytree.h
>     @@ -1,6 +1,6 @@
>      /*
>        This file is part of the Nepomuk KDE project.
>     -   Copyright (C) 2010 Sebastian Trueg <trueg@kde.org
>     <mailto:trueg@kde.org>>
>     +   Copyright (C) 2010-2012 Sebastian Trueg <trueg@kde.org
>     <mailto:trueg@kde.org>>
> 
>        This library is free software; you can redistribute it and/or
>        modify it under the terms of the GNU Lesser General Public
>     @@ -64,7 +64,6 @@ public:
>          */
>         bool isChildOf(const QList<QUrl> & types, const QUrl&
>     superClass) const;
>         int maxCardinality(const QUrl& type) const;
>     -    bool isUserVisible(const QUrl& type) const;
> 
>         QUrl propertyDomain(const QUrl& uri) const;
>         QUrl propertyRange(const QUrl& uri) const;
>     @@ -75,9 +74,6 @@ public:
>         /// \return \p true if \p uri is an defining property, \p false
>     otherwise
>         bool isDefiningProperty(const QUrl& uri) const;
> 
>     -    /// \return A list of all known rdf classes that are visible
>     (nao:userVisible)
>     -    QList<QUrl> visibleTypes() const;
>     -
>         /// will try very hard to convert a variant into a node.
>     Supports literal XML types and QUrl
>         Soprano::Node variantToNode(const QVariant& value, const QUrl&
>     property) const;
>         QSet<Soprano::Node> variantListToNodeSet(const QVariantList& vl,
>     const QUrl& property) const;
>     @@ -94,7 +90,6 @@ private:
>         class ClassOrProperty;
> 
>         const ClassOrProperty* findClassOrProperty(const QUrl& uri) const;
>     -    int updateUserVisibility(ClassOrProperty *cop, QSet<QUrl>
>     &visitedNodes);
>         int updateDefining(ClassOrProperty* cop, QSet<QUrl>& definingNodes);
>         QSet<QUrl> getAllParents(ClassOrProperty *cop, QSet<QUrl>
>     &visitedNodes);
> 
>     diff --git a/services/storage/test/classandpropertytreetest.cpp
>     b/services/storage/test/classandpropertytreetest.cpp
>     index 6d6ee75..acd2d5f 100644
>     --- a/services/storage/test/classandpropertytreetest.cpp
>     +++ b/services/storage/test/classandpropertytreetest.cpp
>     @@ -1,6 +1,6 @@
>      /*
>        This file is part of the Nepomuk KDE project.
>     -   Copyright (C) 2010-2011 Sebastian Trueg <trueg@kde.org
>     <mailto:trueg@kde.org>>
>     +   Copyright (C) 2010-2012 Sebastian Trueg <trueg@kde.org
>     <mailto:trueg@kde.org>>
> 
>        This library is free software; you can redistribute it and/or
>        modify it under the terms of the GNU Lesser General Public
>     @@ -64,30 +64,24 @@ void ClassAndPropertyTreeTest::init()
>         // we create one fake ontology
>         //
>         // situations we need to test:
>     -    // * class that is marked visible should stay visible
>     -    // * class that is marked invisible should stay invisible
>     -    // * non-marked subclass of visible should be visible, too
>     -    // * non-marked subclass of invisible should be invisible, too
>         // * marked subclass should keep its own visiblity and not
>     inherit from parent
>         // * whole branch should inherit from parent
>     -    // * if one parent is visible the class is visible, too, even
>     if N other parents are not
>     -    // * if all parents are invisible, the class is invisible, even
>     if higher up in the branch a class is visible
>         // * properly handle loops (as in: do not run into an endless loop)
>         //
>         // A
>     -    // |- B - invisible
>     +    // |- B
>         //    |- C
>     -    //       |- D - visible
>     +    //       |- D
>         //          |- E
>         //             |- F
>         //    |- G
>         //
>     -    // AA - invisible
>     +    // AA
>         // | - F
>         // | - G
>         //
>         // X
>     -    // |- Y - invisible
>     +    // |- Y
>         //    |- Z
>         //       |- X
> 
>     @@ -146,21 +140,6 @@ void ClassAndPropertyTreeTest::init()
>         m_typeTree->rebuildTree(m_model);
>      }
> 
>     -void ClassAndPropertyTreeTest::testVisibility()
>     -{
>     -    QVERIFY(m_typeTree->isUserVisible(QUrl("onto:/A")));
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/B")));
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/C")));
>     -    QVERIFY(m_typeTree->isUserVisible(QUrl("onto:/D")));
>     -    QVERIFY(m_typeTree->isUserVisible(QUrl("onto:/E")));
>     -    QVERIFY(m_typeTree->isUserVisible(QUrl("onto:/F")));
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/G")));
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/AA")));
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/X"))); //
>     because only top-level classes inherit from rdfs:Resource
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/Y")));
>     -    QVERIFY(!m_typeTree->isUserVisible(QUrl("onto:/Z")));
>     -}
>     -
>      void ClassAndPropertyTreeTest::testParents()
>      {
>         QCOMPARE(m_typeTree->allParents(QUrl("onto:/A")).count(), 1);
>     @@ -273,18 +252,6 @@ void ClassAndPropertyTreeTest::testProperties()
>         QCOMPARE(m_typeTree->maxCardinality(QUrl("prop:/D")), 1);
>      }
> 
>     -void ClassAndPropertyTreeTest::testVisibleType()
>     -{
>     -    const QList<QUrl> types = m_typeTree->visibleTypes();
>     -    kDebug() << types;
>     -    QCOMPARE(types.count(), 5);
>     -    QVERIFY(types.contains(RDFS::Resource()));
>     -    QVERIFY(types.contains(QUrl("onto:/A")));
>     -    QVERIFY(types.contains(QUrl("onto:/D")));
>     -    QVERIFY(types.contains(QUrl("onto:/E")));
>     -    QVERIFY(types.contains(QUrl("onto:/F")));
>     -}
>     -
>      QTEST_KDEMAIN_CORE(ClassAndPropertyTreeTest)
> 
>      #include "classandpropertytreetest.moc"
>     diff --git a/services/storage/test/classandpropertytreetest.h
>     b/services/storage/test/classandpropertytreetest.h
>     index 29d961b..f078d91 100644
>     --- a/services/storage/test/classandpropertytreetest.h
>     +++ b/services/storage/test/classandpropertytreetest.h
>     @@ -1,6 +1,6 @@
>      /*
>        This file is part of the Nepomuk KDE project.
>     -   Copyright (C) 2010-2011 Sebastian Trueg <trueg@kde.org
>     <mailto:trueg@kde.org>>
>     +   Copyright (C) 2010-2012 Sebastian Trueg <trueg@kde.org
>     <mailto:trueg@kde.org>>
> 
>        This library is free software; you can redistribute it and/or
>        modify it under the terms of the GNU Lesser General Public
>     @@ -40,12 +40,10 @@ private Q_SLOTS:
>         void initTestCase();
>         void cleanupTestCase();
>         void init();
>     -    void testVisibility();
>         void testParents();
>         void testVariantToNode_data();
>         void testVariantToNode();
>         void testProperties();
>     -    void testVisibleType();
> 
>      private:
>         KTempDir* m_storageDir;
> 
> 
[prev in list] [next in list] [prev in thread] [next in thread] 

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