throws PtalonRuntimeException {
try {
for (String portName : _relations.keySet()) {
String relationName = _actor.getMappedName(_relations
.get(portName));
TypedIORelation relation = (TypedIORelation) _actor
.getRelation(relationName);
TypedIOPort port = (TypedIOPort) actor.getPort(portName);
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
inner: for (Object connection : relation
.linkedPortList()) {
if (connection instanceof TypedIOPort) {
TypedIOPort testPort = (TypedIOPort) connection;
if (testPort.getContainer().equals(_actor)) {
if (testPort.isInput()) {
port.setInput(true);
}
if (testPort.isOutput()) {
port.setOutput(true);
}
} else {
if (testPort.isInput()) {
port.setOutput(true);
}
if (testPort.isOutput()) {
port.setInput(true);
}
}
break inner;
}
}
}
port.link(relation);
}
for (String portName : _transparencies.keySet()) {
TypedIOPort port = (TypedIOPort) actor.getPort(portName);
String shortName = _transparencies.get(portName);
if (_transparentRelations.containsKey(shortName)) {
TypedIOPort connectionPoint = _transparentRelations
.get(shortName);
String relationName = _actor.uniqueName("relation");
TypedIORelation rel = new TypedIORelation(_actor,
relationName);
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
inner: for (Object connection : rel
.linkedPortList()) {
if (connection instanceof TypedIOPort) {
TypedIOPort testPort = (TypedIOPort) connection;
if (testPort.getContainer().equals(_actor)) {
if (testPort.isInput()) {
port.setInput(true);
}
if (testPort.isOutput()) {
port.setOutput(true);
}
} else {
if (testPort.isInput()) {
port.setOutput(true);
}
if (testPort.isOutput()) {
port.setInput(true);
}
}
break inner;
}
}
}
port.link(rel);
connectionPoint.link(rel);
} else {
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
port.setMultiport(true);
port.setInput(true);
port.setOutput(false);
}
_transparentRelations.put(shortName, port);
}
}
for (String portName : _ports.keySet()) {
TypedIOPort port = (TypedIOPort) actor.getPort(portName);
String containerPortName = _actor.getMappedName(_ports
.get(portName));
TypedIOPort containerPort = (TypedIOPort) _actor
.getPort(containerPortName);
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
if (containerPort.isInput()) {
port.setInput(true);
}
if (containerPort.isOutput()) {
port.setOutput(true);
}
}
String relationName = _actor.uniqueName("relation");
TypedIORelation relation = new TypedIORelation(_actor,
relationName);
port.link(relation);
containerPort.link(relation);
}
for (String portName : _unknownPrefixes.keySet()) {
String suffix = evaluateString(_unknownExpressions
.get(portName));
if (suffix == null) {
throw new PtalonRuntimeException(
"Not able to evaluate suffix "
+ _unknownExpressions.get(portName));
}
String name = _unknownPrefixes.get(portName) + suffix;
if (_getType(name).endsWith("port")) {
TypedIOPort port = (TypedIOPort) actor
.getPort(portName);
String containerPortName = _actor.getMappedName(name);
TypedIOPort containerPort = (TypedIOPort) _actor
.getPort(containerPortName);
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
if (containerPort.isInput()) {
port.setInput(true);
}
if (containerPort.isOutput()) {
port.setOutput(true);
}
}
String relationName = _actor.uniqueName("relation");
TypedIORelation relation = new TypedIORelation(_actor,
relationName);
port.link(relation);
containerPort.link(relation);
} else if (_getType(name).equals("relation")) {
String relationName = _actor.getMappedName(name);
TypedIORelation relation = (TypedIORelation) _actor
.getRelation(relationName);
TypedIOPort port = (TypedIOPort) actor
.getPort(portName);
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
inner: for (Object connection : relation
.linkedPortList()) {
if (connection instanceof TypedIOPort) {
TypedIOPort testPort = (TypedIOPort) connection;
if (testPort.getContainer().equals(_actor)) {
if (testPort.isInput()) {
port.setInput(true);
}
if (testPort.isOutput()) {
port.setOutput(true);
}
} else {
if (testPort.isInput()) {
port.setOutput(true);
}
if (testPort.isOutput()) {
port.setInput(true);
}
}
break inner;
}
}
}
port.link(relation);
} else if (_getType(name).equals("transparent")) {
TypedIOPort port = (TypedIOPort) actor
.getPort(portName);
if (_transparentRelations.containsKey(name)) {
TypedIOPort connectionPoint = _transparentRelations
.get(name);
String relationName = _actor.uniqueName("relation");
TypedIORelation rel = new TypedIORelation(_actor,
relationName);
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
inner: for (Object connection : rel
.linkedPortList()) {
if (connection instanceof TypedIOPort) {
TypedIOPort testPort = (TypedIOPort) connection;
if (testPort.getContainer().equals(
_actor)) {
if (testPort.isInput()) {
port.setInput(true);
}
if (testPort.isOutput()) {
port.setOutput(true);
}
} else {
if (testPort.isInput()) {
port.setOutput(true);
}
if (testPort.isOutput()) {
port.setInput(true);
}
}
break inner;
}
}
}
port.link(rel);
connectionPoint.link(rel);
} else {
if (port == null) {
port = new TypedIOPort(actor, actor
.uniqueName(portName));
port.setMultiport(true);
port.setInput(true);
port.setOutput(false);
}
_transparentRelations.put(name, port);
}
} else {
throw new PtalonRuntimeException(name
+ " not a port or relation");
}
}
if (_danglingPortsOkay) {
return;
}
PtalonActor container = (PtalonActor) actor.getContainer();
for (Object port : actor.portList()) {
if (port instanceof TypedIOPort) {
TypedIOPort ioport = (TypedIOPort) port;
if (ioport.numLinks() == 0) {
String name = container.uniqueName(actor.getName()
+ "_" + ioport.getName());
TypedIOPort newPort = new TypedIOPort(container,
name);
String rel = container.uniqueName("relation");
TypedIORelation relation = new TypedIORelation(
container, rel);
if (ioport.isMultiport()) {
relation.setWidth(ioport.getWidth());
newPort.setMultiport(true);
if (ioport.getWidth() == 0) {
ioport.link(relation);
newPort.link(relation);
} else {