fixed instructions creation with attributes
This commit is contained in:
parent
f54b769388
commit
cea62d5fa4
4 changed files with 11 additions and 42 deletions
|
@ -324,7 +324,7 @@ public final class Result<T> {
|
|||
}
|
||||
}
|
||||
|
||||
public static Result<Void> tryCatch(final Runnable runnable) {
|
||||
public static Result<Void> tryCatch(final TryCatchRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
return Result.EMPTY;
|
||||
|
@ -389,4 +389,8 @@ public final class Result<T> {
|
|||
T get() throws Exception;
|
||||
}
|
||||
|
||||
public interface TryCatchRunnable {
|
||||
void run() throws Exception;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -587,35 +587,6 @@ public final class Utils {
|
|||
return (hexString.length() < 2) ? "0" + hexString : hexString;
|
||||
}
|
||||
|
||||
public static String toJsonObject(final Map<String, String> attributes) {
|
||||
if (attributes == null || attributes.isEmpty()) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
final StringBuilder builder = attributes
|
||||
.entrySet()
|
||||
.stream()
|
||||
.reduce(
|
||||
new StringBuilder(Constants.CURLY_BRACE_OPEN),
|
||||
(sb, entry) -> sb
|
||||
.append(Constants.DOUBLE_QUOTE)
|
||||
.append(entry.getKey())
|
||||
.append(Constants.DOUBLE_QUOTE)
|
||||
.append(Constants.COLON)
|
||||
.append(getJSONValue(entry.getValue()))
|
||||
.append(Constants.COMMA),
|
||||
StringBuilder::append)
|
||||
.append(Constants.CURLY_BRACE_CLOSE);
|
||||
|
||||
if (builder.length() > 0) {
|
||||
return builder
|
||||
.deleteCharAt(builder.length() - 1)
|
||||
.toString();
|
||||
} else {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getJSONValue(final String value) {
|
||||
if (Constants.TRUE_STRING.equalsIgnoreCase(value) || Constants.FALSE_STRING.equalsIgnoreCase(value)) {
|
||||
return value.toLowerCase();
|
||||
|
|
|
@ -262,7 +262,6 @@ public class MonitoringClientConnection implements TemplateComposer {
|
|||
|
||||
NOTIFICATION_LIST_NO_SELECTION_KEY)
|
||||
.noEventPropagation()
|
||||
|
||||
.publishIf(() -> currentUser.get().hasRole(UserRole.EXAM_SUPPORTER), false);
|
||||
|
||||
_notificationTableSupplier = () -> notificationTable;
|
||||
|
@ -396,15 +395,6 @@ public class MonitoringClientConnection implements TemplateComposer {
|
|||
.publish();
|
||||
}
|
||||
|
||||
// actionBuilder
|
||||
// .newAction(ActionDefinition.MONITOR_EXAM_CLIENT_CONNECTION_EXAM_ROOM_PROCTORING)
|
||||
// .withEntityKey(parentEntityKey)
|
||||
// .withExec(action -> this.monitoringProctoringService.openExamCollectionProctorScreen(
|
||||
// action,
|
||||
// connectionData))
|
||||
// .noEventPropagation()
|
||||
// .publish();
|
||||
|
||||
clientConnectionDetails.setStatusChangeListener(ccd -> {
|
||||
this.pageService.firePageEvent(
|
||||
new ActionActivationEvent(
|
||||
|
@ -426,6 +416,11 @@ public class MonitoringClientConnection implements TemplateComposer {
|
|||
final EntityKey entityKey = table.getSingleSelection();
|
||||
final EntityKey parentEntityKey = pageAction.getParentEntityKey();
|
||||
|
||||
if (entityKey == null) {
|
||||
pageAction.pageContext().publishInfo(NOTIFICATION_LIST_NO_SELECTION_KEY);
|
||||
return pageAction;
|
||||
}
|
||||
|
||||
this.pageService.getRestService()
|
||||
.getBuilder(ConfirmPendingClientNotification.class)
|
||||
.withURIVariable(API.PARAM_PARENT_MODEL_ID, parentEntityKey.modelId)
|
||||
|
|
|
@ -34,7 +34,6 @@ import ch.ethz.seb.sebserver.gbl.model.session.ClientInstruction.InstructionType
|
|||
import ch.ethz.seb.sebserver.gbl.profile.WebServiceProfile;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||
import ch.ethz.seb.sebserver.gbl.util.SizedArrayNonBlockingQueue;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
import ch.ethz.seb.sebserver.webservice.WebserviceInfo;
|
||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientInstructionRecord;
|
||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.ClientConnectionDAO;
|
||||
|
@ -143,7 +142,7 @@ public class SEBClientInstructionServiceImpl implements SEBClientInstructionServ
|
|||
|
||||
return Result.tryCatch(() -> {
|
||||
|
||||
final String attributesString = Utils.toJsonObject(attributes);
|
||||
final String attributesString = this.jsonMapper.writeValueAsString(attributes);
|
||||
final Set<String> activeConnections = this.clientConnectionDAO
|
||||
.filterForInstructionStatus(examId, connectionTokens)
|
||||
.getOrElse(Collections::emptySet);
|
||||
|
|
Loading…
Reference in a new issue