From 6927955a4ad86253eb87d7cdf0df9137f299fbb5 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Fri, 16 Nov 2012 12:11:16 +0100 Subject: [PATCH] Bug #1556: Fix problems with i18n of the new enum FEA: ItEr77S04BugFixing --- .../business/users/entities/User.java | 21 +++++++++++++--- .../web/users/UserCRUDController.java | 25 ++++--------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java b/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java index 5bdda865e..bd285c96e 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java +++ b/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java @@ -340,9 +340,24 @@ public class User extends BaseEntity implements IHumanIdentifiable{ return worker != null; } - public String getUserType() { - return isLibrePlanUser().equals(Boolean.TRUE) ? _("Database") - : _("LDAP"); + public enum UserAuthenticationType { + + 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") diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java index ff8dafc65..9ce701fad 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java @@ -37,6 +37,7 @@ import org.libreplan.business.common.exceptions.ValidationException; import org.libreplan.business.resources.entities.Worker; import org.libreplan.business.users.entities.Profile; 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.web.common.BaseCRUDController; import org.libreplan.web.common.Util; @@ -100,7 +101,7 @@ public class UserCRUDController extends BaseCRUDController implements Util.appendLabel(row, user.getLoginName()); Util.appendLabel(row, user.isDisabled() ? _("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() .getShortDescription() : ""); @@ -313,7 +314,7 @@ public class UserCRUDController extends BaseCRUDController implements .getFellowIfAny("authenticationTypeCombo"); combo.getChildren().clear(); for (UserAuthenticationType type : UserAuthenticationType.values()) { - Comboitem item = combo.appendItem(type.toString()); + Comboitem item = combo.appendItem(_(type.toString())); item.setValue(type); if (type.equals(getAuthenticationType())) { combo.setSelectedItem(item); @@ -479,28 +480,12 @@ public class UserCRUDController extends BaseCRUDController implements 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() { User user = getUser(); if (user != null) { - return user.isLibrePlanUser() ? UserAuthenticationType.DATABASE - : UserAuthenticationType.LDAP; + return user.getUserType(); } - return UserAuthenticationType.EMPTY; + return null; } public void setAuthenticationType(Comboitem item) {