#!/usr/bin/env python
import coral

metamodel=coral.lang.UML14

s = coral.Project()

m = metamodel.Model()
m.__setProject__(s)

c1 = metamodel.Class()
c2 = metamodel.Class()
c3 = metamodel.Class()
c4 = metamodel.Class()

m.ownedElement.append(c1)

tm = coral.getTransactionManager()
tm2= coral.getTransactionManager()

print "tm=",tm
print "tm2=",tm2
assert(tm,tm2)
tm.beginModifyCmd()
try:
    m.ownedElement.append(c2)
finally:
    tm.endModifyCmd()

assert(len(m.ownedElement) == 2)

tm.undo()

assert(len(m.ownedElement) == 1)

# This will trim away one transaction
tm.beginModifyCmd()
try:
    m.ownedElement.append(c3)
finally:
    tm.endModifyCmd()

assert(len(m.ownedElement) == 2)

