fixes and prepare for demo
This commit is contained in:
parent
b18febb75f
commit
9e34312ef3
7 changed files with 49 additions and 30 deletions
|
@ -11,4 +11,13 @@
|
||||||
<Match>
|
<Match>
|
||||||
<Package name="ch.ethz.seb.sebserver.webservice.datalayer.batis.model"/>
|
<Package name="ch.ethz.seb.sebserver.webservice.datalayer.batis.model"/>
|
||||||
</Match>
|
</Match>
|
||||||
|
<Match>
|
||||||
|
<Class name="ch.ethz.seb.sebserver.gbl.api.ExamAPIDiscovery" />
|
||||||
|
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
|
||||||
|
</Match>
|
||||||
|
<Match>
|
||||||
|
<Class name="ch.ethz.seb.sebserver.gui.widget.*" />
|
||||||
|
<Bug pattern="SE_BAD_FIELD" />
|
||||||
|
</Match>
|
||||||
|
|
||||||
</FindBugsFilter>
|
</FindBugsFilter>
|
|
@ -8,8 +8,6 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gbl.api;
|
package ch.ethz.seb.sebserver.gbl.api;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -48,22 +46,13 @@ public class POSTMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(final String name) {
|
public String getString(final String name) {
|
||||||
final String first = this.params.getFirst(name);
|
return Utils.decodeFormURL_UTF_8(this.params.getFirst(name));
|
||||||
if (StringUtils.isNotBlank(first)) {
|
|
||||||
try {
|
|
||||||
return URLDecoder.decode(first, "UTF-8");
|
|
||||||
} catch (final UnsupportedEncodingException e) {
|
|
||||||
log.warn("Failed to decode form URL formatted string value: ", e);
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return first;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getCharArray(final String name) {
|
public char[] getCharArray(final String name) {
|
||||||
final String value = getString(name);
|
final String value = getString(name);
|
||||||
if (value == null || value.length() <= 0) {
|
if (value == null || value.length() <= 0) {
|
||||||
return null;
|
return new char[] {};
|
||||||
}
|
}
|
||||||
|
|
||||||
return value.toCharArray();
|
return value.toCharArray();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gbl.util;
|
package ch.ethz.seb.sebserver.gbl.util;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
||||||
|
@ -27,8 +27,6 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
@ -37,8 +35,6 @@ import ch.ethz.seb.sebserver.gbl.Constants;
|
||||||
|
|
||||||
public final class Utils {
|
public final class Utils {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Utils.class);
|
|
||||||
|
|
||||||
/** This Collector can be used within stream collect to get one expected singleton element from
|
/** This Collector can be used within stream collect to get one expected singleton element from
|
||||||
* the given Stream.
|
* the given Stream.
|
||||||
* This first collects the given Stream to a list and then check if there is one expected element.
|
* This first collects the given Stream to a list and then check if there is one expected element.
|
||||||
|
@ -211,12 +207,23 @@ public final class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String encodeFormURL_UTF_8(final String value) {
|
public static final String encodeFormURL_UTF_8(final String value) {
|
||||||
try {
|
if (StringUtils.isBlank(value)) {
|
||||||
return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
|
|
||||||
} catch (final UnsupportedEncodingException e) {
|
|
||||||
log.error("Unexpected error while trying to encode to from URL UTF-8: ", e);
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return URLEncoder.encode(value, StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String decodeFormURL_UTF_8(final String value) {
|
||||||
|
if (StringUtils.isBlank(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return URLDecoder.decode(
|
||||||
|
(value.indexOf('+') >= 0)
|
||||||
|
? value.replaceAll("\\+", "%2b")
|
||||||
|
: value,
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearCharArray(final char[] array) {
|
public static void clearCharArray(final char[] array) {
|
||||||
|
|
|
@ -241,11 +241,12 @@ public abstract class RestCall<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestCallBuilder withFormParam(final String name, final String value) {
|
public RestCallBuilder withFormParam(final String name, final String value) {
|
||||||
|
final String encodedVal = Utils.encodeFormURL_UTF_8(value);
|
||||||
if (StringUtils.isBlank(this.body)) {
|
if (StringUtils.isBlank(this.body)) {
|
||||||
this.body = name + Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + value;
|
this.body = name + Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + encodedVal;
|
||||||
} else {
|
} else {
|
||||||
this.body = this.body + Constants.FORM_URL_ENCODED_SEPARATOR + name +
|
this.body = this.body + Constants.FORM_URL_ENCODED_SEPARATOR + name +
|
||||||
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + value;
|
Constants.FORM_URL_ENCODED_NAME_VALUE_SEPARATOR + encodedVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -353,9 +353,14 @@ public class EntityTable<ROW extends Entity> {
|
||||||
|
|
||||||
private void adaptColumnWidth(final Event event) {
|
private void adaptColumnWidth(final Event event) {
|
||||||
try {
|
try {
|
||||||
final int currentTableWidth = this.table.getParent().getClientArea().width;
|
int currentTableWidth = this.table.getParent().getClientArea().width;
|
||||||
int index = 0;
|
// If we have all columns with filter we need some more space for the
|
||||||
|
// filter actions in the right hand side. This tweak gives enough space for that
|
||||||
|
if (this.filter != null && this.columns.size() == this.filter.size()) {
|
||||||
|
currentTableWidth -= 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The proportion size, the sum of all given proportion values
|
||||||
final int pSize = this.columns
|
final int pSize = this.columns
|
||||||
.stream()
|
.stream()
|
||||||
.filter(c -> c.getWidthProportion() > 0)
|
.filter(c -> c.getWidthProportion() > 0)
|
||||||
|
@ -363,14 +368,18 @@ public class EntityTable<ROW extends Entity> {
|
||||||
(acc, c) -> acc + c.getWidthProportion(),
|
(acc, c) -> acc + c.getWidthProportion(),
|
||||||
(acc1, acc2) -> acc1 + acc2);
|
(acc1, acc2) -> acc1 + acc2);
|
||||||
|
|
||||||
final int columnSize = (pSize > 0)
|
// The unit size either with proportion or for a entire column if all columns are equal in size
|
||||||
|
final int columnUnitSize = (pSize > 0)
|
||||||
? currentTableWidth / pSize
|
? currentTableWidth / pSize
|
||||||
: currentTableWidth / this.columns.size();
|
: currentTableWidth / this.columns.size();
|
||||||
|
|
||||||
|
// Apply the column width for each column
|
||||||
|
int index = 0;
|
||||||
for (final ColumnDefinition<ROW> column : this.columns) {
|
for (final ColumnDefinition<ROW> column : this.columns) {
|
||||||
|
|
||||||
final TableColumn tableColumn = this.table.getColumn(index);
|
final TableColumn tableColumn = this.table.getColumn(index);
|
||||||
final int newWidth = (pSize > 0) ? columnSize * column.getWidthProportion() : columnSize;
|
final int newWidth = (pSize > 0)
|
||||||
|
? columnUnitSize * column.getWidthProportion()
|
||||||
|
: columnUnitSize;
|
||||||
tableColumn.setWidth(newWidth);
|
tableColumn.setWidth(newWidth);
|
||||||
if (this.filter != null) {
|
if (this.filter != null) {
|
||||||
this.filter.adaptColumnWidth(this.table.indexOf(tableColumn), newWidth);
|
this.filter.adaptColumnWidth(this.table.indexOf(tableColumn), newWidth);
|
||||||
|
|
|
@ -61,6 +61,10 @@ public class TableFilter<ROW extends Entity> {
|
||||||
buildComponents();
|
buildComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return this.components.size();
|
||||||
|
}
|
||||||
|
|
||||||
public MultiValueMap<String, String> getFilterParameter() {
|
public MultiValueMap<String, String> getFilterParameter() {
|
||||||
return this.components
|
return this.components
|
||||||
.stream()
|
.stream()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
INSERT IGNORE INTO institution VALUES
|
INSERT IGNORE INTO institution VALUES
|
||||||
(1, 'ETH Züich', 'ethz', null, null, 1),
|
(1, 'ETH Zürich', 'ethz', null, null, 1),
|
||||||
(2, 'Institution 2', 'inst2', null, null, 1),
|
(2, 'Institution 2', 'inst2', null, null, 1),
|
||||||
(3, 'Institution 3', 'inst3', null, null, 0),
|
(3, 'Institution 3', 'inst3', null, null, 0),
|
||||||
(4, 'Institution 4', 'inst4', null, null, 0),
|
(4, 'Institution 4', 'inst4', null, null, 0),
|
||||||
|
|
Loading…
Reference in a new issue