#!/usr/bin/env python
#
# This re-creates a class diagram using the XMIDI builder
#
# 
#
import coral
L = coral.lang.UML14
DI = coral.lang.XMIDI20

P = coral.loadDocument("2classes_with_association.xmi")
m = P.contents().select(lambda x: x.__type__() == L.Model)[0]

# Simple 2-class diagram with an association
# create a copy of the diagram using the xmidi-builder

import coral.modeler.diagram.xmidi_diagrams as diagrams
diagram = diagrams.createDiagram(P, m, "ClassDiagram")

import coral.modeler.xmidigraphbuilder
coral.modeler.xmidigraphbuilder.xmidibuilder(m, diagram)

# Find the new edge

new_edge = diagram.__getAllParts__().select(lambda x: x.oclIsKindOf(DI.GraphEdge))[0]
assert new_edge
assert len(new_edge.waypoints) == 2

