diff options
-rw-r--r-- | examples/uml/duse-mt/src/app/example4.xmi | 14 | ||||
-rw-r--r-- | src/uml/qumlconnector.cpp | 10 | ||||
-rw-r--r-- | src/uml/qumlproperty.cpp | 4 | ||||
-rw-r--r-- | src/uml/qumlstructuredclassifier.cpp | 8 | ||||
-rw-r--r-- | tests/auto/auto.pro | 5 | ||||
-rw-r--r-- | tests/auto/qtumlconnectortypeandcomponentparts/qtumlconnectortypeandcomponentparts.pro | 7 | ||||
-rw-r--r-- | tests/auto/qtumlconnectortypeandcomponentparts/test.xmi | 45 | ||||
-rw-r--r-- | tests/auto/qtumlconnectortypeandcomponentparts/tst_qtumlconnectortypeandcomponentparts.cpp | 86 |
8 files changed, 169 insertions, 10 deletions
diff --git a/examples/uml/duse-mt/src/app/example4.xmi b/examples/uml/duse-mt/src/app/example4.xmi index 4276aa04..8f734bab 100644 --- a/examples/uml/duse-mt/src/app/example4.xmi +++ b/examples/uml/duse-mt/src/app/example4.xmi @@ -3,11 +3,13 @@ <uml:Model xmi:id="_e2GlYFITEeOQC9143qYSZw" name="structuredcomponent"> <packagedElement xmi:type="uml:Component" xmi:id="_e2GlZFITEeOQC9143qYSZw" name="LeaderFollowers"> <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZVITEeOQC9143qYSZw" name="threadPoolRequiredPort" type="_e2GlaVITEeOQC9143qYSZw"/> + <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZVITEeOQC9143qYSZx" name="leaderFollowersProvidedPort" type="_e2GlaFITEeOQC9143qYSZx"/> </packagedElement> <packagedElement xmi:type="uml:Component" xmi:id="_e2GlZlITEeOQC9143qYSZw" name="ThreadPool"> <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZ1ITEeOQC9143qYSZw" name="threadPoolProvidedPort" type="_e2GlaFITEeOQC9143qYSZw"/> </packagedElement> <packagedElement xmi:type="uml:Interface" xmi:id="_e2GlaFITEeOQC9143qYSZw" name="IThreadPool" isAbstract="true"/> + <packagedElement xmi:type="uml:Interface" xmi:id="_e2GlaFITEeOQC9143qYSZx" name="ILeaderFollowers" isAbstract="true"/> <packagedElement xmi:type="uml:Class" xmi:id="_e2GlaVITEeOQC9143qYSZw" name="ThreadPoolClient"> <clientDependency href="_e2GlalITEeOQC9143qYSZw"/> </packagedElement> @@ -18,7 +20,7 @@ <packagedElement xmi:type="uml:Component" xmi:id="_e2Gla1ITEeOQC9143qYSZw" name="WebServer"> <ownedAttribute xmi:type="uml:Property" xmi:id="_e2GlbFITEeOQC9143qYSZw" name="leaderFollowers" type="_e2GlZFITEeOQC9143qYSZw" aggregation="composite"/> <ownedAttribute xmi:type="uml:Property" xmi:id="_e2GlbVITEeOQC9143qYSZw" name="threadPool" type="_e2GlZlITEeOQC9143qYSZw" aggregation="composite"/> - <ownedConnector xmi:type="uml:Connector" xmi:id="_e2GlbVITEeOQC9143qYSZx" name="connector"> + <ownedConnector xmi:type="uml:Connector" xmi:id="_e2GlbVITEeOQC9143qYSZx" name="assemblyConnector"> <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZxEnd1"> <role href="_e2GlZVITEeOQC9143qYSZw"/> <partWithPort href="_e2GlbFITEeOQC9143qYSZw"/> @@ -28,6 +30,16 @@ <partWithPort href="_e2GlbVITEeOQC9143qYSZw"/> </end> </ownedConnector> + <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZVITEeOQC9143qYSZz" name="webserverProvidedPort" type="_e2GlaFITEeOQC9143qYSZx"/> + <ownedConnector xmi:type="uml:Connector" xmi:id="_e2GlbVITEeOQC9143qYSZy" name="delegationConnector"> + <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZyEnd1"> + <role href="_e2GlZVITEeOQC9143qYSZz"/> + </end> + <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZyEnd2"> + <role href="_e2GlZVITEeOQC9143qYSZx"/> + <partWithPort href="_e2GlbFITEeOQC9143qYSZw"/> + </end> + </ownedConnector> </packagedElement> </uml:Model> </xmi:XMI> diff --git a/src/uml/qumlconnector.cpp b/src/uml/qumlconnector.cpp index 9beb2b73..9f1e8361 100644 --- a/src/uml/qumlconnector.cpp +++ b/src/uml/qumlconnector.cpp @@ -55,6 +55,8 @@ #include <QtUml/QUmlRedefinableElement> #include <QtUml/QUmlStringExpression> +#include <QtUml/QUmlPort> + QT_BEGIN_NAMESPACE /*! @@ -173,9 +175,11 @@ QtUml::ConnectorKind QUmlConnector::kind() const { // This is a read-only derived property - qWarning("QUmlConnector::kind(): to be implemented (this is a derived property)"); - - return QtUml::ConnectorKind(); + bool found = false; + foreach (QUmlConnectorEnd *end, ends()) + if (dynamic_cast<QUmlPort *>(end->role()) && !end->partWithPort() && !(dynamic_cast<QUmlPort *>(end->role()))->isBehavior()) + found = true; + return found ? QtUml::ConnectorKindDelegation:QtUml::ConnectorKindAssembly; } void QUmlConnector::setKind(QtUml::ConnectorKind kind) diff --git a/src/uml/qumlproperty.cpp b/src/uml/qumlproperty.cpp index 3bad7afe..a49c1789 100644 --- a/src/uml/qumlproperty.cpp +++ b/src/uml/qumlproperty.cpp @@ -355,9 +355,7 @@ bool QUmlProperty::isComposite() const { // This is a read-write derived property - qWarning("QUmlProperty::isComposite(): to be implemented (this is a derived property)"); - - return bool(); + return _aggregation == QtUml::AggregationKindComposite; } void QUmlProperty::setComposite(bool isComposite) diff --git a/src/uml/qumlstructuredclassifier.cpp b/src/uml/qumlstructuredclassifier.cpp index c7029769..8a17169c 100644 --- a/src/uml/qumlstructuredclassifier.cpp +++ b/src/uml/qumlstructuredclassifier.cpp @@ -228,9 +228,13 @@ const QSet<QUmlProperty *> QUmlStructuredClassifier::parts() const { // This is a read-only derived association end - qWarning("QUmlStructuredClassifier::parts(): to be implemented (this is a derived association end)"); + QSet<QUmlProperty *> parts_; - return QSet<QUmlProperty *>(); + foreach (QUmlProperty *property, _ownedAttributes) + if (property->isComposite()) + parts_.insert(property); + + return parts_; } void QUmlStructuredClassifier::addPart(QUmlProperty *part) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d797a078..a3290967 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,3 +1,6 @@ TEMPLATE=subdirs qtHaveModule(mof): SUBDIRS += qtmofcontainment -qtHaveModule(uml): SUBDIRS += qtumlcontainment qtumlprovidedrequiredinterfaces +qtHaveModule(uml): SUBDIRS += \ + qtumlcontainment \ + qtumlprovidedrequiredinterfaces \ + qtumlconnectortypeandcomponentparts diff --git a/tests/auto/qtumlconnectortypeandcomponentparts/qtumlconnectortypeandcomponentparts.pro b/tests/auto/qtumlconnectortypeandcomponentparts/qtumlconnectortypeandcomponentparts.pro new file mode 100644 index 00000000..0bbabce5 --- /dev/null +++ b/tests/auto/qtumlconnectortypeandcomponentparts/qtumlconnectortypeandcomponentparts.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qtumlconnectortypeandcomponentparts + +QT = modeling uml testlib + +SOURCES += \ + tst_qtumlconnectortypeandcomponentparts.cpp \ diff --git a/tests/auto/qtumlconnectortypeandcomponentparts/test.xmi b/tests/auto/qtumlconnectortypeandcomponentparts/test.xmi new file mode 100644 index 00000000..8f734bab --- /dev/null +++ b/tests/auto/qtumlconnectortypeandcomponentparts/test.xmi @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xmi:XMI xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:uml="http://www.omg.org/spec/UML/20110701"> +<uml:Model xmi:id="_e2GlYFITEeOQC9143qYSZw" name="structuredcomponent"> + <packagedElement xmi:type="uml:Component" xmi:id="_e2GlZFITEeOQC9143qYSZw" name="LeaderFollowers"> + <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZVITEeOQC9143qYSZw" name="threadPoolRequiredPort" type="_e2GlaVITEeOQC9143qYSZw"/> + <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZVITEeOQC9143qYSZx" name="leaderFollowersProvidedPort" type="_e2GlaFITEeOQC9143qYSZx"/> + </packagedElement> + <packagedElement xmi:type="uml:Component" xmi:id="_e2GlZlITEeOQC9143qYSZw" name="ThreadPool"> + <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZ1ITEeOQC9143qYSZw" name="threadPoolProvidedPort" type="_e2GlaFITEeOQC9143qYSZw"/> + </packagedElement> + <packagedElement xmi:type="uml:Interface" xmi:id="_e2GlaFITEeOQC9143qYSZw" name="IThreadPool" isAbstract="true"/> + <packagedElement xmi:type="uml:Interface" xmi:id="_e2GlaFITEeOQC9143qYSZx" name="ILeaderFollowers" isAbstract="true"/> + <packagedElement xmi:type="uml:Class" xmi:id="_e2GlaVITEeOQC9143qYSZw" name="ThreadPoolClient"> + <clientDependency href="_e2GlalITEeOQC9143qYSZw"/> + </packagedElement> + <packagedElement xmi:type="uml:Dependency" xmi:id="_e2GlalITEeOQC9143qYSZw" name="ThreadPoolClient-IThreadPool-Dependency"> + <supplier href="_e2GlaFITEeOQC9143qYSZw"/> + <client href="_e2GlaVITEeOQC9143qYSZw"/> + </packagedElement> + <packagedElement xmi:type="uml:Component" xmi:id="_e2Gla1ITEeOQC9143qYSZw" name="WebServer"> + <ownedAttribute xmi:type="uml:Property" xmi:id="_e2GlbFITEeOQC9143qYSZw" name="leaderFollowers" type="_e2GlZFITEeOQC9143qYSZw" aggregation="composite"/> + <ownedAttribute xmi:type="uml:Property" xmi:id="_e2GlbVITEeOQC9143qYSZw" name="threadPool" type="_e2GlZlITEeOQC9143qYSZw" aggregation="composite"/> + <ownedConnector xmi:type="uml:Connector" xmi:id="_e2GlbVITEeOQC9143qYSZx" name="assemblyConnector"> + <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZxEnd1"> + <role href="_e2GlZVITEeOQC9143qYSZw"/> + <partWithPort href="_e2GlbFITEeOQC9143qYSZw"/> + </end> + <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZxEnd2"> + <role href="_e2GlZ1ITEeOQC9143qYSZw"/> + <partWithPort href="_e2GlbVITEeOQC9143qYSZw"/> + </end> + </ownedConnector> + <ownedAttribute xmi:type="uml:Port" xmi:id="_e2GlZVITEeOQC9143qYSZz" name="webserverProvidedPort" type="_e2GlaFITEeOQC9143qYSZx"/> + <ownedConnector xmi:type="uml:Connector" xmi:id="_e2GlbVITEeOQC9143qYSZy" name="delegationConnector"> + <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZyEnd1"> + <role href="_e2GlZVITEeOQC9143qYSZz"/> + </end> + <end xmi:type="uml:ConnectorEnd" xmi:id="_e2GlbVITEeOQC9143qYSZyEnd2"> + <role href="_e2GlZVITEeOQC9143qYSZx"/> + <partWithPort href="_e2GlbFITEeOQC9143qYSZw"/> + </end> + </ownedConnector> + </packagedElement> +</uml:Model> +</xmi:XMI> diff --git a/tests/auto/qtumlconnectortypeandcomponentparts/tst_qtumlconnectortypeandcomponentparts.cpp b/tests/auto/qtumlconnectortypeandcomponentparts/tst_qtumlconnectortypeandcomponentparts.cpp new file mode 100644 index 00000000..4373543e --- /dev/null +++ b/tests/auto/qtumlconnectortypeandcomponentparts/tst_qtumlconnectortypeandcomponentparts.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Sandro S. Andrade <sandroandrade@kde.org> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtUml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtTest/QtTest> + +#include <QtModeling/QXmiReader> +#include <QtModeling/QModelingElement> + +#include <QtUml/QUmlPort> +#include <QtUml/QUmlConnector> +#include <QtUml/QUmlComponent> + +class TestQtUmlConnectorTypeComponentParts : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void qtumlconnectortypeandcomponentparts(); +}; + +void TestQtUmlConnectorTypeComponentParts::qtumlconnectortypeandcomponentparts() +{ + QFile file("test.xmi"); + + if (!file.open(QFile::ReadOnly | QFile::Text)) { + qDebug() << "Cannot read file !"; + return; + } + + QXmiReader reader; + QList<QModelingElement *> rootElements = reader.readFile(&file); + + QUmlConnector *connector1 = qmodelingelementproperty_cast<QUmlConnector *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("assemblyConnector")); + QCOMPARE(connector1->kind(), QtUml::ConnectorKindAssembly); + + QUmlConnector *connector2 = qmodelingelementproperty_cast<QUmlConnector *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("delegationConnector")); + QCOMPARE(connector2->kind(), QtUml::ConnectorKindDelegation); + + QUmlComponent *component = qmodelingelementproperty_cast<QUmlComponent *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("WebServer")); + QCOMPARE(component->parts().size(), 2); + QCOMPARE(component->parts().contains(qmodelingelementproperty_cast<QUmlProperty *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("leaderFollowers"))), true); + QCOMPARE(component->parts().contains(qmodelingelementproperty_cast<QUmlProperty *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("threadPool"))), true); + +// qDeleteAll(rootElements); +} + +QTEST_MAIN(TestQtUmlConnectorTypeComponentParts) +#include "tst_qtumlconnectortypeandcomponentparts.moc" + |