[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sun Dec 12 13:27:01 UTC 2004


CVS commit by okellogg: 

Defer the UMLDoc::addAssocToConcepts() call to UMLObject::resolveRef()
 in order to support xmi.idref forward references in the <AssociationEnd>.


  M +17 -5     association.cpp   1.59
  M +16 -2     umldoc.cpp   1.213


--- kdesdk/umbrello/umbrello/association.cpp  #1.58:1.59
@@ -149,4 +149,6 @@ bool UMLAssociation::resolveRef() {
                     objB && objB->getBaseType() == Uml::ot_Interface)
                         m_AssocType = Uml::at_Realization;
+                UMLDoc *doc = UMLApp::app()->getDocument();
+                doc->addAssocToConcepts(this);
                 return true;
         }
@@ -212,6 +214,8 @@ bool UMLAssociation::load( QDomElement &
                                 bool isDependency = (m_AssocType == Uml::at_Dependency &&
                                                      (tagEq(tag, "client") || tagEq(tag, "supplier")));
-                                if (!isGeneralization && !isDependency)
+                                if (!isGeneralization && !isDependency) {
+                                        kdDebug() << "UMLAssociation::load: cannot load " << tag << endl;
                                         continue;
+                                }
                                 QString idStr = tempElement.attribute( "xmi.id", "" );
                                 if (idStr.isEmpty())
@@ -433,9 +437,17 @@ UMLObject* UMLAssociation::getObject(Rol
 
 Uml::IDType UMLAssociation::getObjectId(Role_Type role) {
-        UMLObject *o = getObject(role);
+        UMLRole *roleObj = m_pRole[role];
+        UMLObject *o = roleObj->getObject();
         if (o == NULL) {
+                QString auxID = roleObj->getSecondaryId();
+                if (auxID.isEmpty()) {
                 kdError() << "UMLAssociation::getObjectId(" << role
                           << "): getObject returns NULL" << endl;
                 return Uml::id_None;
+                } else {
+                        kdDebug() << "UMLAssociation::getObjectId(" << role
+                                  << "): using secondary ID " << auxID << endl;
+                        return STR2ID(auxID);
+                }
         }
         return o->getID();

--- kdesdk/umbrello/umbrello/umldoc.cpp  #1.212:1.213
@@ -1356,6 +1356,9 @@ void UMLDoc::addAssociation(UMLAssociati
         // add it to our concept list and the document.
 
-        // Add the UMLAssociation at the appropriate concept.
-        addAssocToConcepts(Assoc);
+        // Adding the UMLAssociation at the appropriate concepts is done
+        // later (in UMLAssociation::resolveRef()) in order to support
+        // xmi.idref forward references. (The participating concepts
+        // might not yet be known right here.)
+        //addAssocToConcepts(Assoc);
 
         // Add the UMLAssociation in this UMLDoc.
@@ -2162,4 +2165,15 @@ bool UMLDoc::loadUMLObjectsFromXMI(QDomE
                 if (Umbrello::isCommonXMIAttribute(type))
                         continue;
+                if (! tempElement.hasAttribute("xmi.id")) {
+                        QString idref = tempElement.attribute("xmi.idref", "");
+                        if (! idref.isEmpty()) {
+                                kdDebug() << "resolution of xmi.idref " << idref
+                                          << " is not yet implemented" << endl;
+                        } else {
+                                kdError() << "Cannot load " << type
+                                          << " because xmi.id is missing" << endl;
+                        }
+                        continue;
+                }
                 UMLObject *pObject = makeNewUMLObject(type);
                 if( !pObject ) {






More information about the umbrello-devel mailing list