SUMMARY In some cases Umbrello wont create a UML diagram relation (when importing from code (python)) between two objects STEPS TO REPRODUCE 1. Import the following python code via the code import wizard: import abc class Entity(abc.ABC): def __init__(self, entityNameStr): self.name = entityNameStr class Consumer(Entity): def __init__(self, consumerNameStr): super(Consumer, self).__init__(consumerNameStr) self._consumersPropertySelectedLst = [] def selectPropertyToView(self, propertyObj): cp = ConsumersPropertySelected(self, propertyObj) cp.addConsumersPropertySelected() def toString(self): print("Consumer Object:", self.name) print(self.name + " has selected the following property(ies) for viewing:") for cp in self._consumersPropertySelectedLst: print("-", cp._propertyObj.address) class ConsumersPropertySelected(object): def __init__(self, consumerObj, propertyObj): self._consumerObj = consumerObj self._propertyObj = propertyObj def addConsumersPropertySelected(self): if self not in self._consumerObj._consumersPropertySelectedLst: #check if not already added self._consumerObj._consumersPropertySelectedLst.append(self) self._propertyObj._consumersPropertySelectedLst.append(self) class Property(object): def __init__(self, addressStr): self._consumersPropertySelectedLst = [] self.address = addressStr def toString(self): print("Property Object:", self.address) print(self.address + " is to be viewed by the following consumer(s):") for cp in self._consumersPropertySelectedLst: print("-", cp._consumerObj.name) if __name__ == "__main__": pKlip1 = Property("Klip1") pGamka42 = Property("Gamka42") cPete = Consumer("Pete") cPete.selectPropertyToView(pGamka42) cPete.selectPropertyToView(pKlip1) cPete.toString() print() pGamka42.toString() print() pKlip1.toString() 2. Add the 'Property' & 'ConsumerPropertySelected' to the UML diagram 3. Select the aggregation relation from the toolbar 4. First left click on the 'Property' Object then left click on the 'ConsumerPropertySelected' OBSERVED RESULT See the image on the stack overflow page: https://stackoverflow.com/questions/56739228/umbrello-wont-create-relation/56739597#56739597 Umbrello did not create the relation EXPECTED RESULT A relation is expected to be created between the two objects SOFTWARE/OS VERSIONS Umbrello: 4.14.65 Windows: Windows 10 macOS: N/A Linux/KDE Plasma: N/A (available in About System) KDE Plasma Version: N/A KDE Frameworks Version:N/A Qt Version: N/A (PyQt5-5.11.2) ADDITIONAL INFORMATION Workaround: (refer to the stackoverflow link provided above) 1. Select the relation you want from the toolbar. 2. Left Click and hold on the first object(ex: 'Property') 3. Whilst still holding the left mouse button, drag the cursor to the second object (ex: 'ConsumerPropertySelected') 4. Release your left mouse button over the second object and finally click the second object again with your left mouse button
Git commit 42d5073216f6801fef68dd6a4508b9a0e1f67ef1 by Ralf Habacker. Committed on 26/06/2019 at 11:42. Pushed by habacker into branch 'Applications/19.04'. Fix 'Umbrello wont create a UML diagram relation between two objects' FIXED-IN: 2.28.3 (KDE Applications 19.04.3) M +11 -8 umbrello/codeimport/pythonimport.cpp https://commits.kde.org/umbrello/42d5073216f6801fef68dd6a4508b9a0e1f67ef1
(In reply to Ralf Habacker from comment #1) > Git commit 42d5073216f6801fef68dd6a4508b9a0e1f67ef1 by Ralf Habacker. > Committed on 26/06/2019 at 11:42. > Pushed by habacker into branch 'Applications/19.04'. > > Fix 'Umbrello wont create a UML diagram relation between two objects' Besides the problem in the Umbrello source code, which is fixed by this commit, the provided test code does not follow the Python procedure for defining class variables (see https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables), which is why cp is not recognized automatically. cp should be initialized in __init__(), as shown below: class Consumer(Entity): def __init__(self, consumerNameStr): super(Consumer, self).__init__(consumerNameStr) self._consumersPropertySelectedLst = [] self.cp = ConsumersPropertySelected()
Git commit 0976e1330c0d5708a466fafe52d1c261e9551f24 by Ralf Habacker. Committed on 27/06/2019 at 07:12. Pushed by habacker into branch 'Applications/19.04'. Add constructor visibility test to python test cases M +4 -0 test/import/python/visibility.py https://commits.kde.org/umbrello/0976e1330c0d5708a466fafe52d1c261e9551f24