Ticket #263: Switched to enum for connection group type.

This commit is contained in:
James Muehlner
2013-08-07 22:15:31 -07:00
parent a7f45e8244
commit 52490ca8ab
5 changed files with 36 additions and 53 deletions

View File

@@ -64,11 +64,6 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup {
* The ID of the parent connection group for this connection group.
*/
private Integer parentID;
/**
* The type of this connection group.
*/
private String type;
/**
* The ID of the user who queried or created this connection group.
@@ -160,7 +155,6 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup {
this.parentID = parentID;
setName(name);
setIdentifier(identifier);
this.type = type;
this.userID = userID;
connectionDirectory = connectionDirectoryProvider.get();
@@ -194,34 +188,5 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup {
public Directory<String, ConnectionGroup> getConnectionGroupDirectory() throws GuacamoleException {
return connectionGroupDirectory;
}
/**
* Returns the connection group type.
* @return the connection group type.
*/
public String getType() {
return type;
}
/**
* Sets the connection group type.
* @param type the connection group type.
*/
public void setType(String type) {
this.type = type;
}
@Override
public void setBalancing(boolean balancing) {
if(balancing)
this.type = MySQLConstants.CONNECTION_GROUP_BALANCING;
else
this.type = MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL;
}
@Override
public boolean isBalancing() {
return MySQLConstants.CONNECTION_GROUP_BALANCING.equals(this.type);
}
}

View File

@@ -50,6 +50,7 @@ import java.util.Map;
import java.util.Set;
import net.sourceforge.guacamole.net.GuacamoleSocket;
import net.sourceforge.guacamole.net.auth.mysql.MySQLConnectionGroup;
import net.sourceforge.guacamole.net.auth.mysql.MySQLConstants;
import net.sourceforge.guacamole.net.auth.mysql.dao.ConnectionGroupMapper;
import net.sourceforge.guacamole.net.auth.mysql.model.ConnectionGroup;
import net.sourceforge.guacamole.net.auth.mysql.model.ConnectionGroupExample;
@@ -353,7 +354,15 @@ public class ConnectionGroupService {
connectionGroup.setConnection_group_id(mySQLConnectionGroup.getConnectionGroupID());
connectionGroup.setParent_id(mySQLConnectionGroup.getParentID());
connectionGroup.setConnection_group_name(mySQLConnectionGroup.getName());
connectionGroup.setType(mySQLConnectionGroup.getType());
switch(mySQLConnectionGroup.getType()) {
case BALANCING :
connectionGroup.setType(MySQLConstants.CONNECTION_GROUP_BALANCING);
break;
case ORGANIZATIONAL:
connectionGroup.setType(MySQLConstants.CONNECTION_GROUP_ORGANIZATIONAL);
break;
}
// Update the connection in the database
connectionGroupDAO.updateByPrimaryKeySelective(connectionGroup);