diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/api/POSTMapper.java b/src/main/java/ch/ethz/seb/sebserver/gbl/api/POSTMapper.java index 4e526a2a..2d5f41af 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/api/POSTMapper.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/api/POSTMapper.java @@ -78,6 +78,10 @@ public class POSTMapper { } } + public boolean contains(final String name) { + return this.params.containsKey(name); + } + private String decode(final String val) { try { return Utils.decodeFormURL_UTF_8(val); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java index adaf45e2..0f05d0aa 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/FilterMap.java @@ -60,6 +60,13 @@ public class FilterMap extends POSTMapper { super(params, uriQueryString); } + public boolean containsAny(final Set extFilter) { + return extFilter.stream() + .filter(this.params::containsKey) + .findFirst() + .isPresent(); + } + public Integer getActiveAsInt() { return getBooleanAsInteger(Entity.FILTER_ATTR_ACTIVE); } @@ -345,11 +352,4 @@ public class FilterMap extends POSTMapper { } } - public boolean containsAny(final Set extFilter) { - return extFilter.stream() - .filter(this.params::containsKey) - .findFirst() - .isPresent(); - } - } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java index 79153e0d..c53ea2f0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java @@ -33,6 +33,7 @@ import org.springframework.transaction.annotation.Transactional; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.EntityType; +import ch.ethz.seb.sebserver.gbl.model.Domain; import ch.ethz.seb.sebserver.gbl.model.exam.Exam; import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamStatus; import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType; @@ -216,10 +217,14 @@ public class ExamRecordDAO { or(ExamRecordDynamicSqlSupport.quizEndTime, isNull())); } + final String nameCriteria = filterMap.contains(QuizData.FILTER_ATTR_NAME) + ? filterMap.getSQLWildcard(QuizData.FILTER_ATTR_NAME) + : filterMap.getSQLWildcard(Domain.EXAM.ATTR_QUIZ_NAME); + final List records = whereClause .and( ExamRecordDynamicSqlSupport.quizName, - isLikeWhenPresent(filterMap.getSQLWildcard(QuizData.FILTER_ATTR_NAME))) + isLikeWhenPresent(nameCriteria)) .build() .execute(); diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index b3db2ad0..fd17a0ea 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -502,8 +502,8 @@ sebserver.exam.list.column.name=Name sebserver.exam.list.column.name.tooltip=The name of the exam

Use the filter above to narrow down to a specific exam name
{0} sebserver.exam.list.column.name.filter.tooltip=Use the filter to narrow down to a specific exam name sebserver.exam.list.column.starttime=Start Time {0} -sebserver.exam.list.column.starttime.tooltip=The start time of the exam

Use the filter above to set a specific from date
{0} -sebserver.exam.list.column.starttime.filter.tooltip=Use the filter to set a specific from date +sebserver.exam.list.column.starttime.tooltip=The start time of the exam

Use the filter above to filter by date..
Note that this is applied to the date range between start- and end-date and not to the start-date alone.

{0} +sebserver.exam.list.column.starttime.filter.tooltip=Use this to filter by date.
Note that this is applied to the date range between start- and end-date and not to the start-date alone.
Running and up-coming exams are still available as long as the filter date is not in the future. sebserver.exam.list.column.type=Type sebserver.exam.list.column.type.tooltip=The type of the exam

Use the filter above to set a specific exam type
{0} sebserver.exam.list.column.type.filter.tooltip=Use the filter to set a specific exam type