|
@@ -266,7 +266,13 @@ public class Controller {
|
|
|
* @param link the Link, which contains the SmartDevice
|
|
|
*/
|
|
|
public void removeSmartDeviceFromLink(SmartDevice toRemove, Link link) {
|
|
|
- link.removeDevice(toRemove);
|
|
|
+ if(link != null){
|
|
|
+ link.removeDevice(toRemove);
|
|
|
+ if(link.getDevices().size()==0)
|
|
|
+ deleteLink(link);
|
|
|
+ }
|
|
|
+ if(toRemove!=null)
|
|
|
+ toRemove.removeLink(link);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -432,10 +438,20 @@ public class Controller {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Removes Device p from the Connection
|
|
|
+ * @param p Port/Device to remove
|
|
|
+ * @param connection connection, which should remove the device
|
|
|
+ */
|
|
|
public void removeDeviceFromConnection(Port p, Connection connection){
|
|
|
- connection.removeSmartDevice(p);
|
|
|
- connection.getProtocol().removeDevice(p);
|
|
|
- p.setConnection(null);
|
|
|
+ if(connection != null){
|
|
|
+ connection.removeSmartDevice(p);
|
|
|
+ connection.getProtocol().removeDevice(p);
|
|
|
+ if(connection.getParticipants().size() == 0)
|
|
|
+ deleteConnection(connection);
|
|
|
+ }
|
|
|
+ if(p!=null)
|
|
|
+ p.setConnection(null);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -472,7 +488,6 @@ public class Controller {
|
|
|
* @return true on successful change, false on failure & restore
|
|
|
*/
|
|
|
public boolean changeLinkOfConnection(Connection connection, Link newLink) {
|
|
|
- // TODO Auto-generated method stub
|
|
|
if(newLink != null){
|
|
|
connection.getLink().removeConnection(connection);
|
|
|
connection.setLink(newLink);
|