[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Thu Dec 25 23:58:00 UTC 2003


CVS commit by okellogg: 

saveToXMI, loadFromXMI: Change attribute "documentation" to "comment".
Prepare for handling Uml::at_UniAssociation.


  M +26 -3     umlrole.cpp   1.12


--- kdesdk/umbrello/umbrello/umlrole.cpp  #1.11:1.12
@@ -146,5 +146,5 @@ bool UMLRole::saveToXMI( QDomDocument & 
                 roleElement.setAttribute("name", m_Name);
         if (m_Doc != "")
-                roleElement.setAttribute("documentation", m_Doc);
+                roleElement.setAttribute("comment", m_Doc);
         if (m_roleID) {  // role A
                 switch (m_pAssoc->getAssocType()) {
@@ -155,8 +155,11 @@ bool UMLRole::saveToXMI( QDomDocument & 
                                 roleElement.setAttribute("aggregation", "shared");
                                 break;
-                        default:  //at_Association
+                        default:
                                 roleElement.setAttribute("aggregation", "none");
                                 break;
                 }
+        } else {
+                if (m_pAssoc->getAssocType() == Uml::at_UniAssociation)
+                        roleElement.setAttribute("isNavigable", "true");
         }
         switch (m_Visibility) {
@@ -203,4 +206,7 @@ bool UMLRole::loadFromXMI( QDomElement &
         }
         m_pObject = obj;
+
+        // Here comes the handling of the association type.
+        // This is open for discussion - I'm pretty sure there are better ways..
         if (m_roleID) {  // role A
                 QString aggregation = element.attribute("aggregation", "none");
@@ -211,5 +217,19 @@ bool UMLRole::loadFromXMI( QDomElement &
                 else
                         m_pAssoc->setAssocType(Uml::at_Association);
+        } else if (element.hasAttribute("isNavigable")) {
+                /* Role B:
+                   If isNavigable is not given, we make no change to the
+                   association type.
+                   If isNavigable is given, and is "true", then we assume that
+                   the association's other end (role A) is not navigable, and
+                   therefore we change the association type to UniAssociation.
+                   The case that isNavigable is given as "false" is ignored.
+                   Combined with the association type logic for role A, this
+                   allows us to support at_Association and at_UniAssociation.
+                 */
+                if (element.attribute("isNavigable") == "true")
+                        m_pAssoc->setAssocType(Uml::at_UniAssociation);
         }
+
         m_Multi = element.attribute("multiplicity", "");
         m_Name = element.attribute("name", "");
@@ -214,5 +234,8 @@ bool UMLRole::loadFromXMI( QDomElement &
         m_Multi = element.attribute("multiplicity", "");
         m_Name = element.attribute("name", "");
+        if (element.hasAttribute("documentation"))  // for bkwd compat.
         m_Doc = element.attribute("documentation", "");
+        else
+                m_Doc = element.attribute("comment", "");
 
         // visibilty defaults to Public if it cant set it here..






More information about the umbrello-devel mailing list