Show username in tables (#946)

* formatting the username is slightly improved

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* formatting the username without steams

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>

* formatting the username without information about first or last name

Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>
This commit is contained in:
Natalia Kislicyn
2020-03-17 08:01:22 +01:00
committed by GitHub
parent 2dc5a959f0
commit 83161ea267

View File

@@ -34,7 +34,6 @@ import com.vaadin.server.VaadinService;
public final class UserDetailsFormatter {
private static final String TRIM_APPENDIX = "...";
private static final String DETAIL_SEPERATOR = ", ";
private UserDetailsFormatter() {
}
@@ -76,7 +75,7 @@ public final class UserDetailsFormatter {
*
* @param baseEntity
* the entity
* @return the formatted 'last modefied by user name' (max 100 characters)
* @return the formatted 'last modified by user name' (max 100 characters)
* cannot be <null>
*/
public static String loadAndFormatLastModifiedBy(final BaseEntity baseEntity) {
@@ -125,21 +124,7 @@ public final class UserDetailsFormatter {
}
final UserPrincipal userPrincipal = (UserPrincipal) userDetails;
String lastname = StringUtils.defaultIfEmpty(userPrincipal.getLastname(), "");
if (!StringUtils.isEmpty(lastname)) {
lastname += DETAIL_SEPERATOR;
}
final String firstAndLastname = lastname + StringUtils.defaultIfEmpty(userPrincipal.getFirstname(), "");
final String trimmedUsername = trimAndFormatDetail(firstAndLastname, expectedNameLength);
if (StringUtils.isEmpty(trimmedUsername)) {
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
}
return trimmedUsername;
return trimAndFormatDetail(userPrincipal.getLoginname(), expectedNameLength);
}
/**