}
// add all existing associations to the new graph model
for (IAssociation association : pm.getAssociations())
{
IElement start = association.getStartpoint();
IElement end = association.getEndpoint();
IElement mappedStart = null;
IElement mappedEnd = null;
boolean startFound = false;
boolean endFound = false;
// we have to create a new association with the start and end nodes
// of the graph model
for (IElement element : gm.getElements())
{
if (element.equals(start))
{
mappedStart = element;
startFound = true;
}
else if (element.equals(end))
{
mappedEnd = element;
endFound = true;
}
if (startFound && endFound)
{
break;
}
}
if ((null != mappedStart) && (null != mappedEnd))
{
IAssociation mappedAssociation;
if (association instanceof DirectedAssociation)
{
mappedAssociation = new DirectedAssociation(mappedStart, mappedEnd);
}
else
{
mappedAssociation = new Association(mappedStart, mappedEnd);
}
gm.add(mappedAssociation);
}
else
{
System.err.println("error transforming association " + association);
}
}
// now remove all connectors from the new graph model
while (true)
{
boolean changed = false;
// we have to iterate over the connectors of the original process
// model because we can't simultaneously iterate and remove graph
// model connectors
for (Connector connector : pm.getConnectors())
{
IElement graphElement = null;
for (IElement ge : gm.getElements())
{
if (ge.getId().equals(connector.getId()))
{