Bug 126547 - Wish: Importing diagrams from other Umbrello files into an opened file
Summary: Wish: Importing diagrams from other Umbrello files into an opened file
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 1.4.2
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-01 00:14 UTC by João Batista
Modified: 2014-06-18 09:03 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.12.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description João Batista 2006-05-01 00:14:51 UTC
Version:           1.4.2 (using KDE KDE 3.5.2)
Installed from:    Debian testing/unstable Packages
OS:                Linux

As requested by okellogg in bug 126278 , I'm describing a suggestion on how to implement the ability to merge two Umbrello files. This wish results from the need to have diagrams and UML elements contained in different files into the same file.

The following are suggestions which hopefully might help with coming up with some requirements.
- Umbrello files are really XML files. So, I guess merging them would be done as something in the lines of parsing both the opened file and the to-be-merged file, and placing the adequate descriptors in the XML tree (but then again, I'm likely overlooking important details). To avoid some incompatibilities, the diagrams and UML elements might be placed in new folders, each named after the corresponding file.
- If the files were merged into the same folder(s), it would involve having to check for several incompatibilities during the merge, so not to overwrite existing XML elements; but stuff such as new actors, new classes, etc would likely be merged without conflicts. The user might want to have individual, non-diagramatical elements (i.e., classes, actors, etc.) be imported automatically, and have Umbrello report at the end which elements were not merged.
- Those diagrams in the imported file, which might have the same name as the opened file, would have to be renamed; the user could ask to do it automatically, or choose to rename it one by one.
Comment 1 Oliver Kellogg 2006-09-20 22:49:20 UTC
Thanks for clarifying. It's clearly a desirable feature.
I see two preconditions for implementing this -
1) Change the UniqueID::get() function to return a random
  string of reasonable length instead of just a small integer.
  This would help avoid xmi.id conflicts between different files.
2) Less heavily rely on xmi.id's for resolving model element references
  but instead use the fully qualified names. (E.g. on merging, two
  model elements might have different xmi.id's but identical fully
  qualified names)
Comment 2 Oliver Kellogg 2006-09-20 22:55:45 UTC
On re-reading my comment #1, here's another idea:
Just use the fully qualified name as the xmi.id
(have to think about this some more...)
Comment 3 Oliver Kellogg 2006-11-09 23:44:30 UTC
Comment #2 is probably not a good idea - it doesn't work well
when moving an object to another package or folder (the xmi.id
would need to change.)
Comment 4 Oliver Kellogg 2006-11-09 23:48:13 UTC
SVN commit 603735 by okellogg:

Change the UniqueID::gen() function to return a random string of reasonable
length instead of just a small integer. Addresses first part of Comment #1.
CCBUG:126547


 A             configure.in.bot  
 M  +7 -0      configure.in.in  
 M  +1 -1      umbrello/Makefile.am  
 M  +7 -12     umbrello/umlobject.cpp  
 M  +4 -7      umbrello/umlview.cpp  
 M  +1 -5      umbrello/umlview.h  
 M  +13 -10    umbrello/uniqueid.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/configure.in.in #603734:603735
@@ -34,7 +34,14 @@
 dnl #endif
 dnl ])
 
+KDE_CHECK_HEADER(uuid/uuid.h,
+  [kde_have_libuuid=yes],
+  [kde_have_libuuid=])
 
+if test -z "$kde_have_libuuid"; then
+  DO_NOT_COMPILE="$DO_NOT_COMPILE umbrello"
+fi
+
 HAVE_XSLT=yes
 
 KDE_FIND_PATH(xml2-config, XML_CONFIG, [${prefix}/bin ${exec_prefix}/bin], [
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/Makefile.am #603734:603735
@@ -136,7 +136,7 @@
 
 METASOURCES = AUTO
 
-umbrello_LDFLAGS = $(all_libraries) $(KDE_RPATH) -export-dynamic
+umbrello_LDFLAGS = $(all_libraries) -luuid $(KDE_RPATH) -export-dynamic
 
 messages: rc.cpp
 	$(PREPARETIPS) > tips.cpp
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlobject.cpp #603734:603735
@@ -599,20 +599,15 @@
     }
 
     QString stereo = element.attribute( "stereotype", "" );
-    if (!stereo.isEmpty() && stereo != "-1") {
-        if (stereo.contains(QRegExp("\\D"))) {
-            // Old versions saved the stereotype name instead of the xmi.id.
-            setStereotype( stereo );
-        } else {
-            Uml::IDType stereoID = STR2ID(stereo);
-            m_pStereotype = umldoc->findStereotypeById(stereoID);
-            if (m_pStereotype)
-                m_pStereotype->incrRefCount();
-            else
-                kdError() << "UMLObject::loadFromXMI(" << m_Name << "): "
+    if (!stereo.isEmpty()) {
+        Uml::IDType stereoID = STR2ID(stereo);
+        m_pStereotype = umldoc->findStereotypeById(stereoID);
+        if (m_pStereotype)
+            m_pStereotype->incrRefCount();
+        else
+            kdError() << "UMLObject::loadFromXMI(" << m_Name << "): "
                 << "UMLStereotype " << ID2STR(stereoID)
                 << " not found" << endl;
-        }
     }
 
     if( element.hasAttribute("abstract") ) {     // for bkwd compat.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.cpp #603734:603735
@@ -93,8 +93,6 @@
 #include "toolbarstatefactory.h"
 
 
-# define EXTERNALIZE_ID(id)  QString::number(id).ascii()
-
 // control the manual DoubleBuffering of QCanvas
 // with a define, so that this memory X11 effect can
 // be tested more easily
@@ -119,7 +117,6 @@
     m_pDoc = NULL;
     m_Documentation = "";
     m_Type = dt_Undefined;
-    m_nLocalID = 900000;
     m_bUseSnapToGrid = false;
     m_bUseSnapComponentSizeToGrid = false;
     m_bShowSnapGrid = false;
@@ -1107,8 +1104,8 @@
 }
 
 Uml::IDType UMLView::getLocalID() {
-    --m_nLocalID;
-    return EXTERNALIZE_ID(m_nLocalID);
+    m_nLocalID = UniqueID::gen();
+    return m_nLocalID;
 }
 
 bool UMLView::isSavedInSeparateFile() {
@@ -2860,7 +2857,7 @@
     viewElement.setAttribute( "showscope", m_Options.classState.showVisibility );
     viewElement.setAttribute( "showstereotype", m_Options.classState.showStereoType );
     //misc
-    viewElement.setAttribute( "localid", m_nLocalID );
+    viewElement.setAttribute( "localid", ID2STR(m_nLocalID) );
     viewElement.setAttribute( "showgrid", m_bShowSnapGrid );
     viewElement.setAttribute( "snapgrid", m_bUseSnapToGrid );
     viewElement.setAttribute( "snapcsgrid", m_bUseSnapComponentSizeToGrid );
@@ -3025,7 +3022,7 @@
         m_Options.uiState.lineColor = QColor( linecolor );
     if( !linewidth.isEmpty() )
         m_Options.uiState.lineWidth = linewidth.toInt();
-    m_nLocalID = localid.toInt();
+    m_nLocalID = STR2ID(localid);
 
     QDomNode node = qElement.firstChild();
     bool widgetsLoaded = false, messagesLoaded = false, associationsLoaded = false;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.h #603734:603735
@@ -930,12 +930,8 @@
     /**
      * Contains the unique ID to allocate to a widget that needs an
      * ID for the view.  @ref ObjectWidgets are an example of this.
-     * NOTE: Currently this is an int although Uml::IDType is a string
-     *       (unless ID_USE_INT is defined.) Perhaps it should be changed
-     *       to Uml::IDType but then we need a unique string generator.
-     *       See also UMLDoc::m_uniqueID.
      */
-    int m_nLocalID;
+    Uml::IDType m_nLocalID;
 
     /**
      * The ID of the view.  Allocated by @ref UMLDoc
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/uniqueid.cpp #603734:603735
@@ -9,35 +9,38 @@
  *   Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>                 *
  ***************************************************************************/
 
+// own header
 #include "uniqueid.h"
 
-# define EXTERNALIZE_ID(id)  QString::number(id).ascii()
+// system includes
+#include <uuid/uuid.h>
 
 namespace UniqueID {
 
 /**
  * Each model object gets assigned a unique ID.
- * NOTE: Currently this is an int although Uml::IDType is a string.
- *       See also UMLView::m_nLocalID.
  */
-int m_uniqueID = 0;
+Uml::IDType m_uniqueID;
 
 Uml::IDType gen() {
-    ++m_uniqueID;
-    return EXTERNALIZE_ID(m_uniqueID);
+    static char buf[40];
+    uuid_t uuid;
+    uuid_generate(uuid);
+    uuid_unparse_upper(uuid, buf);
+    m_uniqueID = std::string(buf);
+    return m_uniqueID;
 }
 
 void init() {
-    m_uniqueID = 0;
+    m_uniqueID = Uml::id_Reserved;
 }
 
 Uml::IDType get() {
-    return EXTERNALIZE_ID(m_uniqueID);
+    return m_uniqueID;
 }
 
 void set(Uml::IDType id) {
-    QString uniqueid = ID2STR(id);
-    m_uniqueID = uniqueid.toInt();
+    m_uniqueID = id;
 }
 
 }  // end namespace UniqueID
Comment 5 Ralf Habacker 2013-11-21 09:18:36 UTC
Since version 2.12.0 Umbrello have copy/paste support of complete diagrams into a new umbrello instance (copy/paste of packages is requested with bug 327887)