relation = (IORelation) graphModel
.getSemanticObject(head);
}
if (port != null) {
ComponentEntity entity = (ComponentEntity) port
.getContainer();
String portName = "port_" + i;
boolean isInput = port.isInput();
boolean isOutput = port.isOutput();
newPorts
.append("<port name=\""
+ portName
+ "\" class=\"ptolemy.actor.TypedIOPort"
+ "\">\n");
if (namedObjSet.contains(entity)) {
// The port is inside the hierarchy.
// The relation must be outside.
// Create composite port.
if (isInput) {
newPorts
.append("<property name=\"input\"/>");
}
if (isOutput) {
newPorts
.append("<property name=\"output\"/>");
}
newPorts.append("\n</port>\n");
// Create internal relation and links.
// Note we can only partially reuse
// the relation name, one original relation
// can be two internal relations.
String relationName = relation.getName()
+ "_" + i;
intRelations
.append("<relation name=\""
+ relationName
+ "\" class=\""
+ "ptolemy.actor.TypedIORelation\"/>\n");
intConnections.append("<link port=\""
+ entity.getName() + "."
+ port.getName() + "\" relation=\""
+ relationName + "\"/>\n");
intConnections.append("<link port=\""
+ portName + "\" relation=\""
+ relationName + "\"/>\n");
// Create external links.
if (duplicateRelation) {
extRelations
.append("<relation name=\""
+ relation.getName()
+ "\" class=\""
+ "ptolemy.actor.TypedIORelation\"/>\n");
IOPort otherPort = (IOPort) tail;
ComponentEntity otherEntity = (ComponentEntity) otherPort
.getContainer();
if (otherEntity == container) {
// This is a boundary port at a higher level.
extConnections
.append("<link port=\""
+ otherPort
.getName()
+ "\" relation=\""
+ relation
.getName()
+ "\"/>\n");
} else {
extConnections
.append("<link port=\""
+ otherEntity
.getName()
+ "."
+ otherPort
.getName()
+ "\" relation=\""
+ relation
.getName()
+ "\"/>\n");
}
}
extConnections.append("<link port=\""
+ compositeActorName + "."
+ portName + "\" relation=\""
+ relation.getName() + "\"/>\n");
} else {
// The port is outside the hierarchy.
// The relation must be inside.
if (isInput) {
newPorts
.append("<property name=\"output\"/>");
}
if (isOutput) {
newPorts
.append("<property name=\"input\"/>");
}
newPorts.append("\n</port>\n");
String relationName = relation.getName()
+ "_" + i;
extRelations
.append("<relation name=\""
+ relationName
+ "\" class=\""
+ "ptolemy.actor.TypedIORelation\"/>\n");
extConnections.append("<link port=\""
+ entity.getName() + "."
+ port.getName() + "\" relation=\""
+ relationName + "\"/>\n");
extConnections.append("<link port=\""
+ compositeActorName + "."
+ portName + "\" relation=\""
+ relationName + "\"/>\n");
// Create external links.
if (duplicateRelation) {
intRelations
.append("<relation name=\""
+ relation.getName()
+ "\" class=\""
+ "ptolemy.actor.TypedIORelation\"/>\n");
IOPort otherPort = (IOPort) tail;
ComponentEntity otherEntity = (ComponentEntity) otherPort
.getContainer();
intConnections
.append("<link port=\""
+ otherEntity.getName()
+ "."
+ otherPort.getName()
+ "\" relation=\""
+ relation.getName()
+ "\"/>\n");