Merge remote-tracking branch 'origin/patch-1.0.2' into development
Conflicts: src/main/java/ch/ethz/seb/sebserver/gui/service/session/ClientConnectionDetails.java src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/AbstractClientIndicator.java
This commit is contained in:
commit
12fcaa405c
7 changed files with 69 additions and 32 deletions
|
@ -14,6 +14,13 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
||||||
|
|
||||||
public interface IndicatorValue extends IndicatorValueHolder {
|
public interface IndicatorValue extends IndicatorValueHolder {
|
||||||
|
|
||||||
|
public static final String ATTR_INDICATOR_ID = "indicatorId";
|
||||||
|
public static final String ATTR_INDICATOR_VALUE = "indicatorValue";
|
||||||
|
public static final String ATTR_INDICATOR_TYPE = "indicatorType";
|
||||||
|
|
||||||
|
@JsonProperty(SimpleIndicatorValue.ATTR_INDICATOR_ID)
|
||||||
|
Long getIndicatorId();
|
||||||
|
|
||||||
/** Use this to get the type of indicator this value was computed from.
|
/** Use this to get the type of indicator this value was computed from.
|
||||||
*
|
*
|
||||||
* @return the type of indicator this value was computed from. */
|
* @return the type of indicator this value was computed from. */
|
||||||
|
|
|
@ -15,9 +15,8 @@ import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
||||||
|
|
||||||
public final class SimpleIndicatorValue implements IndicatorValue {
|
public final class SimpleIndicatorValue implements IndicatorValue {
|
||||||
|
|
||||||
public static final String ATTR_INDICATOR_VALUE = "indicatorValue";
|
@JsonProperty(ATTR_INDICATOR_ID)
|
||||||
public static final String ATTR_INDICATOR_TYPE = "indicatorType";
|
public final Long indicatorId;
|
||||||
|
|
||||||
@JsonProperty(ATTR_INDICATOR_TYPE)
|
@JsonProperty(ATTR_INDICATOR_TYPE)
|
||||||
public final IndicatorType type;
|
public final IndicatorType type;
|
||||||
@JsonProperty(ATTR_INDICATOR_VALUE)
|
@JsonProperty(ATTR_INDICATOR_VALUE)
|
||||||
|
@ -25,13 +24,20 @@ public final class SimpleIndicatorValue implements IndicatorValue {
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public SimpleIndicatorValue(
|
public SimpleIndicatorValue(
|
||||||
|
@JsonProperty(ATTR_INDICATOR_ID) final Long indicatorId,
|
||||||
@JsonProperty(ATTR_INDICATOR_TYPE) final IndicatorType type,
|
@JsonProperty(ATTR_INDICATOR_TYPE) final IndicatorType type,
|
||||||
@JsonProperty(ATTR_INDICATOR_VALUE) final double value) {
|
@JsonProperty(ATTR_INDICATOR_VALUE) final double value) {
|
||||||
|
|
||||||
|
this.indicatorId = indicatorId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getIndicatorId() {
|
||||||
|
return this.indicatorId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndicatorType getType() {
|
public IndicatorType getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
|
@ -45,11 +51,14 @@ public final class SimpleIndicatorValue implements IndicatorValue {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append("IndicatorValue [type=");
|
builder.append("SimpleIndicatorValue [indicatorId=");
|
||||||
|
builder.append(this.indicatorId);
|
||||||
|
builder.append(", type=");
|
||||||
builder.append(this.type);
|
builder.append(this.type);
|
||||||
builder.append(", value=");
|
builder.append(", value=");
|
||||||
builder.append(this.value);
|
builder.append(this.value);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
package ch.ethz.seb.sebserver.gui.service.session;
|
package ch.ethz.seb.sebserver.gui.service.session;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumMap;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
@ -22,7 +22,6 @@ 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.exam.Exam;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.QuizData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue;
|
import ch.ethz.seb.sebserver.gbl.model.session.IndicatorValue;
|
||||||
|
@ -52,7 +51,7 @@ public class ClientConnectionDetails {
|
||||||
private static final int NUMBER_OF_NONE_INDICATOR_ROWS = 3;
|
private static final int NUMBER_OF_NONE_INDICATOR_ROWS = 3;
|
||||||
|
|
||||||
private final ResourceService resourceService;
|
private final ResourceService resourceService;
|
||||||
private final EnumMap<IndicatorType, IndicatorData> indicatorMapping;
|
private final Map<Long, IndicatorData> indicatorMapping;
|
||||||
private final RestCall<ClientConnectionData>.RestCallBuilder restCallBuilder;
|
private final RestCall<ClientConnectionData>.RestCallBuilder restCallBuilder;
|
||||||
private final FormHandle<?> formHandle;
|
private final FormHandle<?> formHandle;
|
||||||
private final ColorData colorData;
|
private final ColorData colorData;
|
||||||
|
@ -167,7 +166,7 @@ public class ClientConnectionDetails {
|
||||||
// update indicators
|
// update indicators
|
||||||
this.connectionData.getIndicatorValues()
|
this.connectionData.getIndicatorValues()
|
||||||
.forEach(indValue -> {
|
.forEach(indValue -> {
|
||||||
final IndicatorData indData = this.indicatorMapping.get(indValue.getType());
|
final IndicatorData indData = this.indicatorMapping.get(indValue.getIndicatorId());
|
||||||
final double value = indValue.getValue();
|
final double value = indValue.getValue();
|
||||||
final String displayValue = IndicatorValue.getDisplayValue(indValue);
|
final String displayValue = IndicatorValue.getDisplayValue(indValue);
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
@ -50,7 +50,6 @@ import ch.ethz.seb.sebserver.gbl.model.Domain;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
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.Exam;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection.ConnectionStatus;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnection.ConnectionStatus;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData;
|
import ch.ethz.seb.sebserver.gbl.model.session.ClientConnectionData;
|
||||||
|
@ -68,6 +67,8 @@ public final class ClientConnectionTable {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ClientConnectionTable.class);
|
private static final Logger log = LoggerFactory.getLogger(ClientConnectionTable.class);
|
||||||
|
|
||||||
|
private static final int[] TABLE_PROPORTIONS = new int[] { 3, 1, 2, 1 };
|
||||||
|
|
||||||
private static final int BOTTOM_PADDING = 20;
|
private static final int BOTTOM_PADDING = 20;
|
||||||
private static final int NUMBER_OF_NONE_INDICATOR_COLUMNS = 3;
|
private static final int NUMBER_OF_NONE_INDICATOR_COLUMNS = 3;
|
||||||
private static final String USER_SESSION_STATUS_FILTER_ATTRIBUTE = "USER_SESSION_STATUS_FILTER_ATTRIBUTE";
|
private static final String USER_SESSION_STATUS_FILTER_ATTRIBUTE = "USER_SESSION_STATUS_FILTER_ATTRIBUTE";
|
||||||
|
@ -91,7 +92,7 @@ public final class ClientConnectionTable {
|
||||||
private final ResourceService resourceService;
|
private final ResourceService resourceService;
|
||||||
private final Exam exam;
|
private final Exam exam;
|
||||||
private final RestCall<Collection<ClientConnectionData>>.RestCallBuilder restCallBuilder;
|
private final RestCall<Collection<ClientConnectionData>>.RestCallBuilder restCallBuilder;
|
||||||
private final EnumMap<IndicatorType, IndicatorData> indicatorMapping;
|
private final Map<Long, IndicatorData> indicatorMapping;
|
||||||
private final Table table;
|
private final Table table;
|
||||||
private final ColorData colorData;
|
private final ColorData colorData;
|
||||||
private final EnumSet<ConnectionStatus> statusFilter;
|
private final EnumSet<ConnectionStatus> statusFilter;
|
||||||
|
@ -355,9 +356,22 @@ public final class ClientConnectionTable {
|
||||||
private void adaptTableWidth() {
|
private void adaptTableWidth() {
|
||||||
final Rectangle area = this.table.getParent().getClientArea();
|
final Rectangle area = this.table.getParent().getClientArea();
|
||||||
if (this.tableWidth != area.width) {
|
if (this.tableWidth != area.width) {
|
||||||
final int columnWidth = area.width / this.table.getColumnCount() - 5;
|
|
||||||
for (final TableColumn column : this.table.getColumns()) {
|
// proportions size
|
||||||
column.setWidth(columnWidth);
|
final int pSize = TABLE_PROPORTIONS[0] +
|
||||||
|
TABLE_PROPORTIONS[1] +
|
||||||
|
TABLE_PROPORTIONS[2] +
|
||||||
|
TABLE_PROPORTIONS[3] * this.indicatorMapping.size();
|
||||||
|
final int columnUnitSize = (pSize > 0)
|
||||||
|
? area.width / pSize
|
||||||
|
: area.width / TABLE_PROPORTIONS.length - 1 + this.indicatorMapping.size();
|
||||||
|
|
||||||
|
final TableColumn[] columns = this.table.getColumns();
|
||||||
|
for (int i = 0; i < columns.length; i++) {
|
||||||
|
final int proportionFactor = (i < TABLE_PROPORTIONS.length)
|
||||||
|
? TABLE_PROPORTIONS[i]
|
||||||
|
: TABLE_PROPORTIONS[TABLE_PROPORTIONS.length - 1];
|
||||||
|
columns[i].setWidth(proportionFactor * columnUnitSize);
|
||||||
}
|
}
|
||||||
this.tableWidth = area.width;
|
this.tableWidth = area.width;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +542,7 @@ public final class ClientConnectionTable {
|
||||||
for (int i = 0; i < this.connectionData.indicatorValues.size(); i++) {
|
for (int i = 0; i < this.connectionData.indicatorValues.size(); i++) {
|
||||||
final IndicatorValue indicatorValue = this.connectionData.indicatorValues.get(i);
|
final IndicatorValue indicatorValue = this.connectionData.indicatorValues.get(i);
|
||||||
final IndicatorData indicatorData =
|
final IndicatorData indicatorData =
|
||||||
ClientConnectionTable.this.indicatorMapping.get(indicatorValue.getType());
|
ClientConnectionTable.this.indicatorMapping.get(indicatorValue.getIndicatorId());
|
||||||
if (indicatorData == null) {
|
if (indicatorData == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -632,7 +646,7 @@ public final class ClientConnectionTable {
|
||||||
for (int i = 0; i < connectionData.indicatorValues.size(); i++) {
|
for (int i = 0; i < connectionData.indicatorValues.size(); i++) {
|
||||||
final IndicatorValue indicatorValue = connectionData.indicatorValues.get(i);
|
final IndicatorValue indicatorValue = connectionData.indicatorValues.get(i);
|
||||||
final IndicatorData indicatorData =
|
final IndicatorData indicatorData =
|
||||||
ClientConnectionTable.this.indicatorMapping.get(indicatorValue.getType());
|
ClientConnectionTable.this.indicatorMapping.get(indicatorValue.getIndicatorId());
|
||||||
|
|
||||||
if (indicatorData != null) {
|
if (indicatorData != null) {
|
||||||
final double value = indicatorValue.getValue();
|
final double value = indicatorValue.getValue();
|
||||||
|
|
|
@ -8,17 +8,18 @@
|
||||||
|
|
||||||
package ch.ethz.seb.sebserver.gui.service.session;
|
package ch.ethz.seb.sebserver.gui.service.session;
|
||||||
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
|
||||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
|
||||||
import org.eclipse.swt.graphics.Color;
|
|
||||||
import org.eclipse.swt.widgets.Display;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.EnumMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.Threshold;
|
||||||
|
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||||
|
|
||||||
final class IndicatorData {
|
final class IndicatorData {
|
||||||
|
|
||||||
|
@ -52,16 +53,16 @@ final class IndicatorData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static EnumMap<IndicatorType, IndicatorData> createFormIndicators(
|
static Map<Long, IndicatorData> createFormIndicators(
|
||||||
final Collection<Indicator> indicators,
|
final Collection<Indicator> indicators,
|
||||||
final Display display,
|
final Display display,
|
||||||
final ColorData colorData,
|
final ColorData colorData,
|
||||||
final int tableIndexOffset) {
|
final int tableIndexOffset) {
|
||||||
|
|
||||||
final EnumMap<IndicatorType, IndicatorData> indicatorMapping = new EnumMap<>(IndicatorType.class);
|
final Map<Long, IndicatorData> indicatorMapping = new HashMap<>();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final Indicator indicator : indicators) {
|
for (final Indicator indicator : indicators) {
|
||||||
indicatorMapping.put(indicator.type, new IndicatorData(
|
indicatorMapping.put(indicator.id, new IndicatorData(
|
||||||
indicator,
|
indicator,
|
||||||
i,
|
i,
|
||||||
i + tableIndexOffset,
|
i + tableIndexOffset,
|
||||||
|
|
|
@ -16,6 +16,7 @@ import ch.ethz.seb.sebserver.webservice.servicelayer.session.ClientIndicator;
|
||||||
|
|
||||||
public abstract class AbstractClientIndicator implements ClientIndicator {
|
public abstract class AbstractClientIndicator implements ClientIndicator {
|
||||||
|
|
||||||
|
protected Long indicatorId;
|
||||||
protected Long examId;
|
protected Long examId;
|
||||||
protected Long connectionId;
|
protected Long connectionId;
|
||||||
protected boolean cachingEnabled;
|
protected boolean cachingEnabled;
|
||||||
|
@ -28,11 +29,17 @@ public abstract class AbstractClientIndicator implements ClientIndicator {
|
||||||
final Long connectionId,
|
final Long connectionId,
|
||||||
final boolean cachingEnabled) {
|
final boolean cachingEnabled) {
|
||||||
|
|
||||||
this.examId = (indicatorDefinition != null) ? indicatorDefinition.examId : null;
|
this.indicatorId = (indicatorDefinition != null) ? indicatorDefinition.id : -1;
|
||||||
|
this.examId = (indicatorDefinition != null) ? indicatorDefinition.examId : -1;
|
||||||
this.connectionId = connectionId;
|
this.connectionId = connectionId;
|
||||||
this.cachingEnabled = cachingEnabled;
|
this.cachingEnabled = cachingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getIndicatorId() {
|
||||||
|
return this.indicatorId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long examId() {
|
public Long examId() {
|
||||||
return this.examId;
|
return this.examId;
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class ModelObjectJSONGenerator {
|
||||||
System.out.println(writerWithDefaultPrettyPrinter.writeValueAsString(domainObject));
|
System.out.println(writerWithDefaultPrettyPrinter.writeValueAsString(domainObject));
|
||||||
|
|
||||||
domainObject =
|
domainObject =
|
||||||
new SimpleIndicatorValue(IndicatorType.LAST_PING, 1.0);
|
new SimpleIndicatorValue(1L, IndicatorType.LAST_PING, 1.0);
|
||||||
System.out.println(domainObject.getClass().getSimpleName() + ":");
|
System.out.println(domainObject.getClass().getSimpleName() + ":");
|
||||||
System.out.println(writerWithDefaultPrettyPrinter.writeValueAsString(domainObject));
|
System.out.println(writerWithDefaultPrettyPrinter.writeValueAsString(domainObject));
|
||||||
|
|
||||||
|
@ -250,9 +250,9 @@ public class ModelObjectJSONGenerator {
|
||||||
1L, 1L, 1L, ConnectionStatus.ACTIVE, UUID.randomUUID().toString(),
|
1L, 1L, 1L, ConnectionStatus.ACTIVE, UUID.randomUUID().toString(),
|
||||||
"user-account-1", "86.119.30.213", "0.0.0.0", System.currentTimeMillis(), null, null),
|
"user-account-1", "86.119.30.213", "0.0.0.0", System.currentTimeMillis(), null, null),
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
new SimpleIndicatorValue(IndicatorType.LAST_PING, 1.0),
|
new SimpleIndicatorValue(1L, IndicatorType.LAST_PING, 1.0),
|
||||||
new SimpleIndicatorValue(IndicatorType.ERROR_COUNT, 2.0),
|
new SimpleIndicatorValue(2L, IndicatorType.ERROR_COUNT, 2.0),
|
||||||
new SimpleIndicatorValue(IndicatorType.WARN_COUNT, 3.0)));
|
new SimpleIndicatorValue(3L, IndicatorType.WARN_COUNT, 3.0)));
|
||||||
System.out.println(domainObject.getClass().getSimpleName() + ":");
|
System.out.println(domainObject.getClass().getSimpleName() + ":");
|
||||||
System.out.println(writerWithDefaultPrettyPrinter.writeValueAsString(domainObject));
|
System.out.println(writerWithDefaultPrettyPrinter.writeValueAsString(domainObject));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue