SEBSERV-109 added surname column and fixed some sort issues

This commit is contained in:
anhefti 2020-03-25 19:00:09 +01:00
parent 3d20038a1e
commit 02e3a104bf
7 changed files with 414 additions and 390 deletions

View file

@ -1,370 +1,371 @@
/* /*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET) * Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
* *
* This Source Code Form is subject to the terms of the Mozilla Public * This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
package ch.ethz.seb.sebserver.gbl.model.user; package ch.ethz.seb.sebserver.gbl.model.user;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.validation.constraints.Email; import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import ch.ethz.seb.sebserver.gbl.model.EntityName; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime;
import org.joda.time.DateTime; import org.joda.time.DateTimeZone;
import org.joda.time.DateTimeZone; import org.springframework.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty;
import ch.ethz.seb.sebserver.gbl.api.EntityType;
import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.model.Domain.USER;
import ch.ethz.seb.sebserver.gbl.model.Domain.USER; import ch.ethz.seb.sebserver.gbl.model.Domain.USER_ROLE;
import ch.ethz.seb.sebserver.gbl.model.Domain.USER_ROLE; import ch.ethz.seb.sebserver.gbl.model.EntityKey;
import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.model.EntityName;
import ch.ethz.seb.sebserver.gbl.util.Utils; import ch.ethz.seb.sebserver.gbl.util.Utils;
/** The user info domain model contains primary user information /** The user info domain model contains primary user information
* *
* This domain model is annotated and fully serializable and deserializable * This domain model is annotated and fully serializable and deserializable
* to and from JSON within the Jackson library. * to and from JSON within the Jackson library.
* *
* This domain model is immutable and thread-save */ * This domain model is immutable and thread-save */
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public final class UserInfo implements UserAccount, Serializable { public final class UserInfo implements UserAccount, Serializable {
private static final long serialVersionUID = 2526446136264377808L; private static final long serialVersionUID = 2526446136264377808L;
public static final String FILTER_ATTR_USER_NAME = "username"; public static final String FILTER_ATTR_SURNAME = "surname";
public static final String FILTER_ATTR_EMAIL = "email"; public static final String FILTER_ATTR_USER_NAME = "username";
public static final String FILTER_ATTR_LANGUAGE = "language"; public static final String FILTER_ATTR_EMAIL = "email";
public static final String FILTER_ATTR_ROLE = "role"; public static final String FILTER_ATTR_LANGUAGE = "language";
public static final String FILTER_ATTR_ROLE = "role";
/** The user's UUID */
@JsonProperty(USER.ATTR_UUID) /** The user's UUID */
public final String uuid; @JsonProperty(USER.ATTR_UUID)
public final String uuid;
/** The foreign key identifier to the institution where the User belongs to */
@NotNull(message = "user:institutionId:notNull") /** The foreign key identifier to the institution where the User belongs to */
@JsonProperty(USER.ATTR_INSTITUTION_ID) @NotNull(message = "user:institutionId:notNull")
public final Long institutionId; @JsonProperty(USER.ATTR_INSTITUTION_ID)
public final Long institutionId;
@JsonProperty(USER.ATTR_CREATION_DATE)
public final DateTime creationDate; @JsonProperty(USER.ATTR_CREATION_DATE)
public final DateTime creationDate;
/** First name of the user */
@NotNull(message = "user:name:notNull") /** First name of the user */
@Size(max = 255, message = "user:name:size:{min}:{max}:${validatedValue}") @NotNull(message = "user:name:notNull")
@JsonProperty(USER.ATTR_NAME) @Size(max = 255, message = "user:name:size:{min}:{max}:${validatedValue}")
public final String name; @JsonProperty(USER.ATTR_NAME)
public final String name;
/** Surname of the user */
@NotNull(message = "user:surname:notNull") /** Surname of the user */
@Size(max = 255, message = "user:surname:size:{min}:{max}:${validatedValue}") @NotNull(message = "user:surname:notNull")
@JsonProperty(USER.ATTR_SURNAME) @Size(max = 255, message = "user:surname:size:{min}:{max}:${validatedValue}")
public final String surname; @JsonProperty(USER.ATTR_SURNAME)
public final String surname;
/** The internal user name */
@NotNull(message = "user:username:notNull") /** The internal user name */
@Size(min = 3, max = 255, message = "user:username:size:{min}:{max}:${validatedValue}") @NotNull(message = "user:username:notNull")
@JsonProperty(USER.ATTR_USERNAME) @Size(min = 3, max = 255, message = "user:username:size:{min}:{max}:${validatedValue}")
public final String username; @JsonProperty(USER.ATTR_USERNAME)
public final String username;
/** E-mail address of the user */
@Email(message = "user:email:email:_:_:${validatedValue}") /** E-mail address of the user */
@JsonProperty(USER.ATTR_EMAIL) @Email(message = "user:email:email:_:_:${validatedValue}")
public final String email; @JsonProperty(USER.ATTR_EMAIL)
public final String email;
/** Indicates whether this user is still active or not */
@NotNull /** Indicates whether this user is still active or not */
@JsonProperty(USER.ATTR_ACTIVE) @NotNull
public final Boolean active; @JsonProperty(USER.ATTR_ACTIVE)
public final Boolean active;
/** The users locale */
@NotNull(message = "user:language:notNull") /** The users locale */
@JsonProperty(USER.ATTR_LANGUAGE) @NotNull(message = "user:language:notNull")
public final Locale language; @JsonProperty(USER.ATTR_LANGUAGE)
public final Locale language;
/** The users time zone */
@NotNull(message = "user:timeZone:notNull") /** The users time zone */
@JsonProperty(USER.ATTR_TIMEZONE) @NotNull(message = "user:timeZone:notNull")
public final DateTimeZone timeZone; @JsonProperty(USER.ATTR_TIMEZONE)
public final DateTimeZone timeZone;
/** The users roles in a unmodifiable set. Is never null */
@NotNull(message = "user:userRoles:notNull") /** The users roles in a unmodifiable set. Is never null */
@NotEmpty(message = "user:userRoles:notNull") @NotNull(message = "user:userRoles:notNull")
@JsonProperty(USER_ROLE.REFERENCE_NAME) @NotEmpty(message = "user:userRoles:notNull")
public final Set<String> roles; @JsonProperty(USER_ROLE.REFERENCE_NAME)
public final Set<String> roles;
@JsonCreator
public UserInfo( @JsonCreator
@JsonProperty(USER.ATTR_UUID) final String uuid, public UserInfo(
@JsonProperty(USER.ATTR_INSTITUTION_ID) final Long institutionId, @JsonProperty(USER.ATTR_UUID) final String uuid,
@JsonProperty(USER.ATTR_CREATION_DATE) final DateTime creationDate, @JsonProperty(USER.ATTR_INSTITUTION_ID) final Long institutionId,
@JsonProperty(USER.ATTR_NAME) final String name, @JsonProperty(USER.ATTR_CREATION_DATE) final DateTime creationDate,
@JsonProperty(USER.ATTR_SURNAME) final String surname, @JsonProperty(USER.ATTR_NAME) final String name,
@JsonProperty(USER.ATTR_USERNAME) final String username, @JsonProperty(USER.ATTR_SURNAME) final String surname,
@JsonProperty(USER.ATTR_EMAIL) final String email, @JsonProperty(USER.ATTR_USERNAME) final String username,
@JsonProperty(USER.ATTR_ACTIVE) final Boolean active, @JsonProperty(USER.ATTR_EMAIL) final String email,
@JsonProperty(USER.ATTR_LANGUAGE) final Locale language, @JsonProperty(USER.ATTR_ACTIVE) final Boolean active,
@JsonProperty(USER.ATTR_TIMEZONE) final DateTimeZone timeZone, @JsonProperty(USER.ATTR_LANGUAGE) final Locale language,
@JsonProperty(USER_ROLE.REFERENCE_NAME) final Set<String> roles) { @JsonProperty(USER.ATTR_TIMEZONE) final DateTimeZone timeZone,
@JsonProperty(USER_ROLE.REFERENCE_NAME) final Set<String> roles) {
this.uuid = uuid;
this.institutionId = institutionId; this.uuid = uuid;
this.creationDate = creationDate; this.institutionId = institutionId;
this.name = name; this.creationDate = creationDate;
this.surname = surname; this.name = name;
this.username = username; this.surname = surname;
this.email = email; this.username = username;
this.active = BooleanUtils.isTrue(active); this.email = email;
this.language = language; this.active = BooleanUtils.isTrue(active);
this.timeZone = timeZone; this.language = language;
this.roles = Utils.immutableSetOf(roles); this.timeZone = timeZone;
} this.roles = Utils.immutableSetOf(roles);
}
@Override
public EntityType entityType() { @Override
return EntityType.USER; public EntityType entityType() {
} return EntityType.USER;
}
@Override
public String getModelId() { @Override
return this.uuid; public String getModelId() {
} return this.uuid;
}
public String getUuid() {
return this.uuid; public String getUuid() {
} return this.uuid;
}
@Override
public DateTime getCreationDate() { @Override
return this.creationDate; public DateTime getCreationDate() {
} return this.creationDate;
}
@Override
public Long getInstitutionId() { @Override
return this.institutionId; public Long getInstitutionId() {
} return this.institutionId;
}
@Override
public String getOwnerId() { @Override
return this.uuid; public String getOwnerId() {
} return this.uuid;
}
@Override
public String getName() { @Override
return this.name; public String getName() {
} return this.name;
}
@Override
public String getSurname() { @Override
return this.surname; public String getSurname() {
} return this.surname;
}
@Override
public String getUsername() { @Override
return this.username; public String getUsername() {
} return this.username;
}
@Override
public String getEmail() { @Override
return this.email; public String getEmail() {
} return this.email;
}
@Override
public Boolean getActive() { @Override
return this.active; public Boolean getActive() {
} return this.active;
}
@Override
public boolean isActive() { @Override
return this.active; public boolean isActive() {
} return this.active;
}
@Override
public Locale getLanguage() { @Override
return this.language; public Locale getLanguage() {
} return this.language;
}
@Override
public DateTimeZone getTimeZone() { @Override
return this.timeZone; public DateTimeZone getTimeZone() {
} return this.timeZone;
}
@Override
public Set<String> getRoles() { @Override
return this.roles; public Set<String> getRoles() {
} return this.roles;
}
@Override
@JsonIgnore @Override
public EnumSet<UserRole> getUserRoles() { @JsonIgnore
return EnumSet.copyOf( public EnumSet<UserRole> getUserRoles() {
getRoles().stream() return EnumSet.copyOf(
.map(UserRole::valueOf) getRoles().stream()
.collect(Collectors.toList())); .map(UserRole::valueOf)
} .collect(Collectors.toList()));
}
public boolean hasRole(final UserRole userRole) {
if (userRole == null) { public boolean hasRole(final UserRole userRole) {
return false; if (userRole == null) {
} return false;
return this.roles.contains(userRole.name()); }
} return this.roles.contains(userRole.name());
}
public boolean hasAnyRole(final UserRole... userRole) {
if (userRole == null) { public boolean hasAnyRole(final UserRole... userRole) {
return false; if (userRole == null) {
} return false;
return CollectionUtils.containsAny(getUserRoles(), Arrays.asList(userRole)); }
} return CollectionUtils.containsAny(getUserRoles(), Arrays.asList(userRole));
}
@JsonIgnore
@Override @JsonIgnore
public EntityKey getEntityKey() { @Override
if (StringUtils.isBlank(this.uuid)) { public EntityKey getEntityKey() {
return null; if (StringUtils.isBlank(this.uuid)) {
} return null;
return new EntityKey(this.uuid, entityType()); }
} return new EntityKey(this.uuid, entityType());
}
@Override
public EntityName toName() { @Override
return new EntityName( public EntityName toName() {
this.getModelId(), return new EntityName(
this.entityType(), this.getModelId(),
this.getUsername() + " (" + this.getSurname() + " " + this.getName() + ")"); this.entityType(),
} this.getUsername() + " (" + this.getSurname() + " " + this.getName() + ")");
}
@Override
public int hashCode() { @Override
final int prime = 31; public int hashCode() {
int result = 1; final int prime = 31;
result = prime * result + ((this.uuid == null) ? 0 : this.uuid.hashCode()); int result = 1;
return result; result = prime * result + ((this.uuid == null) ? 0 : this.uuid.hashCode());
} return result;
}
@Override
public boolean equals(final Object obj) { @Override
if (this == obj) public boolean equals(final Object obj) {
return true; if (this == obj)
if (obj == null) return true;
return false; if (obj == null)
if (getClass() != obj.getClass()) return false;
return false; if (getClass() != obj.getClass())
final UserInfo other = (UserInfo) obj; return false;
if (this.uuid == null) { final UserInfo other = (UserInfo) obj;
if (other.uuid != null) if (this.uuid == null) {
return false; if (other.uuid != null)
} else if (!this.uuid.equals(other.uuid)) return false;
return false; } else if (!this.uuid.equals(other.uuid))
return true; return false;
} return true;
}
@Override
public String toString() { @Override
final StringBuilder builder = new StringBuilder(); public String toString() {
builder.append("UserInfo [uuid="); final StringBuilder builder = new StringBuilder();
builder.append(this.uuid); builder.append("UserInfo [uuid=");
builder.append(", institutionId="); builder.append(this.uuid);
builder.append(this.institutionId); builder.append(", institutionId=");
builder.append(", creationDate="); builder.append(this.institutionId);
builder.append(this.creationDate); builder.append(", creationDate=");
builder.append(", name="); builder.append(this.creationDate);
builder.append(this.name); builder.append(", name=");
builder.append(", surname="); builder.append(this.name);
builder.append(this.surname); builder.append(", surname=");
builder.append(", username="); builder.append(this.surname);
builder.append(this.username); builder.append(", username=");
builder.append(", email="); builder.append(this.username);
builder.append(this.email); builder.append(", email=");
builder.append(", active="); builder.append(this.email);
builder.append(this.active); builder.append(", active=");
builder.append(", language="); builder.append(this.active);
builder.append(this.language); builder.append(", language=");
builder.append(", timeZone="); builder.append(this.language);
builder.append(this.timeZone); builder.append(", timeZone=");
builder.append(", roles="); builder.append(this.timeZone);
builder.append(this.roles); builder.append(", roles=");
builder.append("]"); builder.append(this.roles);
return builder.toString(); builder.append("]");
} return builder.toString();
}
/** Use this to create a copy of a given UserInfo instance.
* /** Use this to create a copy of a given UserInfo instance.
* @param userInfo UserInfo instance to copy *
* @return copied UserInfo instance */ * @param userInfo UserInfo instance to copy
public static UserInfo of(final UserInfo userInfo) { * @return copied UserInfo instance */
return new UserInfo( public static UserInfo of(final UserInfo userInfo) {
userInfo.getUuid(), return new UserInfo(
userInfo.getInstitutionId(), userInfo.getUuid(),
userInfo.creationDate, userInfo.getInstitutionId(),
userInfo.getName(), userInfo.creationDate,
userInfo.getUsername(), userInfo.getName(),
userInfo.getSurname(), userInfo.getUsername(),
userInfo.getEmail(), userInfo.getSurname(),
userInfo.getActive(), userInfo.getEmail(),
userInfo.getLanguage(), userInfo.getActive(),
userInfo.getTimeZone(), userInfo.getLanguage(),
userInfo.roles); userInfo.getTimeZone(),
} userInfo.roles);
}
/** Use this to create a copy of a given UserInfo by overriding available arguments.
* /** Use this to create a copy of a given UserInfo by overriding available arguments.
* @param userInfo UserInfo instance to copy *
* @param name new name or null if the name of given userInfo should be taken * @param userInfo UserInfo instance to copy
* @param surname new surname or null if the name of given userInfo should be taken * @param name new name or null if the name of given userInfo should be taken
* @param username new username or null if the username of given userInfo should be taken * @param surname new surname or null if the name of given userInfo should be taken
* @param email new email or null if the email of given userInfo should be taken * @param username new username or null if the username of given userInfo should be taken
* @param language new language or null if the language of given userInfo should be taken * @param email new email or null if the email of given userInfo should be taken
* @param timeZone new timeZone or null if the timeZone of given userInfo should be taken * @param language new language or null if the language of given userInfo should be taken
* @param roles new timeZone or null if the roles of given userInfo should be taken * @param timeZone new timeZone or null if the timeZone of given userInfo should be taken
* @return copied UserInfo instance with the given attributes */ * @param roles new timeZone or null if the roles of given userInfo should be taken
public static UserInfo of( * @return copied UserInfo instance with the given attributes */
final UserInfo userInfo, public static UserInfo of(
final String name, final UserInfo userInfo,
final String username, final String name,
final String surname, final String username,
final String email, final String surname,
final Locale language, final String email,
final DateTimeZone timeZone, final Locale language,
final String... roles) { final DateTimeZone timeZone,
final String... roles) {
return new UserInfo(
userInfo.getUuid(), return new UserInfo(
userInfo.getInstitutionId(), userInfo.getUuid(),
userInfo.creationDate, userInfo.getInstitutionId(),
(name != null) ? name : userInfo.getName(), userInfo.creationDate,
(surname != null) ? surname : userInfo.getSurname(), (name != null) ? name : userInfo.getName(),
(username != null) ? username : userInfo.getUsername(), (surname != null) ? surname : userInfo.getSurname(),
(email != null) ? email : userInfo.getEmail(), (username != null) ? username : userInfo.getUsername(),
userInfo.getActive(), (email != null) ? email : userInfo.getEmail(),
(language != null) ? language : userInfo.getLanguage(), userInfo.getActive(),
(timeZone != null) ? timeZone : userInfo.getTimeZone(), (language != null) ? language : userInfo.getLanguage(),
(roles != null) ? new HashSet<>(Arrays.asList(roles)) : userInfo.roles); (timeZone != null) ? timeZone : userInfo.getTimeZone(),
} (roles != null) ? new HashSet<>(Arrays.asList(roles)) : userInfo.roles);
}
public static UserInfo withEMail(final UserInfo userInfo, final String email) {
return of(userInfo, null, null, null, email, null, null, (String[]) null); public static UserInfo withEMail(final UserInfo userInfo, final String email) {
} return of(userInfo, null, null, null, email, null, null, (String[]) null);
}
public static UserInfo withRoles(final UserInfo userInfo, final String... roles) {
return of(userInfo, null, null, null, null, null, null, roles); public static UserInfo withRoles(final UserInfo userInfo, final String... roles) {
} return of(userInfo, null, null, null, null, null, null, roles);
} }
}

View file

@ -8,6 +8,14 @@
package ch.ethz.seb.sebserver.gui.content; package ch.ethz.seb.sebserver.gui.content;
import java.util.Map;
import java.util.function.Function;
import org.eclipse.swt.widgets.Composite;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection; import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection;
@ -30,13 +38,6 @@ import ch.ethz.seb.sebserver.gui.table.ColumnDefinition.TableFilterAttribute;
import ch.ethz.seb.sebserver.gui.table.EntityTable; import ch.ethz.seb.sebserver.gui.table.EntityTable;
import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType; import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
import org.eclipse.swt.widgets.Composite;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.function.Function;
@Lazy @Lazy
@Component @Component
@ -134,7 +135,7 @@ public class SebClientLogs implements TemplateComposer {
.widthProportion(2)) .widthProportion(2))
.withColumn(new ColumnDefinition<ExtendedClientEvent>( .withColumn(new ColumnDefinition<ExtendedClientEvent>(
Domain.CLIENT_EVENT.TYPE_NAME, Domain.CLIENT_EVENT.ATTR_TYPE,
TYPE_TEXT_KEY, TYPE_TEXT_KEY,
this.resourceService::getEventTypeName) this.resourceService::getEventTypeName)
.withFilter(this.eventTypeFilter) .withFilter(this.eventTypeFilter)
@ -166,7 +167,8 @@ public class SebClientLogs implements TemplateComposer {
.withDefaultAction(t -> actionBuilder .withDefaultAction(t -> actionBuilder
.newAction(ActionDefinition.LOGS_SEB_CLIENT_SHOW_DETAILS) .newAction(ActionDefinition.LOGS_SEB_CLIENT_SHOW_DETAILS)
.withExec(action -> sebClientLogDetailsPopup.showDetails(action, t.getSingleSelectedROWData())) .withExec(action -> this.sebClientLogDetailsPopup.showDetails(action,
t.getSingleSelectedROWData()))
.noEventPropagation() .noEventPropagation()
.create()) .create())
@ -180,14 +182,12 @@ public class SebClientLogs implements TemplateComposer {
.newAction(ActionDefinition.LOGS_SEB_CLIENT_SHOW_DETAILS) .newAction(ActionDefinition.LOGS_SEB_CLIENT_SHOW_DETAILS)
.withSelect( .withSelect(
table::getSelection, table::getSelection,
action -> sebClientLogDetailsPopup.showDetails(action, table.getSingleSelectedROWData()), action -> this.sebClientLogDetailsPopup.showDetails(action, table.getSingleSelectedROWData()),
EMPTY_SELECTION_TEXT) EMPTY_SELECTION_TEXT)
.noEventPropagation() .noEventPropagation()
.publishIf(table::hasAnyContent, false); .publishIf(table::hasAnyContent, false);
} }
private Function<ExtendedClientEvent, String> examNameFunction() { private Function<ExtendedClientEvent, String> examNameFunction() {
final Map<Long, String> examNameMapping = this.resourceService.getExamNameMapping(); final Map<Long, String> examNameMapping = this.resourceService.getExamNameMapping();
return event -> examNameMapping.get(event.examId); return event -> examNameMapping.get(event.examId);

View file

@ -8,6 +8,15 @@
package ch.ethz.seb.sebserver.gui.content; package ch.ethz.seb.sebserver.gui.content;
import java.util.function.BooleanSupplier;
import java.util.function.Function;
import org.apache.commons.lang3.BooleanUtils;
import org.eclipse.swt.widgets.Composite;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.EntityType;
@ -36,14 +45,6 @@ import ch.ethz.seb.sebserver.gui.table.ColumnDefinition.TableFilterAttribute;
import ch.ethz.seb.sebserver.gui.table.EntityTable; import ch.ethz.seb.sebserver.gui.table.EntityTable;
import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType; import ch.ethz.seb.sebserver.gui.table.TableFilter.CriteriaType;
import ch.ethz.seb.sebserver.gui.widget.WidgetFactory; import ch.ethz.seb.sebserver.gui.widget.WidgetFactory;
import org.apache.commons.lang3.BooleanUtils;
import org.eclipse.swt.widgets.Composite;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.function.BooleanSupplier;
import java.util.function.Function;
@Lazy @Lazy
@Component @Component
@ -67,6 +68,8 @@ public class UserAccountList implements TemplateComposer {
new LocTextKey("sebserver.useraccount.list.column.username"); new LocTextKey("sebserver.useraccount.list.column.username");
private static final LocTextKey NAME_TEXT_KEY = private static final LocTextKey NAME_TEXT_KEY =
new LocTextKey("sebserver.useraccount.list.column.name"); new LocTextKey("sebserver.useraccount.list.column.name");
private static final LocTextKey SURNAME_TEXT_KEY =
new LocTextKey("sebserver.useraccount.list.column.surname");
private static final LocTextKey TITLE_TEXT_KEY = private static final LocTextKey TITLE_TEXT_KEY =
new LocTextKey("sebserver.useraccount.list.title"); new LocTextKey("sebserver.useraccount.list.title");
private static final LocTextKey NO_EDIT_RIGHT_MESSAGE = private static final LocTextKey NO_EDIT_RIGHT_MESSAGE =
@ -76,6 +79,8 @@ public class UserAccountList implements TemplateComposer {
private final TableFilterAttribute institutionFilter; private final TableFilterAttribute institutionFilter;
private final TableFilterAttribute nameFilter = private final TableFilterAttribute nameFilter =
new TableFilterAttribute(CriteriaType.TEXT, Entity.FILTER_ATTR_NAME); new TableFilterAttribute(CriteriaType.TEXT, Entity.FILTER_ATTR_NAME);
private final TableFilterAttribute surnameFilter =
new TableFilterAttribute(CriteriaType.TEXT, UserInfo.FILTER_ATTR_SURNAME);
private final TableFilterAttribute usernameFilter = private final TableFilterAttribute usernameFilter =
new TableFilterAttribute(CriteriaType.TEXT, UserInfo.FILTER_ATTR_USER_NAME); new TableFilterAttribute(CriteriaType.TEXT, UserInfo.FILTER_ATTR_USER_NAME);
private final TableFilterAttribute mailFilter = private final TableFilterAttribute mailFilter =
@ -152,6 +157,14 @@ public class UserAccountList implements TemplateComposer {
.sortable() .sortable()
.widthProportion(2)) .widthProportion(2))
.withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_SURNAME,
SURNAME_TEXT_KEY,
UserInfo::getSurname)
.withFilter(this.surnameFilter)
.sortable()
.widthProportion(2))
.withColumn(new ColumnDefinition<>( .withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_USERNAME, Domain.USER.ATTR_USERNAME,
USER_NAME_TEXT_KEY, USER_NAME_TEXT_KEY,

View file

@ -217,6 +217,7 @@ public class PaginationServiceImpl implements PaginationService {
// User Table // User Table
final Map<String, String> userTableMap = new HashMap<>(); final Map<String, String> userTableMap = new HashMap<>();
userTableMap.put(Domain.USER.ATTR_NAME, UserRecordDynamicSqlSupport.name.name()); userTableMap.put(Domain.USER.ATTR_NAME, UserRecordDynamicSqlSupport.name.name());
userTableMap.put(Domain.USER.ATTR_SURNAME, UserRecordDynamicSqlSupport.surname.name());
userTableMap.put(Domain.USER.ATTR_USERNAME, UserRecordDynamicSqlSupport.username.name()); userTableMap.put(Domain.USER.ATTR_USERNAME, UserRecordDynamicSqlSupport.username.name());
userTableMap.put(Domain.USER.ATTR_EMAIL, UserRecordDynamicSqlSupport.email.name()); userTableMap.put(Domain.USER.ATTR_EMAIL, UserRecordDynamicSqlSupport.email.name());
userTableMap.put(Domain.USER.ATTR_LANGUAGE, UserRecordDynamicSqlSupport.language.name()); userTableMap.put(Domain.USER.ATTR_LANGUAGE, UserRecordDynamicSqlSupport.language.name());

View file

@ -65,6 +65,10 @@ public class FilterMap extends POSTMapper {
return getSQLWildcard(Entity.FILTER_ATTR_NAME); return getSQLWildcard(Entity.FILTER_ATTR_NAME);
} }
public String getSurname() {
return getSQLWildcard(UserInfo.FILTER_ATTR_SURNAME);
}
public String getQuizName() { public String getQuizName() {
return getString(Entity.FILTER_ATTR_NAME); return getString(Entity.FILTER_ATTR_NAME);
} }

View file

@ -172,6 +172,9 @@ public class UserDAOImpl implements UserDAO {
.and( .and(
UserRecordDynamicSqlSupport.name, UserRecordDynamicSqlSupport.name,
isLikeWhenPresent(filterMap.getName())) isLikeWhenPresent(filterMap.getName()))
.and(
UserRecordDynamicSqlSupport.surname,
isLikeWhenPresent(filterMap.getSurname()))
.and( .and(
UserRecordDynamicSqlSupport.username, UserRecordDynamicSqlSupport.username,
isLikeWhenPresent(filterMap.getUserUsername())) isLikeWhenPresent(filterMap.getUserUsername()))

View file

@ -196,6 +196,8 @@ sebserver.useraccount.list.column.institution=Institution
sebserver.useraccount.list.column.institution.tooltip=The institution of the user account.<br/><br/>Use the filter above to specify the institution.<br/>{0} sebserver.useraccount.list.column.institution.tooltip=The institution of the user account.<br/><br/>Use the filter above to specify the institution.<br/>{0}
sebserver.useraccount.list.column.name=First Name sebserver.useraccount.list.column.name=First Name
sebserver.useraccount.list.column.name.tooltip=The first name of the user.<br/><br/>Use the filter above to narrow down a specific first name.<br/>{0} sebserver.useraccount.list.column.name.tooltip=The first name of the user.<br/><br/>Use the filter above to narrow down a specific first name.<br/>{0}
sebserver.useraccount.list.column.surname=Surname
sebserver.useraccount.list.column.surname.tooltip=The surname of the user.<br/><br/>Use the filter above to narrow down a specific surname.<br/>{0}
sebserver.useraccount.list.column.username=User Name sebserver.useraccount.list.column.username=User Name
sebserver.useraccount.list.column.username.tooltip=The internal user name of the user.<br/><br/>Use the filter above to narrow down a specific user name.<br/>{0} sebserver.useraccount.list.column.username.tooltip=The internal user name of the user.<br/><br/>Use the filter above to narrow down a specific user name.<br/>{0}
sebserver.useraccount.list.column.email=Mail sebserver.useraccount.list.column.email=Mail