minor fixes and tables

This commit is contained in:
anhefti 2019-06-05 13:10:07 +02:00
parent bbb15bba40
commit 652de887a5
93 changed files with 407 additions and 323 deletions

View file

@ -12,6 +12,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
public final class ExamAPIDiscovery {
@ -28,11 +29,12 @@ public final class ExamAPIDiscovery {
@JsonProperty("api-versions")
public final Collection<ExamAPIVersion> versions;
@JsonCreator
public ExamAPIDiscovery(
final String title,
final String description,
final String serverLocation,
final Collection<ExamAPIVersion> versions) {
@JsonProperty("title") final String title,
@JsonProperty("description") final String description,
@JsonProperty("server-location") final String serverLocation,
@JsonProperty("api-versions") final Collection<ExamAPIVersion> versions) {
this.title = title;
this.description = description;
@ -61,9 +63,10 @@ public final class ExamAPIDiscovery {
@JsonProperty("endpoints")
public final Collection<Endpoint> endpoints;
@JsonCreator
public ExamAPIVersion(
final String name,
final Collection<Endpoint> endpoints) {
@JsonProperty("name") final String name,
@JsonProperty("endpoints") final Collection<Endpoint> endpoints) {
this.name = name;
this.endpoints = endpoints;
@ -92,9 +95,13 @@ public final class ExamAPIDiscovery {
@JsonProperty("authorization")
public final String authorization;
public Endpoint(final String name, final String descripiton, final String location,
final String authorization) {
super();
@JsonCreator
public Endpoint(
@JsonProperty("name") final String name,
@JsonProperty("descripiton") final String descripiton,
@JsonProperty("location") final String location,
@JsonProperty("authorization") final String authorization) {
this.name = name;
this.descripiton = descripiton;
this.location = location;

View file

@ -26,8 +26,8 @@ import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus;
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
@ -283,18 +283,15 @@ public class ExamForm implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
Domain.CONFIGURATION_NODE.ATTR_NAME,
CONFIG_NAME_COLUMN_KEY,
ExamConfigurationMap::getConfigName,
false))
ExamConfigurationMap::getConfigName))
.withColumn(new ColumnDefinition<>(
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
CONFIG_DESCRIPTION_COLUMN_KEY,
ExamConfigurationMap::getConfigDescription,
false))
ExamConfigurationMap::getConfigDescription))
.withColumn(new ColumnDefinition<>(
Domain.CONFIGURATION_NODE.ATTR_STATUS,
CONFIG_STATUS_COLUMN_KEY,
this.resourceService::localizedExamConfigStatusName,
false))
this.resourceService::localizedExamConfigStatusName))
.withDefaultActionIf(
() -> editable,
() -> actionBuilder
@ -350,18 +347,15 @@ public class ExamForm implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
Domain.INDICATOR.ATTR_NAME,
INDICATOR_NAME_COLUMN_KEY,
Indicator::getName,
false))
Indicator::getName))
.withColumn(new ColumnDefinition<>(
Domain.INDICATOR.ATTR_TYPE,
INDICATOR_TYPE_COLUMN_KEY,
this::indicatorTypeName,
false))
this::indicatorTypeName))
.withColumn(new ColumnDefinition<>(
Domain.THRESHOLD.REFERENCE_NAME,
INDICATOR_THRESHOLD_COLUMN_KEY,
ExamForm::thresholdsValue,
false))
ExamForm::thresholdsValue))
.withDefaultActionIf(
() -> editable,
() -> actionBuilder

View file

@ -110,28 +110,28 @@ public class ExamList implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
Domain.EXAM.ATTR_LMS_SETUP_ID,
columnTitleLmsSetupKey,
examLmsSetupNameFunction(this.resourceService),
this.lmsFilter,
false))
examLmsSetupNameFunction(this.resourceService))
.withFilter(this.lmsFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_NAME,
columnTitleNameKey,
Exam::getName,
this.nameFilter,
true))
Exam::getName)
.withFilter(this.nameFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_START_TIME,
new LocTextKey(
"sebserver.exam.list.column.starttime",
i18nSupport.getUsersTimeZoneTitleSuffix()),
Exam::getStartTime,
this.startTimeFilter,
true))
Exam::getStartTime)
.withFilter(this.startTimeFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.EXAM.ATTR_TYPE,
columnTitleTypeKey,
this::examTypeName,
true))
this::examTypeName)
.sortable())
.withDefaultAction(actionBuilder
.newAction(ActionDefinition.EXAM_VIEW_FROM_LIST)
.create())

View file

@ -79,20 +79,20 @@ public class InstitutionList implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
Domain.INSTITUTION.ATTR_NAME,
NAME_TEXT_KEY,
entity -> entity.name,
true))
Institution::getName)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.INSTITUTION.ATTR_URL_SUFFIX,
URL_TEXT_KEY,
entity -> entity.urlSuffix,
true))
.withColumn(new ColumnDefinition<>(
Institution::getUrlSuffix)
.sortable())
.withColumn(new ColumnDefinition<Institution>(
Domain.INSTITUTION.ATTR_ACTIVE,
ACTIVE_TEXT_KEY,
entity -> this.pageService
.getResourceService()
.localizedActivityResource().apply(entity.active),
true))
.localizedActivityResource().apply(entity.active))
.sortable())
.withDefaultAction(pageActionBuilder
.newAction(ActionDefinition.INSTITUTION_VIEW_FROM_LIST)
.create())
@ -118,7 +118,6 @@ public class InstitutionList implements TemplateComposer {
.withSelect(table::getSelection, PageAction::applySingleSelection, EMPTY_SELECTION_TEXT_KEY)
.publishIf(() -> instGrant.m() && table.hasAnyContent());
;
}
}

View file

@ -113,26 +113,27 @@ public class LmsSetupList implements TemplateComposer {
() -> new ColumnDefinition<>(
Domain.LMS_SETUP.ATTR_INSTITUTION_ID,
INSTITUTION_TEXT_KEY,
lmsSetupInstitutionNameFunction(this.resourceService),
this.institutionFilter,
false))
lmsSetupInstitutionNameFunction(this.resourceService))
.withFilter(this.institutionFilter))
.withColumn(new ColumnDefinition<>(
Domain.LMS_SETUP.ATTR_NAME,
NAME_TEXT_KEY,
entity -> entity.name,
(isSEBAdmin) ? this.nameFilter : null,
true))
LmsSetup::getName)
.withFilter((isSEBAdmin) ? this.nameFilter : null)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.LMS_SETUP.ATTR_LMS_TYPE,
TYPE_TEXT_KEY,
this::lmsSetupTypeName,
(isSEBAdmin) ? this.typeFilter : null,
false, true))
this::lmsSetupTypeName)
.withFilter((isSEBAdmin) ? this.typeFilter : null)
.localized()
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.LMS_SETUP.ATTR_ACTIVE,
ACTIVITY_TEXT_KEY,
entity -> entity.active,
true))
LmsSetup::getActive)
.sortable())
.withDefaultAction(actionBuilder
.newAction(ActionDefinition.LMS_SETUP_VIEW_FROM_LIST)
.create())

View file

@ -128,30 +128,30 @@ public class QuizDiscoveryList implements TemplateComposer {
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_LMS_SETUP_ID,
LMS_TEXT_KEY,
quizDataLmsSetupNameFunction(this.resourceService),
this.lmsFilter,
false))
quizDataLmsSetupNameFunction(this.resourceService))
.withFilter(this.lmsFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_NAME,
NAME_TEXT_KEY,
quizData -> quizData.name,
this.nameFilter,
true))
QuizData::getName)
.withFilter(this.nameFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_START_TIME,
new LocTextKey(
"sebserver.quizdiscovery.list.column.starttime",
i18nSupport.getUsersTimeZoneTitleSuffix()),
quizData -> quizData.startTime,
this.startTimeFilter,
true))
QuizData::getStartTime)
.withFilter(this.startTimeFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
QuizData.QUIZ_ATTR_END_TIME,
new LocTextKey(
"sebserver.quizdiscovery.list.column.endtime",
i18nSupport.getUsersTimeZoneTitleSuffix()),
quizData -> quizData.endTime,
true))
QuizData::getEndTime)
.sortable())
.withDefaultAction(t -> actionBuilder
.newAction(ActionDefinition.QUIZ_DISCOVERY_SHOW_DETAILS)
.withExec(action -> this.showDetails(action, t.getSelectedROWData()))

View file

@ -117,28 +117,27 @@ public class SebClientConfigList implements TemplateComposer {
() -> new ColumnDefinition<>(
Domain.LMS_SETUP.ATTR_INSTITUTION_ID,
INSTITUTION_TEXT_KEY,
clientConfigInstitutionNameFunction(this.resourceService),
this.institutionFilter,
false))
clientConfigInstitutionNameFunction(this.resourceService))
.withFilter(this.institutionFilter))
.withColumn(new ColumnDefinition<>(
Domain.SEB_CLIENT_CONFIGURATION.ATTR_NAME,
NAME_TEXT_KEY,
entity -> entity.name,
this.nameFilter,
true))
SebClientConfig::getName)
.withFilter(this.nameFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.SEB_CLIENT_CONFIGURATION.ATTR_DATE,
new LocTextKey(
"sebserver.clientconfig.list.column.date",
i18nSupport.getUsersTimeZoneTitleSuffix()),
entity -> entity.date,
this.dateFilter,
true))
SebClientConfig::getDate)
.withFilter(this.dateFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.SEB_CLIENT_CONFIGURATION.ATTR_ACTIVE,
ACTIVE_TEXT_KEY,
entity -> entity.active,
true))
SebClientConfig::getActive)
.sortable())
.withDefaultAction(pageActionBuilder
.newAction(ActionDefinition.SEB_CLIENT_CONFIG_VIEW_FROM_LIST)
.create())

View file

@ -111,27 +111,27 @@ public class SebExamConfigList implements TemplateComposer {
() -> new ColumnDefinition<>(
Domain.LMS_SETUP.ATTR_INSTITUTION_ID,
INSTITUTION_TEXT_KEY,
this.resourceService::localizedExamConfigInstitutionName,
this.institutionFilter,
false))
this.resourceService::localizedExamConfigInstitutionName)
.withFilter(this.institutionFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.CONFIGURATION_NODE.ATTR_NAME,
NAME_TEXT_KEY,
entity -> entity.name,
this.nameFilter,
true))
ConfigurationNode::getName)
.withFilter(this.nameFilter)
.sortable())
.withColumn(new ColumnDefinition<>(
Domain.CONFIGURATION_NODE.ATTR_DESCRIPTION,
DESCRIPTION_TEXT_KEY,
entity -> entity.description,
this.nameFilter,
true))
.withColumn(new ColumnDefinition<>(
ConfigurationNode::getDescription)
.withFilter(this.nameFilter)
.sortable())
.withColumn(new ColumnDefinition<ConfigurationNode>(
Domain.CONFIGURATION_NODE.ATTR_STATUS,
STATUS_TEXT_KEY,
this.resourceService::localizedExamConfigStatusName,
this.statusFilter,
true))
this.resourceService::localizedExamConfigStatusName)
.withFilter(this.statusFilter)
.sortable())
.withDefaultAction(pageActionBuilder
.newAction(ActionDefinition.SEB_EXAM_CONFIG_VIEW_PROP_FROM_LIST)
.create())

View file

@ -123,38 +123,44 @@ public class UserAccountList implements TemplateComposer {
() -> new ColumnDefinition<>(
Domain.USER.ATTR_INSTITUTION_ID,
INSTITUTION_TEXT_KEY,
userInstitutionNameFunction(this.resourceService),
this.institutionFilter,
false))
userInstitutionNameFunction(this.resourceService))
.withFilter(this.institutionFilter)
.widthProportion(2))
.withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_NAME,
NAME_TEXT_KEY,
entity -> entity.name,
this.nameFilter,
true))
UserInfo::getName)
.withFilter(this.nameFilter)
.sortable()
.widthProportion(2))
.withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_USERNAME,
USER_NAME_TEXT_KEY,
entity -> entity.username,
this.usernameFilter,
true))
UserInfo::getUsername)
.withFilter(this.usernameFilter)
.sortable()
.widthProportion(2))
.withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_EMAIL,
MAIL_TEXT_KEY,
entity -> entity.email,
this.mailFilter,
true))
UserInfo::getEmail)
.withFilter(this.mailFilter)
.sortable()
.widthProportion(3))
.withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_LANGUAGE,
LANG_TEXT_KEY,
this::getLocaleDisplayText,
this.languageFilter,
true, true))
this::getLocaleDisplayText)
.withFilter(this.languageFilter)
.localized()
.sortable()
.widthProportion(2))
.withColumn(new ColumnDefinition<>(
Domain.USER.ATTR_ACTIVE,
ACTIVE_TEXT_KEY,
entity -> entity.active,
true))
UserInfo::getActive)
.sortable()
.widthProportion(1))
.withDefaultAction(actionBuilder
.newAction(ActionDefinition.USER_ACCOUNT_VIEW_FROM_LIST)
.create())

View file

@ -69,7 +69,9 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
true, false,
(tableContext.orientation != null) ? tableContext.orientation.width() : 1,
(tableContext.orientation != null) ? tableContext.orientation.height() : 1);
gridData.heightHint = tableContext.orientation.height * 20 + 40;
if (tableContext.orientation.height != null) {
gridData.heightHint = tableContext.orientation.height * 20 + 40;
}
table.setLayoutData(gridData);
table.setHeaderVisible(true);
table.addListener(SWT.Resize, event -> adaptColumnWidth(table, tableContext));
@ -267,7 +269,7 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
final Map<Long, TableValue> rowValues,
final int index) {
if (values != null && !values.isEmpty()) {
if (!values.isEmpty()) {
values.remove(index);
values.add(index, rowValues);
applyTableRowValues(index);

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ActivateExam extends RestCall<EntityProcessingReport> {
protected ActivateExam() {
public ActivateExam() {
super(new TypeKey<>(
CallType.ACTIVATION_ACTIVATE,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeactivateExam extends RestCall<EntityProcessingReport> {
protected DeactivateExam() {
public DeactivateExam() {
super(new TypeKey<>(
CallType.ACTIVATION_DEACTIVATE,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeleteExamConfigMapping extends RestCall<EntityProcessingReport> {
protected DeleteExamConfigMapping() {
public DeleteExamConfigMapping() {
super(new TypeKey<>(
CallType.DELETE,
EntityType.EXAM_CONFIGURATION_MAP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeleteIndicator extends RestCall<EntityProcessingReport> {
protected DeleteIndicator() {
public DeleteIndicator() {
super(new TypeKey<>(
CallType.DELETE,
EntityType.INDICATOR,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExam extends RestCall<Exam> {
protected GetExam() {
public GetExam() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamConfigMapping extends RestCall<ExamConfigurationMap> {
protected GetExamConfigMapping() {
public GetExamConfigMapping() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.EXAM_CONFIGURATION_MAP,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamConfigMappingNames extends RestCall<List<EntityName>> {
protected GetExamConfigMappingNames() {
public GetExamConfigMappingNames() {
super(new TypeKey<>(
CallType.GET_NAMES,
EntityType.CONFIGURATION_NODE,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamConfigMappingsPage extends RestCall<Page<ExamConfigurationMap>> {
protected GetExamConfigMappingsPage() {
public GetExamConfigMappingsPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.EXAM_CONFIGURATION_MAP,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamDependencies extends RestCall<Set<EntityKey>> {
protected GetExamDependencies() {
public GetExamDependencies() {
super(new TypeKey<>(
CallType.GET_DEPENDENCIES,
EntityType.EXAM,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamNames extends RestCall<List<EntityName>> {
protected GetExamNames() {
public GetExamNames() {
super(new TypeKey<>(
CallType.GET_NAMES,
EntityType.EXAM,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamPage extends RestCall<Page<Exam>> {
protected GetExamPage() {
public GetExamPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetIndicator extends RestCall<Indicator> {
protected GetIndicator() {
public GetIndicator() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.INDICATOR,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetIndicators extends RestCall<Page<Indicator>> {
protected GetIndicators() {
public GetIndicators() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.INDICATOR,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewExamConfigMapping extends RestCall<ExamConfigurationMap> {
protected NewExamConfigMapping() {
public NewExamConfigMapping() {
super(new TypeKey<>(
CallType.NEW,
EntityType.EXAM_CONFIGURATION_MAP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewIndicator extends RestCall<Indicator> {
protected NewIndicator() {
public NewIndicator() {
super(new TypeKey<>(
CallType.NEW,
EntityType.INDICATOR,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveExam extends RestCall<Exam> {
protected SaveExam() {
public SaveExam() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveExamConfigMapping extends RestCall<ExamConfigurationMap> {
protected SaveExamConfigMapping() {
public SaveExamConfigMapping() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.EXAM_CONFIGURATION_MAP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveIndicator extends RestCall<Indicator> {
protected SaveIndicator() {
public SaveIndicator() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.INDICATOR,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ActivateInstitution extends RestCall<EntityProcessingReport> {
protected ActivateInstitution() {
public ActivateInstitution() {
super(new TypeKey<>(
CallType.ACTIVATION_ACTIVATE,
EntityType.INSTITUTION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeactivateInstitution extends RestCall<EntityProcessingReport> {
protected DeactivateInstitution() {
public DeactivateInstitution() {
super(new TypeKey<>(
CallType.ACTIVATION_DEACTIVATE,
EntityType.INSTITUTION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetInstitution extends RestCall<Institution> {
protected GetInstitution() {
public GetInstitution() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.INSTITUTION,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetInstitutionDependency extends RestCall<Set<EntityKey>> {
protected GetInstitutionDependency() {
public GetInstitutionDependency() {
super(new TypeKey<>(
CallType.GET_DEPENDENCIES,
EntityType.INSTITUTION,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetInstitutionNames extends RestCall<List<EntityName>> {
protected GetInstitutionNames() {
public GetInstitutionNames() {
super(new TypeKey<>(
CallType.GET_NAMES,
EntityType.INSTITUTION,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetInstitutionPage extends RestCall<Page<Institution>> {
protected GetInstitutionPage() {
public GetInstitutionPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.INSTITUTION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewInstitution extends RestCall<Institution> {
protected NewInstitution() {
public NewInstitution() {
super(new TypeKey<>(
CallType.NEW,
EntityType.INSTITUTION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveInstitution extends RestCall<Institution> {
protected SaveInstitution() {
public SaveInstitution() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.INSTITUTION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ActivateLmsSetup extends RestCall<EntityProcessingReport> {
protected ActivateLmsSetup() {
public ActivateLmsSetup() {
super(new TypeKey<>(
CallType.ACTIVATION_ACTIVATE,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeactivateLmsSetup extends RestCall<EntityProcessingReport> {
protected DeactivateLmsSetup() {
public DeactivateLmsSetup() {
super(new TypeKey<>(
CallType.ACTIVATION_DEACTIVATE,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetLmsSetup extends RestCall<LmsSetup> {
protected GetLmsSetup() {
public GetLmsSetup() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.LMS_SETUP,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetLmsSetupDependencies extends RestCall<Set<EntityKey>> {
protected GetLmsSetupDependencies() {
public GetLmsSetupDependencies() {
super(new TypeKey<>(
CallType.GET_DEPENDENCIES,
EntityType.LMS_SETUP,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetLmsSetupNames extends RestCall<List<EntityName>> {
protected GetLmsSetupNames() {
public GetLmsSetupNames() {
super(new TypeKey<>(
CallType.GET_NAMES,
EntityType.LMS_SETUP,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetLmsSetupPage extends RestCall<Page<LmsSetup>> {
protected GetLmsSetupPage() {
public GetLmsSetupPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewLmsSetup extends RestCall<LmsSetup> {
protected NewLmsSetup() {
public NewLmsSetup() {
super(new TypeKey<>(
CallType.NEW,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveLmsSetup extends RestCall<LmsSetup> {
protected SaveLmsSetup() {
public SaveLmsSetup() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class TestLmsSetup extends RestCall<LmsSetupTestResult> {
protected TestLmsSetup() {
public TestLmsSetup() {
super(new TypeKey<>(
CallType.UNDEFINED,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class TestLmsSetupAdHoc extends RestCall<LmsSetupTestResult> {
protected TestLmsSetupAdHoc() {
public TestLmsSetupAdHoc() {
super(new TypeKey<>(
CallType.UNDEFINED,
EntityType.LMS_SETUP,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetQuizData extends RestCall<QuizData> {
protected GetQuizData() {
public GetQuizData() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.EXAM,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetQuizPage extends RestCall<Page<QuizData>> {
protected GetQuizPage() {
public GetQuizPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ImportAsExam extends RestCall<Exam> {
protected ImportAsExam() {
public ImportAsExam() {
super(new TypeKey<>(
CallType.NEW,
EntityType.EXAM,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ActivateClientConfig extends RestCall<EntityProcessingReport> {
protected ActivateClientConfig() {
public ActivateClientConfig() {
super(new TypeKey<>(
CallType.ACTIVATION_ACTIVATE,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeactivateClientConfig extends RestCall<EntityProcessingReport> {
protected DeactivateClientConfig() {
public DeactivateClientConfig() {
super(new TypeKey<>(
CallType.ACTIVATION_DEACTIVATE,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -25,7 +25,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractExportCal
@GuiProfile
public class ExportClientConfig extends AbstractExportCall {
protected ExportClientConfig() {
public ExportClientConfig() {
super(new TypeKey<>(
CallType.UNDEFINED,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetClientConfig extends RestCall<SebClientConfig> {
protected GetClientConfig() {
public GetClientConfig() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetClientConfigPage extends RestCall<Page<SebClientConfig>> {
protected GetClientConfigPage() {
public GetClientConfigPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewClientConfig extends RestCall<SebClientConfig> {
protected NewClientConfig() {
public NewClientConfig() {
super(new TypeKey<>(
CallType.NEW,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveClientConfig extends RestCall<SebClientConfig> {
protected SaveClientConfig() {
public SaveClientConfig() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.SEB_CLIENT_CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ActivateExamConfig extends RestCall<EntityProcessingReport> {
protected ActivateExamConfig() {
public ActivateExamConfig() {
super(new TypeKey<>(
CallType.ACTIVATION_ACTIVATE,
EntityType.CONFIGURATION_NODE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeactivateExamConfig extends RestCall<EntityProcessingReport> {
protected DeactivateExamConfig() {
public DeactivateExamConfig() {
super(new TypeKey<>(
CallType.ACTIVATION_DEACTIVATE,
EntityType.CONFIGURATION_NODE,

View file

@ -25,7 +25,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.AbstractExportCal
@GuiProfile
public class ExportPlainXML extends AbstractExportCall {
protected ExportPlainXML() {
public ExportPlainXML() {
super(new TypeKey<>(
CallType.UNDEFINED,
EntityType.CONFIGURATION_NODE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetConfiguration extends RestCall<Configuration> {
protected GetConfiguration() {
public GetConfiguration() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.CONFIGURATION,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetConfigurationPage extends RestCall<Page<Configuration>> {
protected GetConfigurationPage() {
public GetConfigurationPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.CONFIGURATION,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetConfigurationValuePage extends RestCall<Page<ConfigurationValue>> {
protected GetConfigurationValuePage() {
public GetConfigurationValuePage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.CONFIGURATION_VALUE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.PageToListCallAda
@GuiProfile
public class GetConfigurationValues extends PageToListCallAdapter<ConfigurationValue> {
protected GetConfigurationValues() {
public GetConfigurationValues() {
super(
GetConfigurationValuePage.class,
EntityType.CONFIGURATION_VALUE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.PageToListCallAda
@GuiProfile
public class GetConfigurations extends PageToListCallAdapter<Configuration> {
protected GetConfigurations() {
public GetConfigurations() {
super(
GetConfigurationPage.class,
EntityType.CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamConfigNode extends RestCall<ConfigurationNode> {
protected GetExamConfigNode() {
public GetExamConfigNode() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.CONFIGURATION_NODE,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetExamConfigNodePage extends RestCall<Page<ConfigurationNode>> {
protected GetExamConfigNodePage() {
public GetExamConfigNodePage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.CONFIGURATION_NODE,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetOrientationPage extends RestCall<Page<Orientation>> {
protected GetOrientationPage() {
public GetOrientationPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.ORIENTATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.PageToListCallAda
@GuiProfile
public class GetOrientations extends PageToListCallAdapter<Orientation> {
protected GetOrientations() {
public GetOrientations() {
super(
GetOrientationPage.class,
EntityType.ORIENTATION,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetViewList extends RestCall<List<View>> {
protected GetViewList() {
public GetViewList() {
super(new TypeKey<>(
CallType.GET_LIST,
EntityType.VIEW,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewExamConfig extends RestCall<ConfigurationNode> {
protected NewExamConfig() {
public NewExamConfig() {
super(new TypeKey<>(
CallType.NEW,
EntityType.CONFIGURATION_NODE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveExamConfig extends RestCall<ConfigurationNode> {
protected SaveExamConfig() {
public SaveExamConfig() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.CONFIGURATION_NODE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveExamConfigHistory extends RestCall<Configuration> {
protected SaveExamConfigHistory() {
public SaveExamConfigHistory() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveExamConfigTableValues extends RestCall<ConfigurationTableValues> {
protected SaveExamConfigTableValues() {
public SaveExamConfigTableValues() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.CONFIGURATION_VALUE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveExamConfigValue extends RestCall<ConfigurationValue> {
protected SaveExamConfigValue() {
public SaveExamConfigValue() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.CONFIGURATION_VALUE,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SebExamConfigUndo extends RestCall<Configuration> {
protected SebExamConfigUndo() {
public SebExamConfigUndo() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.CONFIGURATION,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ActivateUserAccount extends RestCall<EntityProcessingReport> {
protected ActivateUserAccount() {
public ActivateUserAccount() {
super(new TypeKey<>(
CallType.ACTIVATION_ACTIVATE,
EntityType.USER,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class ChangePassword extends RestCall<UserInfo> {
protected ChangePassword() {
public ChangePassword() {
super(new TypeKey<>(
CallType.UNDEFINED,
EntityType.USER,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class DeactivateUserAccount extends RestCall<EntityProcessingReport> {
protected DeactivateUserAccount() {
public DeactivateUserAccount() {
super(new TypeKey<>(
CallType.ACTIVATION_DEACTIVATE,
EntityType.USER,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetUserAccount extends RestCall<UserInfo> {
protected GetUserAccount() {
public GetUserAccount() {
super(new TypeKey<>(
CallType.GET_SINGLE,
EntityType.USER,

View file

@ -28,7 +28,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetUserAccountNames extends RestCall<List<EntityName>> {
protected GetUserAccountNames() {
public GetUserAccountNames() {
super(new TypeKey<>(
CallType.GET_NAMES,
EntityType.USER,

View file

@ -27,7 +27,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class GetUserAccountPage extends RestCall<Page<UserInfo>> {
protected GetUserAccountPage() {
public GetUserAccountPage() {
super(new TypeKey<>(
CallType.GET_PAGE,
EntityType.USER,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class NewUserAccount extends RestCall<UserInfo> {
protected NewUserAccount() {
public NewUserAccount() {
super(new TypeKey<>(
CallType.NEW,
EntityType.USER,

View file

@ -26,7 +26,7 @@ import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
@GuiProfile
public class SaveUserAccount extends RestCall<UserInfo> {
protected SaveUserAccount() {
public SaveUserAccount() {
super(new TypeKey<>(
CallType.SAVE,
EntityType.USER,

View file

@ -21,79 +21,31 @@ public final class ColumnDefinition<ROW extends Entity> {
final String columnName;
final LocTextKey displayName;
final LocTextKey tooltip;
final int widthPercent;
final Function<ROW, ?> valueSupplier;
final boolean sortable;
final TableFilterAttribute filterAttribute;
final boolean localized;
private LocTextKey tooltip;
private int widthProportion;
private boolean sortable;
private TableFilterAttribute filterAttribute;
private boolean localized;
public ColumnDefinition(final String columnName, final LocTextKey displayName) {
this(columnName, displayName, null, -1);
this(columnName, displayName, null);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final Function<ROW, ?> valueSupplier) {
this(columnName, displayName, null, -1, valueSupplier, null, false, false);
}
private ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final LocTextKey tooltip,
final int widthPercent) {
this(columnName, displayName, tooltip, widthPercent, null, null, false, false);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final int widthPercent) {
this(columnName, displayName, null, widthPercent, null, null, false, false);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final Function<ROW, ?> valueSupplier,
final boolean sortable) {
this(columnName, displayName, null, -1, valueSupplier, null, sortable, false);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final Function<ROW, ?> valueSupplier,
final boolean sortable,
final boolean localized) {
this(columnName, displayName, null, -1, valueSupplier, null, sortable, localized);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final Function<ROW, ?> valueSupplier,
final TableFilterAttribute tableFilterAttribute,
final boolean sortable) {
this(columnName, displayName, null, -1, valueSupplier, tableFilterAttribute, sortable, false);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final Function<ROW, ?> valueSupplier,
final TableFilterAttribute tableFilterAttribute,
final boolean sortable,
final boolean localized) {
this(columnName, displayName, null, -1, valueSupplier, tableFilterAttribute, sortable, localized);
}
public ColumnDefinition(
final String columnName,
final LocTextKey displayName,
final LocTextKey tooltip,
final int widthPercent,
final int widthProportion,
final Function<ROW, ?> valueSupplier,
final TableFilterAttribute filterAttribute,
final boolean sortable,
@ -102,13 +54,58 @@ public final class ColumnDefinition<ROW extends Entity> {
this.columnName = columnName;
this.displayName = displayName;
this.tooltip = tooltip;
this.widthPercent = widthPercent;
this.widthProportion = widthProportion;
this.valueSupplier = valueSupplier;
this.filterAttribute = filterAttribute;
this.sortable = sortable;
this.localized = localized;
}
public ColumnDefinition<ROW> withFilter(final TableFilterAttribute filterAttribute) {
this.filterAttribute = filterAttribute;
return this;
}
public ColumnDefinition<ROW> withTooltip(final LocTextKey tooltip) {
this.tooltip = tooltip;
return this;
}
public ColumnDefinition<ROW> localized() {
this.localized = true;
return this;
}
public ColumnDefinition<ROW> sortable() {
this.sortable = true;
return this;
}
public ColumnDefinition<ROW> widthProportion(final int widthProportion) {
this.widthProportion = widthProportion;
return this;
}
public LocTextKey getTooltip() {
return this.tooltip;
}
public int getWidthProportion() {
return this.widthProportion;
}
public boolean isSortable() {
return this.sortable;
}
public TableFilterAttribute getFilterAttribute() {
return this.filterAttribute;
}
public boolean isLocalized() {
return this.localized;
}
public static final class TableFilterAttribute {
public final CriteriaType type;

View file

@ -110,7 +110,7 @@ public class EntityTable<ROW extends Entity> {
this.filter =
columns
.stream()
.map(column -> column.filterAttribute)
.map(column -> column.getFilterAttribute())
.filter(Objects::nonNull)
.findFirst()
.isPresent() ? new TableFilter<>(this) : null;
@ -273,12 +273,12 @@ public class EntityTable<ROW extends Entity> {
final TableColumn tableColumn = this.widgetFactory.tableColumnLocalized(
this.table,
column.displayName,
column.tooltip);
column.getTooltip());
tableColumn.addListener(SWT.Resize, this::adaptColumnWidthChange);
tableColumn.setData(COLUMN_DEFINITION, column);
if (column.sortable) {
if (column.isSortable()) {
tableColumn.addListener(SWT.Selection, event -> {
if (!column.columnName.equals(this.sortColumn)) {
applySort(column.columnName);
@ -292,7 +292,7 @@ public class EntityTable<ROW extends Entity> {
});
}
if (column.widthPercent > 0) {
if (column.getWidthProportion() > 0) {
this.columnsWithSameWidth = false;
}
}
@ -355,14 +355,22 @@ public class EntityTable<ROW extends Entity> {
try {
final int currentTableWidth = this.table.getParent().getClientArea().width;
int index = 0;
final int pSize = this.columns
.stream()
.filter(c -> c.getWidthProportion() > 0)
.reduce(0,
(acc, c) -> acc + c.getWidthProportion(),
(acc1, acc2) -> acc1 + acc2);
final int columnSize = (pSize > 0)
? currentTableWidth / pSize
: currentTableWidth / this.columns.size();
for (final ColumnDefinition<ROW> column : this.columns) {
final int percentage = (this.columnsWithSameWidth)
? 100 / this.columns.size()
: column.widthPercent;
final TableColumn tableColumn = this.table.getColumn(index);
final int newWidth = currentTableWidth / 100 * percentage;
final int newWidth = (pSize > 0) ? columnSize * column.getWidthProportion() : columnSize;
tableColumn.setWidth(newWidth);
if (this.filter != null) {
this.filter.adaptColumnWidth(this.table.indexOf(tableColumn), newWidth);
@ -401,7 +409,7 @@ public class EntityTable<ROW extends Entity> {
final TableColumn[] columns = table.table.getColumns();
for (int i = 0; i < columns.length; i++) {
final ColumnDefinition<ROW> columnDefinition = table.columns.get(i);
if (columnDefinition.localized) {
if (columnDefinition.isLocalized()) {
for (int j = 0; j < items.length; j++) {
@SuppressWarnings("unchecked")
final ROW rowData = (ROW) items[j].getData(TABLE_ROW_DATA);

View file

@ -82,10 +82,10 @@ public class TableFilter<ROW extends Entity> {
this.components.clear();
this.components.addAll(this.entityTable.columns
.stream()
.map(column -> column.filterAttribute)
.map(ColumnDefinition::getFilterAttribute)
.map(this::createFilterComponent)
.map(comp -> comp.build(this.composite))
.map(comp -> comp.reset())
.map(FilterComponent::reset)
.collect(Collectors.toList()));
final FilterComponent lastComp = this.components.get(this.components.size() - 1);

View file

@ -20,12 +20,12 @@ import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestAttributes;
@ -55,41 +55,58 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.sebconfig.impl.SebConfigEnc
@WebServiceProfile
public class SebClientConfigServiceImpl implements SebClientConfigService {
private static final String WEB_SERVICE_SERVER_NAME_KEY = "sebserver.webservice.http.server.name";
private static final String WEB_SERVICE_HTTP_SCHEME_KEY = "sebserver.webservice.http.scheme";
private static final String WEB_SERVICE_SERVER_ADDRESS_KEY = "server.address";
private static final String WEB_SERVICE_SERVER_PORT_KEY = "server.port";
private static final String WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY =
"sebserver.webservice.api.exam.endpoint.discovery";
private static final Logger log = LoggerFactory.getLogger(SebClientConfigServiceImpl.class);
private final InstitutionDAO institutionDAO;
private final SebClientConfigDAO sebClientConfigDAO;
private final ClientCredentialService clientCredentialService;
private final SebConfigEncryptionService sebConfigEncryptionService;
@Autowired
@Qualifier(WebSecurityConfig.CLIENT_PASSWORD_ENCODER_BEAN_NAME)
private PasswordEncoder clientPasswordEncoder;
private final PasswordEncoder clientPasswordEncoder;
private final ZipService zipService;
private final String httpScheme;
private final String serverAddress;
private final String serverName;
private final String serverPort;
private final String discoveryEndpoint;
private final String serverURLPrefix;
protected SebClientConfigServiceImpl(
final InstitutionDAO institutionDAO,
final SebClientConfigDAO sebClientConfigDAO,
final ClientCredentialService clientCredentialService,
final SebConfigEncryptionService sebConfigEncryptionService,
final ZipService zipService,
@Value("${sebserver.webservice.http.scheme}") final String httpScheme,
@Value("${server.address}") final String serverAddress,
@Value("${server.port}") final String serverPort,
@Value("${sebserver.webservice.api.exam.endpoint.discovery}") final String discoveryEndpoint) {
@Qualifier(WebSecurityConfig.CLIENT_PASSWORD_ENCODER_BEAN_NAME) final PasswordEncoder clientPasswordEncoder,
final Environment environment) {
this.institutionDAO = institutionDAO;
this.sebClientConfigDAO = sebClientConfigDAO;
this.clientCredentialService = clientCredentialService;
this.sebConfigEncryptionService = sebConfigEncryptionService;
this.zipService = zipService;
this.httpScheme = httpScheme;
this.serverAddress = serverAddress;
this.serverPort = serverPort;
this.discoveryEndpoint = discoveryEndpoint;
this.clientPasswordEncoder = clientPasswordEncoder;
this.httpScheme = environment.getRequiredProperty(WEB_SERVICE_HTTP_SCHEME_KEY);
this.serverAddress = environment.getRequiredProperty(WEB_SERVICE_SERVER_ADDRESS_KEY);
this.serverName = environment.getProperty(WEB_SERVICE_SERVER_NAME_KEY, (String) null);
this.serverPort = environment.getRequiredProperty(WEB_SERVICE_SERVER_PORT_KEY);
this.discoveryEndpoint = environment.getRequiredProperty(WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY);
this.serverURLPrefix = UriComponentsBuilder.newInstance()
.scheme(this.httpScheme)
.host((StringUtils.isNoneBlank(this.serverName))
? this.serverName
: this.serverAddress)
.port(this.serverPort)
.toUriString();
}
@Override
@ -236,11 +253,7 @@ public class SebClientConfigServiceImpl implements SebClientConfigService {
@Override
public String getServerURL() {
return UriComponentsBuilder.newInstance()
.scheme(this.httpScheme)
.host(this.serverAddress)
.port(this.serverPort)
.toUriString();
return this.serverURLPrefix;
}
private void passwordEncryption(

View file

@ -43,37 +43,39 @@ public class ExamAPIDiscoveryController {
@PostConstruct
void init() {
final String serverURL = this.sebClientConfigService.getServerURL();
this.DISCOVERY_INFO = new ExamAPIDiscovery(
"Safe Exam Browser Server / Exam API Description",
"This is a description of Safe Exam Browser Server's Exam API",
this.sebClientConfigService.getServerURL(),
serverURL,
Arrays.asList(new ExamAPIDiscovery.ExamAPIVersion(
"v1",
Arrays.asList(
new ExamAPIDiscovery.Endpoint(
"access-token-endpoint",
"request OAuth2 access token with client credentials grant",
API.OAUTH_TOKEN_ENDPOINT,
serverURL + API.OAUTH_TOKEN_ENDPOINT,
"Basic"),
new ExamAPIDiscovery.Endpoint(
"seb-handshake-endpoint",
"endpoint to establish SEB - SEB Server connection",
this.examAPI_V1_Endpoint + API.EXAM_API_HANDSHAKE_ENDPOINT,
serverURL + this.examAPI_V1_Endpoint + API.EXAM_API_HANDSHAKE_ENDPOINT,
"Bearer"),
new ExamAPIDiscovery.Endpoint(
"seb-configuration-endpoint",
"endpoint to get SEB exam configuration in exchange of connection-token and exam identifier",
this.examAPI_V1_Endpoint + API.EXAM_API_CONFIGURATION_REQUEST_ENDPOINT,
serverURL + this.examAPI_V1_Endpoint
+ API.EXAM_API_CONFIGURATION_REQUEST_ENDPOINT,
"Bearer"),
new ExamAPIDiscovery.Endpoint(
"seb-ping-endpoint",
"endpoint to send pings to while running exam",
this.examAPI_V1_Endpoint + API.EXAM_API_PING_ENDPOINT,
serverURL + this.examAPI_V1_Endpoint + API.EXAM_API_PING_ENDPOINT,
"Bearer"),
new ExamAPIDiscovery.Endpoint(
"seb-ping-endpoint",
"endpoint to send log events to while running exam",
this.examAPI_V1_Endpoint + API.EXAM_API_EVENT_ENDPOINT,
serverURL + this.examAPI_V1_Endpoint + API.EXAM_API_EVENT_ENDPOINT,
"Bearer")))));
}

View file

@ -10,6 +10,7 @@ spring.datasource.platform=dev
spring.datasource.hikari.max-lifetime=600000
sebserver.webservice.http.scheme=http
sebserver.webservice.http.server.name=localhost
sebserver.webservice.api.admin.endpoint=/admin-api/v1
sebserver.webservice.api.admin.accessTokenValiditySeconds=1800
sebserver.webservice.api.admin.refreshTokenValiditySeconds=-1

View file

@ -6,7 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig;
package ch.ethz.seb.sebserver.gui.integration;
import static org.junit.Assert.*;
@ -18,8 +18,12 @@ import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
import ch.ethz.seb.sebserver.gbl.model.sebconfig.SebClientConfig;
import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gui.integration.GuiIntegrationTest;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.ActivateClientConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.DeactivateClientConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.GetClientConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.NewClientConfig;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.seb.clientconfig.SaveClientConfig;
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public class ClientConfigTest extends GuiIntegrationTest {

View file

@ -6,7 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution;
package ch.ethz.seb.sebserver.gui.integration;
import static org.junit.Assert.*;
@ -14,16 +14,18 @@ import java.util.ArrayList;
import java.util.Collection;
import org.junit.Test;
import org.springframework.test.context.jdbc.Sql;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gui.integration.GuiIntegrationTest;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestCall;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.GetInstitution;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.OAuth2AuthorizationContextHolder;
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public class GetInstitutionTest extends GuiIntegrationTest {
@Test

View file

@ -0,0 +1,77 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package ch.ethz.seb.sebserver.gui.integration;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.test.context.jdbc.Sql;
import ch.ethz.seb.sebserver.gbl.api.API;
import ch.ethz.seb.sebserver.gbl.model.Domain;
import ch.ethz.seb.sebserver.gbl.model.EntityProcessingReport;
import ch.ethz.seb.sebserver.gbl.model.institution.Institution;
import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.RestServiceImpl;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.ActivateInstitution;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.GetInstitution;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.api.institution.NewInstitution;
@Sql(scripts = { "classpath:schema-test.sql", "classpath:data-test.sql" })
public class UseCasesIntegrationTest extends GuiIntegrationTest {
@Test
public void bigUseCasesTest() {
// *************************************
// Use Case 1: SEB Administrator creates a new institution and activate this new institution
final RestServiceImpl restService = createRestServiceForUser(
"admin",
"admin",
new NewInstitution(),
new ActivateInstitution(),
new GetInstitution());
final Result<Institution> result = restService.getBuilder(NewInstitution.class)
.withQueryParam(Domain.INSTITUTION.ATTR_NAME, "Test Institution")
.call();
assertNotNull(result);
assertFalse(result.hasError());
Institution institution = result.get();
assertEquals("Test Institution", institution.name);
assertFalse(institution.active);
final Result<EntityProcessingReport> resultActivation = restService.getBuilder(ActivateInstitution.class)
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(institution.id))
.call();
assertNotNull(resultActivation);
assertFalse(resultActivation.hasError());
final Result<Institution> resultGet = restService.getBuilder(GetInstitution.class)
.withURIVariable(API.PARAM_MODEL_ID, String.valueOf(institution.id))
.call();
assertNotNull(resultGet);
assertFalse(resultGet.hasError());
institution = resultGet.get();
assertEquals("Test Institution", institution.name);
assertTrue(institution.active);
// *************************************
// Use Case 2: SEB Administrator creates a new Institutional Administrator user for the
// newly created institution and activate this user
// TODO do as much use cases as possible within this integration test
}
}

View file

@ -8,7 +8,7 @@
package ch.ethz.seb.sebserver.webservice.integration.api.exam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@ -16,6 +16,8 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import ch.ethz.seb.sebserver.gbl.api.ExamAPIDiscovery;
import ch.ethz.seb.sebserver.gbl.api.ExamAPIDiscovery.ExamAPIVersion;
import ch.ethz.seb.sebserver.gbl.api.JSONMapper;
public class ExamDiscoveryEndpointTest extends ExamAPIIntegrationTester {
@ -33,44 +35,14 @@ public class ExamDiscoveryEndpointTest extends ExamAPIIntegrationTester {
.andExpect(status().isOk())
.andReturn().getResponse().getContentAsString();
final Object json = this.jsonMapper.readValue(contentAsString, Object.class);
assertEquals(
"{\r\n" +
" \"title\" : \"Safe Exam Browser Server / Exam API Description\",\r\n" +
" \"description\" : \"This is a description of Safe Exam Browser Server's Exam API\",\r\n" +
" \"server-location\" : \"http://localhost:0\",\r\n" +
" \"api-versions\" : [ {\r\n" +
" \"name\" : \"v1\",\r\n" +
" \"endpoints\" : [ {\r\n" +
" \"name\" : \"access-token-endpoint\",\r\n" +
" \"descripiton\" : \"request OAuth2 access token with client credentials grant\",\r\n" +
" \"location\" : \"/oauth/token\",\r\n" +
" \"authorization\" : \"Basic\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-handshake-endpoint\",\r\n" +
" \"descripiton\" : \"endpoint to establish SEB - SEB Server connection\",\r\n" +
" \"location\" : \"/exam-api/v1/handshake\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-configuration-endpoint\",\r\n" +
" \"descripiton\" : \"endpoint to get SEB exam configuration in exchange of connection-token and exam identifier\",\r\n"
+
" \"location\" : \"/exam-api/v1/examconfig\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-ping-endpoint\",\r\n" +
" \"descripiton\" : \"endpoint to send pings to while running exam\",\r\n" +
" \"location\" : \"/exam-api/v1/sebping\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" }, {\r\n" +
" \"name\" : \"seb-ping-endpoint\",\r\n" +
" \"descripiton\" : \"endpoint to send log events to while running exam\",\r\n" +
" \"location\" : \"/exam-api/v1/seblog\",\r\n" +
" \"authorization\" : \"Bearer\"\r\n" +
" } ]\r\n" +
" } ]\r\n" +
"}",
this.jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(json));
final ExamAPIDiscovery examAPIDiscovery = this.jsonMapper.readValue(contentAsString, ExamAPIDiscovery.class);
assertNotNull(examAPIDiscovery);
assertEquals("Safe Exam Browser Server / Exam API Description", examAPIDiscovery.title);
assertEquals("This is a description of Safe Exam Browser Server's Exam API", examAPIDiscovery.description);
assertTrue(!examAPIDiscovery.versions.isEmpty());
final ExamAPIVersion version1 = examAPIDiscovery.versions.iterator().next();
assertEquals("v1", version1.name);
assertTrue(!version1.endpoints.isEmpty());
}
}