#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!
# line 3 "../CascadeDelete.ump"
class B():
#------------------------
# MEMBER VARIABLES
#------------------------
#B Associations
#------------------------
# CONSTRUCTOR
#------------------------
def __init__(self):
self._myC = None
self._myC = []
#------------------------
# INTERFACE
#------------------------
# Code from template association_GetMany
def getMyC1(self, index):
aMyC = self._myC[index]
return aMyC
def getMyC2(self):
newMyC = tuple(self._myC)
return newMyC
def numberOfMyC(self):
number = len(self._myC)
return number
def hasMyC(self):
has = len(self._myC) > 0
return has
def indexOfMyC(self, aMyC):
index = (-1 if not aMyC in self._myC else self._myC.index(aMyC))
return index
# Code from template association_MinimumNumberOfMethod
@staticmethod
def minimumNumberOfMyC():
return 0
# Code from template association_AddManyToOne
def addMyC1(self, aMyD):
from example.C import C
return C(aMyD, self)
def addMyC2(self, aMyC):
wasAdded = False
if (aMyC) in self._myC :
return False
existingB = aMyC.getB()
isNewB = not (existingB is None) and not self == existingB
if isNewB :
aMyC.setB(self)
else :
self._myC.append(aMyC)
wasAdded = True
return wasAdded
def removeMyC(self, aMyC):
wasRemoved = False
#Unable to remove aMyC, as it must always have a b
if not self == aMyC.getB() :
self._myC.remove(aMyC)
wasRemoved = True
return wasRemoved
# Code from template association_AddIndexControlFunctions
def addMyCAt(self, aMyC, index):
wasAdded = False
if self.addMyC(aMyC) :
if index < 0 :
index = 0
if index > self.numberOfMyC() :
index = self.numberOfMyC() - 1
self._myC.remove(aMyC)
self._myC.insert(index, aMyC)
wasAdded = True
return wasAdded
def addOrMoveMyCAt(self, aMyC, index):
wasAdded = False
if (aMyC) in self._myC :
if index < 0 :
index = 0
if index > self.numberOfMyC() :
index = self.numberOfMyC() - 1
self._myC.remove(aMyC)
self._myC.insert(index, aMyC)
wasAdded = True
else :
wasAdded = self.addMyCAt(aMyC, index)
return wasAdded
def delete(self):
while len(self._myC) > 0 :
aMyC = self._myC[len(self._myC) - 1]
aMyC.delete()
self._myC.remove(aMyC)
def getMyC(self, *argv):
if len(argv) == 1 and isinstance(argv[0], int) :
return self.getMyC1(argv[0])
if len(argv) == 0 :
return self.getMyC2()
raise TypeError("No method matches provided parameters")
def addMyC(self, *argv):
from example.C import C
if len(argv) == 1 and isinstance(argv[0], D) :
return self.addMyC1(argv[0])
if len(argv) == 1 and isinstance(argv[0], C) :
return self.addMyC2(argv[0])
raise TypeError("No method matches provided parameters")
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!
# line 6 "../CascadeDelete.ump"
class C():
#------------------------
# MEMBER VARIABLES
#------------------------
#C Associations
#------------------------
# CONSTRUCTOR
#------------------------
@classmethod
def alternateConstructor(cls, aMyD, aB):
self = cls.__new__(cls)
self._b = None
self._myD = None
if aMyD is None or not (aMyD.getC() is None) :
raise RuntimeError ("Unable to create C due to aMyD. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
self._myD = aMyD
didAddB = self.setB(aB)
if not didAddB :
raise RuntimeError ("Unable to create myC due to b. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
return self
def __init__(self, aB):
from example.D import D
self._b = None
self._myD = None
self._myD = D.alternateConstructor(self)
didAddB = self.setB(aB)
if not didAddB :
raise RuntimeError ("Unable to create myC due to b. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
#------------------------
# INTERFACE
#------------------------
# Code from template association_GetOne
def getMyD(self):
return self._myD
# Code from template association_GetOne
def getB(self):
return self._b
# Code from template association_SetOneToMany
def setB(self, aB):
wasSet = False
if aB is None :
return wasSet
existingB = self._b
self._b = aB
if not (existingB is None) and not existingB == aB :
existingB.removeMyC(self)
self._b.addMyC(self)
wasSet = True
return wasSet
def delete(self):
existingMyD = self._myD
self._myD = None
if not (existingMyD is None) :
existingMyD.delete()
placeholderB = self._b
self._b = None
if not (placeholderB is None) :
placeholderB.removeMyC(self)
#PLEASE DO NOT EDIT THIS CODE
#This code was generated using the UMPLE 1.35.0.7523.c616a4dce modeling language!
# line 1 "../CascadeDelete.ump"
class D():
#------------------------
# MEMBER VARIABLES
#------------------------
#D Associations
#------------------------
# CONSTRUCTOR
#------------------------
@classmethod
def alternateConstructor(cls, aC):
self = cls.__new__(cls)
self._c = None
if aC is None or not (aC.getMyD() is None) :
raise RuntimeError ("Unable to create D due to aC. See https://manual.umple.org?RE002ViolationofAssociationMultiplicity.html")
self._c = aC
return self
def __init__(self, aBForC):
from example.C import C
self._c = None
self._c = C.alternateConstructor(self, aBForC)
#------------------------
# INTERFACE
#------------------------
# Code from template association_GetOne
def getC(self):
return self._c
def delete(self):
existingC = self._c
self._c = None
if not (existingC is None) :
existingC.delete()