[kepler-dev] Removing ports (and relations)

Edward A Lee eal at eecs.berkeley.edu
Mon Aug 30 09:00:40 PDT 2004

At 08:37 AM 8/30/2004 -0500, Rod Spears wrote:
>I need to remove a port, which means I need to unlink and and remove all 
>the relations to that port. In fact, I think it would be best to remove 
>(delete) all the relations linked to that port.

When you remove a port (by calling port.setContainer(null) or
via a MoML change request <deletePort name="portName"/>), it
automatically takes care of removing links to relations.

However, removing the relation is not necessarily the right thing
to do. The relation likely has other links to it, and you don't
necessarily want to remove those.

Vergil has some code somewhere that tries to be smart about this...
If the relation has exactly one other link to it, then it removes
the relation.  Otherwise, it leaves it in place...

>What would be the best way to get that done?
>I tried calling unlinkAll and unlinkAllInside on the port, that allowed me 
>to remove the port without any exceptions, but the relation(s) was still there.
>Then I tried enumerating thru the relations and calling 
>relation.unlinkAll(), but that causes an exception after the port goes away.

What exception?


>I did not try the two approaches together.

Edward A. Lee, Professor
518 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0455, fax: 510-642-2739
eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal

More information about the Kepler-dev mailing list