Bug #1556: Fix problems with i18n of the new enum

FEA: ItEr77S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-11-16 12:11:16 +01:00
parent 4406d1548a
commit 6927955a4a
2 changed files with 23 additions and 23 deletions

View file

@ -340,9 +340,24 @@ public class User extends BaseEntity implements IHumanIdentifiable{
return worker != null; return worker != null;
} }
public String getUserType() { public enum UserAuthenticationType {
return isLibrePlanUser().equals(Boolean.TRUE) ? _("Database")
: _("LDAP"); DATABASE(_("Database")), LDAP(_("LDAP"));
private String name;
private UserAuthenticationType(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
public UserAuthenticationType getUserType() {
return isLibrePlanUser() ? UserAuthenticationType.DATABASE
: UserAuthenticationType.LDAP;
} }
@AssertTrue(message = "You have exceeded the maximum limit of users") @AssertTrue(message = "You have exceeded the maximum limit of users")

View file

@ -37,6 +37,7 @@ import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.resources.entities.Worker; import org.libreplan.business.resources.entities.Worker;
import org.libreplan.business.users.entities.Profile; import org.libreplan.business.users.entities.Profile;
import org.libreplan.business.users.entities.User; import org.libreplan.business.users.entities.User;
import org.libreplan.business.users.entities.User.UserAuthenticationType;
import org.libreplan.business.users.entities.UserRole; import org.libreplan.business.users.entities.UserRole;
import org.libreplan.web.common.BaseCRUDController; import org.libreplan.web.common.BaseCRUDController;
import org.libreplan.web.common.Util; import org.libreplan.web.common.Util;
@ -100,7 +101,7 @@ public class UserCRUDController extends BaseCRUDController<User> implements
Util.appendLabel(row, user.getLoginName()); Util.appendLabel(row, user.getLoginName());
Util.appendLabel(row, user.isDisabled() ? _("Yes") : _("No")); Util.appendLabel(row, user.isDisabled() ? _("Yes") : _("No"));
Util.appendLabel(row, user.isSuperuser() ? _("Yes") : _("No")); Util.appendLabel(row, user.isSuperuser() ? _("Yes") : _("No"));
Util.appendLabel(row, _(user.getUserType())); Util.appendLabel(row, _(user.getUserType().toString()));
Util.appendLabel(row, user.isBound() ? user.getWorker() Util.appendLabel(row, user.isBound() ? user.getWorker()
.getShortDescription() : ""); .getShortDescription() : "");
@ -313,7 +314,7 @@ public class UserCRUDController extends BaseCRUDController<User> implements
.getFellowIfAny("authenticationTypeCombo"); .getFellowIfAny("authenticationTypeCombo");
combo.getChildren().clear(); combo.getChildren().clear();
for (UserAuthenticationType type : UserAuthenticationType.values()) { for (UserAuthenticationType type : UserAuthenticationType.values()) {
Comboitem item = combo.appendItem(type.toString()); Comboitem item = combo.appendItem(_(type.toString()));
item.setValue(type); item.setValue(type);
if (type.equals(getAuthenticationType())) { if (type.equals(getAuthenticationType())) {
combo.setSelectedItem(item); combo.setSelectedItem(item);
@ -479,28 +480,12 @@ public class UserCRUDController extends BaseCRUDController<User> implements
return isLdapUser() || isUserDefaultAdmin(); return isLdapUser() || isUserDefaultAdmin();
} }
public enum UserAuthenticationType {
EMPTY(""), DATABASE(_("Database")), LDAP(_("LDAP"));
private String name;
private UserAuthenticationType(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
public UserAuthenticationType getAuthenticationType() { public UserAuthenticationType getAuthenticationType() {
User user = getUser(); User user = getUser();
if (user != null) { if (user != null) {
return user.isLibrePlanUser() ? UserAuthenticationType.DATABASE return user.getUserType();
: UserAuthenticationType.LDAP;
} }
return UserAuthenticationType.EMPTY; return null;
} }
public void setAuthenticationType(Comboitem item) { public void setAuthenticationType(Comboitem item) {