#!/usr/bin/env python
import coral
L = coral.Language.__getLanguage__("UML", 1, 4)
assert L

ClassifierRole = L.getElement("ClassifierRole")
Multiplicity = L.getElement("Multiplicity")
c = ClassifierRole()
m = Multiplicity()

c.multiplicity = m

print "X"
for slot in m.__all_slots__():
    print slot, slot.getProperty().getName()
    for i in slot:
        print i
print "Y"
for prop in m.__type__().__properties__():
    print prop.getName()
print "Z"

assert m.__parent__() == c

L2= coral.Language.__getLanguage__("XMIDI",2,0)

print "*"*60
GraphNode=L2.getElement("GraphNode")
gn=GraphNode()
print gn.position.__parent__()
assert gn.position.__parent__()==gn
p=L2.getElement("Point")()
assert p.__parent__() is None
gn.position=p
assert gn.position.__parent__()==gn
s=coral.Project()
coral.saveModel("tmp/anonim.xmi",gn)


for f in ("tmp/anonim.xmi", "../../../qa/models2import/Softsale.xmi"):
    print "file",f
    storage=coral.loadDocument(f)
    for s in storage.contents():
        for x in s.__getAllParts__():
            if x.oclIsKindOf(GraphNode) and x.position:
                print x,x.position,x.position.__parent__()
                assert x.position.__parent__()==x
