corefx - updated client interface to use non rest specific classes

This commit is contained in:
Blake J. Harnden 2018-11-26 10:42:02 -08:00
parent 1877d864dc
commit bd1edabb7c
26 changed files with 132 additions and 119 deletions

View file

@ -1,7 +1,7 @@
package com.core; package com.core;
import com.core.client.ICoreClient; import com.core.client.ICoreClient;
import com.core.client.rest.*; import com.core.client.rest.CoreRestClient;
import com.core.data.*; import com.core.data.*;
import com.core.graph.NetworkGraph; import com.core.graph.NetworkGraph;
import com.core.ui.*; import com.core.ui.*;
@ -100,30 +100,30 @@ public class Controller implements Initializable {
} }
private void initialJoin() throws IOException { private void initialJoin() throws IOException {
GetServices services = coreClient.getServices(); Map<String, List<String>> serviceGroups = coreClient.getServices();
logger.info("core services: {}", services); logger.info("core services: {}", serviceGroups);
nodeServicesDialog.setServices(services); nodeServicesDialog.setServices(serviceGroups);
logger.info("initial core session join"); logger.info("initial core session join");
GetSessions response = coreClient.getSessions(); List<SessionOverview> sessions = coreClient.getSessions();
logger.info("existing sessions: {}", response); logger.info("existing sessions: {}", sessions);
Integer sessionId; Integer sessionId;
if (response.getSessions().isEmpty()) { if (sessions.isEmpty()) {
logger.info("creating initial session"); logger.info("creating initial session");
CreatedSession createdSession = coreClient.createSession(); SessionOverview sessionOverview = coreClient.createSession();
sessionId = createdSession.getId(); sessionId = sessionOverview.getId();
Toast.info(String.format("Created Session %s", sessionId)); Toast.info(String.format("Created Session %s", sessionId));
} else { } else {
GetSessionsData getSessionsData = response.getSessions().get(0); SessionOverview sessionOverview = sessions.get(0);
sessionId = getSessionsData.getId(); sessionId = sessionOverview.getId();
Toast.info(String.format("Joined Session %s", sessionId)); Toast.info(String.format("Joined Session %s", sessionId));
} }
joinSession(sessionId); joinSession(sessionId);
// set emane models // set emane models
List<String> emaneModels = coreClient.getEmaneModels().getModels(); List<String> emaneModels = coreClient.getEmaneModels();
nodeEmaneDialog.setModels(emaneModels); nodeEmaneDialog.setModels(emaneModels);
} }
@ -132,7 +132,7 @@ public class Controller implements Initializable {
networkGraph.reset(); networkGraph.reset();
// get session to join // get session to join
GetSession session = coreClient.getSession(joinId); Session session = coreClient.getSession(joinId);
SessionState sessionState = SessionState.get(session.getState()); SessionState sessionState = SessionState.get(session.getState());
// update client to use this session // update client to use this session
@ -170,11 +170,11 @@ public class Controller implements Initializable {
hooksDialog.updateHooks(); hooksDialog.updateHooks();
// display first mobility script in player // display first mobility script in player
GetMobilityConfigs getMobilityConfigs = coreClient.getMobilityConfigs(); Map<Integer, MobilityConfig> mobilityConfigMap = coreClient.getMobilityConfigs();
Optional<Integer> nodeIdOptional = getMobilityConfigs.getConfigurations().keySet().stream().findFirst(); Optional<Integer> nodeIdOptional = mobilityConfigMap.keySet().stream().findFirst();
if (nodeIdOptional.isPresent()) { if (nodeIdOptional.isPresent()) {
Integer nodeId = nodeIdOptional.get(); Integer nodeId = nodeIdOptional.get();
MobilityConfig mobilityConfig = getMobilityConfigs.getConfigurations().get(nodeId); MobilityConfig mobilityConfig = mobilityConfigMap.get(nodeId);
CoreNode node = networkGraph.getVertex(nodeId); CoreNode node = networkGraph.getVertex(nodeId);
mobilityPlayer.show(node, mobilityConfig); mobilityPlayer.show(node, mobilityConfig);
Platform.runLater(() -> bottom.getChildren().add(mobilityPlayer)); Platform.runLater(() -> bottom.getChildren().add(mobilityPlayer));
@ -305,8 +305,8 @@ public class Controller implements Initializable {
if (file != null) { if (file != null) {
logger.info("opening session xml: {}", file.getPath()); logger.info("opening session xml: {}", file.getPath());
try { try {
CreatedSession createdSession = coreClient.openSession(file); SessionOverview sessionOverview = coreClient.openSession(file);
Integer sessionId = createdSession.getId(); Integer sessionId = sessionOverview.getId();
joinSession(sessionId); joinSession(sessionId);
Toast.info(String.format("Joined Session %s", sessionId)); Toast.info(String.format("Joined Session %s", sessionId));
} catch (IOException ex) { } catch (IOException ex) {
@ -352,12 +352,11 @@ public class Controller implements Initializable {
@FXML @FXML
private void onSessionOptionsMenu(ActionEvent event) { private void onSessionOptionsMenu(ActionEvent event) {
try { try {
GetConfig config = coreClient.getSessionConfig(); List<ConfigGroup> configGroups = coreClient.getSessionConfig();
configDialog.showDialog("Session Options", config, () -> { configDialog.showDialog("Session Options", configGroups, () -> {
List<ConfigOption> options = configDialog.getOptions(); List<ConfigOption> options = configDialog.getOptions();
SetConfig setConfig = new SetConfig(options);
try { try {
boolean result = coreClient.setSessionConfig(setConfig); boolean result = coreClient.setSessionConfig(options);
if (result) { if (result) {
Toast.info("Session options saved"); Toast.info("Session options saved");
} else { } else {

View file

@ -1,12 +1,14 @@
package com.core.client; package com.core.client;
import com.core.client.rest.*; import com.core.client.rest.ServiceFile;
import com.core.client.rest.WlanConfig;
import com.core.data.*; import com.core.data.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map;
public interface ICoreClient { public interface ICoreClient {
void setUrl(String url); void setUrl(String url);
@ -15,11 +17,11 @@ public interface ICoreClient {
void updateState(SessionState state); void updateState(SessionState state);
CreatedSession createSession() throws IOException; SessionOverview createSession() throws IOException;
GetSessions getSessions() throws IOException; List<SessionOverview> getSessions() throws IOException;
GetSession getSession(Integer sessionId) throws IOException; Session getSession(Integer sessionId) throws IOException;
boolean start(Collection<CoreNode> nodes, Collection<CoreLink> links, List<Hook> hooks) throws IOException; boolean start(Collection<CoreNode> nodes, Collection<CoreLink> links, List<Hook> hooks) throws IOException;
@ -27,7 +29,7 @@ public interface ICoreClient {
boolean setState(SessionState state) throws IOException; boolean setState(SessionState state) throws IOException;
GetServices getServices() throws IOException; Map<String, List<String>> getServices() throws IOException;
CoreService getService(CoreNode node, String serviceName) throws IOException; CoreService getService(CoreNode node, String serviceName) throws IOException;
@ -37,13 +39,13 @@ public interface ICoreClient {
boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException; boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException;
GetConfig getEmaneConfig(CoreNode node) throws IOException; List<ConfigGroup> getEmaneConfig(CoreNode node) throws IOException;
GetEmaneModels getEmaneModels() throws IOException; List<String> getEmaneModels() throws IOException;
boolean setEmaneConfig(CoreNode node, List<ConfigOption> options) throws IOException; boolean setEmaneConfig(CoreNode node, List<ConfigOption> options) throws IOException;
GetConfig getEmaneModelConfig(Integer id, String model) throws IOException; List<ConfigGroup> getEmaneModelConfig(Integer id, String model) throws IOException;
boolean setEmaneModelConfig(Integer id, String model, List<ConfigOption> options) throws IOException; boolean setEmaneModelConfig(Integer id, String model, List<ConfigOption> options) throws IOException;
@ -51,11 +53,11 @@ public interface ICoreClient {
void saveSession(File file) throws IOException; void saveSession(File file) throws IOException;
CreatedSession openSession(File file) throws IOException; SessionOverview openSession(File file) throws IOException;
GetConfig getSessionConfig() throws IOException; List<ConfigGroup> getSessionConfig() throws IOException;
boolean setSessionConfig(SetConfig config) throws IOException; boolean setSessionConfig(List<ConfigOption> configOptions) throws IOException;
boolean createNode(CoreNode node) throws IOException; boolean createNode(CoreNode node) throws IOException;
@ -69,7 +71,7 @@ public interface ICoreClient {
boolean createHook(Hook hook) throws IOException; boolean createHook(Hook hook) throws IOException;
GetHooks getHooks() throws IOException; List<Hook> getHooks() throws IOException;
WlanConfig getWlanConfig(CoreNode node) throws IOException; WlanConfig getWlanConfig(CoreNode node) throws IOException;
@ -77,7 +79,7 @@ public interface ICoreClient {
String getTerminalCommand(CoreNode node) throws IOException; String getTerminalCommand(CoreNode node) throws IOException;
GetMobilityConfigs getMobilityConfigs() throws IOException; Map<Integer, MobilityConfig> getMobilityConfigs() throws IOException;
boolean setMobilityConfig(CoreNode node, MobilityConfig config) throws IOException; boolean setMobilityConfig(CoreNode node, MobilityConfig config) throws IOException;

View file

@ -41,27 +41,29 @@ public class CoreRestClient implements ICoreClient {
} }
@Override @Override
public CreatedSession createSession() throws IOException { public SessionOverview createSession() throws IOException {
String url = getUrl("sessions"); String url = getUrl("sessions");
return WebUtils.post(url, CreatedSession.class); return WebUtils.post(url, SessionOverview.class);
} }
public GetServices getServices() throws IOException { public Map<String, List<String>> getServices() throws IOException {
String url = getUrl("services"); String url = getUrl("services");
return WebUtils.getJson(url, GetServices.class); GetServices getServices = WebUtils.getJson(url, GetServices.class);
return getServices.getGroups();
} }
@Override @Override
public GetSession getSession(Integer sessionId) throws IOException { public Session getSession(Integer sessionId) throws IOException {
String path = String.format("sessions/%s", sessionId); String path = String.format("sessions/%s", sessionId);
String url = getUrl(path); String url = getUrl(path);
return WebUtils.getJson(url, GetSession.class); return WebUtils.getJson(url, Session.class);
} }
@Override @Override
public GetSessions getSessions() throws IOException { public List<SessionOverview> getSessions() throws IOException {
String url = getUrl("sessions"); String url = getUrl("sessions");
return WebUtils.getJson(url, GetSessions.class); GetSessions getSessions = WebUtils.getJson(url, GetSessions.class);
return getSessions.getSessions();
} }
@Override @Override
@ -155,26 +157,29 @@ public class CoreRestClient implements ICoreClient {
} }
@Override @Override
public GetEmaneModels getEmaneModels() throws IOException { public List<String> getEmaneModels() throws IOException {
String url = getUrl(String.format("sessions/%s/emane/models", sessionId)); String url = getUrl(String.format("sessions/%s/emane/models", sessionId));
return WebUtils.getJson(url, GetEmaneModels.class); GetEmaneModels getEmaneModels = WebUtils.getJson(url, GetEmaneModels.class);
return getEmaneModels.getModels();
} }
@Override @Override
public GetConfig getEmaneModelConfig(Integer id, String model) throws IOException { public List<ConfigGroup> getEmaneModelConfig(Integer id, String model) throws IOException {
String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId)); String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId));
Map<String, String> args = new HashMap<>(); Map<String, String> args = new HashMap<>();
args.put("node", id.toString()); args.put("node", id.toString());
args.put("name", model); args.put("name", model);
return WebUtils.getJson(url, GetConfig.class, args); GetConfig getConfig = WebUtils.getJson(url, GetConfig.class, args);
return getConfig.getGroups();
} }
@Override @Override
public GetConfig getEmaneConfig(CoreNode node) throws IOException { public List<ConfigGroup> getEmaneConfig(CoreNode node) throws IOException {
String url = getUrl(String.format("sessions/%s/emane/config", sessionId)); String url = getUrl(String.format("sessions/%s/emane/config", sessionId));
Map<String, String> args = new HashMap<>(); Map<String, String> args = new HashMap<>();
args.put("node", node.getId().toString()); args.put("node", node.getId().toString());
return WebUtils.getJson(url, GetConfig.class, args); GetConfig getConfig = WebUtils.getJson(url, GetConfig.class, args);
return getConfig.getGroups();
} }
@Override @Override
@ -209,21 +214,23 @@ public class CoreRestClient implements ICoreClient {
} }
@Override @Override
public CreatedSession openSession(File file) throws IOException { public SessionOverview openSession(File file) throws IOException {
String url = getUrl("sessions/xml"); String url = getUrl("sessions/xml");
return WebUtils.postFile(url, file, CreatedSession.class); return WebUtils.postFile(url, file, SessionOverview.class);
} }
@Override @Override
public GetConfig getSessionConfig() throws IOException { public List<ConfigGroup> getSessionConfig() throws IOException {
String url = getUrl(String.format("sessions/%s/options", sessionId)); String url = getUrl(String.format("sessions/%s/options", sessionId));
return WebUtils.getJson(url, GetConfig.class); GetConfig getConfig = WebUtils.getJson(url, GetConfig.class);
return getConfig.getGroups();
} }
@Override @Override
public boolean setSessionConfig(SetConfig config) throws IOException { public boolean setSessionConfig(List<ConfigOption> configOptions) throws IOException {
String url = getUrl(String.format("sessions/%s/options", sessionId)); String url = getUrl(String.format("sessions/%s/options", sessionId));
return WebUtils.putJson(url, config); SetConfig setConfig = new SetConfig(configOptions);
return WebUtils.putJson(url, setConfig);
} }
@Override @Override
@ -275,9 +282,10 @@ public class CoreRestClient implements ICoreClient {
} }
@Override @Override
public GetHooks getHooks() throws IOException { public List<Hook> getHooks() throws IOException {
String url = getUrl(String.format("sessions/%s/hooks", sessionId)); String url = getUrl(String.format("sessions/%s/hooks", sessionId));
return WebUtils.getJson(url, GetHooks.class); GetHooks getHooks = WebUtils.getJson(url, GetHooks.class);
return getHooks.getHooks();
} }
@Override @Override
@ -311,9 +319,10 @@ public class CoreRestClient implements ICoreClient {
} }
@Override @Override
public GetMobilityConfigs getMobilityConfigs() throws IOException { public Map<Integer, MobilityConfig> getMobilityConfigs() throws IOException {
String url = getUrl(String.format("sessions/%s/mobility/configs", sessionId)); String url = getUrl(String.format("sessions/%s/mobility/configs", sessionId));
return WebUtils.getJson(url, GetMobilityConfigs.class); GetMobilityConfigs getMobilityConfigs = WebUtils.getJson(url, GetMobilityConfigs.class);
return getMobilityConfigs.getConfigurations();
} }
@Override @Override

View file

@ -1,10 +0,0 @@
package com.core.client.rest;
import lombok.Data;
@Data
public class CreatedSession {
private Integer id;
private Integer state;
private String url;
}

View file

@ -1,5 +1,6 @@
package com.core.client.rest; package com.core.client.rest;
import com.core.data.ConfigGroup;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,5 +1,6 @@
package com.core.client.rest; package com.core.client.rest;
import com.core.data.SessionOverview;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -9,5 +10,5 @@ import java.util.List;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public class GetSessions { public class GetSessions {
private List<GetSessionsData> sessions = new ArrayList<>(); private List<SessionOverview> sessions = new ArrayList<>();
} }

View file

@ -1,5 +1,6 @@
package com.core.client.rest; package com.core.client.rest;
import com.core.data.ConfigOption;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;

View file

@ -1,5 +1,6 @@
package com.core.client.rest; package com.core.client.rest;
import com.core.data.ConfigOption;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,5 +1,6 @@
package com.core.client.rest; package com.core.client.rest;
import com.core.data.ConfigOption;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package com.core.client.rest; package com.core.data;
import lombok.Data; import lombok.Data;

View file

@ -1,4 +1,4 @@
package com.core.client.rest; package com.core.data;
import lombok.Data; import lombok.Data;

View file

@ -1,7 +1,5 @@
package com.core.client.rest; package com.core.data;
import com.core.data.CoreNode;
import com.core.data.CoreLink;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -10,7 +8,7 @@ import java.util.List;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public class GetSession { public class Session {
private Integer state; private Integer state;
private List<CoreNode> nodes = new ArrayList<>(); private List<CoreNode> nodes = new ArrayList<>();
private List<CoreLink> links = new ArrayList<>(); private List<CoreLink> links = new ArrayList<>();

View file

@ -0,0 +1,13 @@
package com.core.data;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class SessionOverview {
private Integer id;
private Integer state;
private Integer nodes = 0;
private String url;
}

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.stage.Stage; import javafx.stage.Stage;
import lombok.Data; import lombok.Data;

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXToggleButton; import com.jfoenix.controls.JFXToggleButton;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import com.core.data.ConfigDataType; import com.core.data.ConfigDataType;
import javafx.stage.Stage; import javafx.stage.Stage;

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXTextField;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField; import com.jfoenix.controls.JFXTextField;
import javafx.scene.Node; import javafx.scene.Node;

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.Label; import javafx.scene.control.Label;

View file

@ -1,6 +1,6 @@
package com.core.ui.config; package com.core.ui.config;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import com.jfoenix.controls.JFXComboBox; import com.jfoenix.controls.JFXComboBox;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.stage.Stage; import javafx.stage.Stage;

View file

@ -1,9 +1,8 @@
package com.core.ui.dialogs; package com.core.ui.dialogs;
import com.core.Controller; import com.core.Controller;
import com.core.client.rest.ConfigGroup; import com.core.data.ConfigGroup;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigOption;
import com.core.client.rest.GetConfig;
import com.core.ui.config.ConfigItemUtils; import com.core.ui.config.ConfigItemUtils;
import com.core.ui.config.IConfigItem; import com.core.ui.config.IConfigItem;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
@ -38,12 +37,12 @@ public class ConfigDialog extends StageDialog {
return configItems.stream().map(IConfigItem::getOption).collect(Collectors.toList()); return configItems.stream().map(IConfigItem::getOption).collect(Collectors.toList());
} }
public void showDialog(String title, GetConfig getConfig, Runnable runnable) { public void showDialog(String title, List<ConfigGroup> configGroups, Runnable runnable) {
setTitle(title); setTitle(title);
configItems.clear(); configItems.clear();
tabPane.getTabs().clear(); tabPane.getTabs().clear();
for (ConfigGroup group : getConfig.getGroups()) { for (ConfigGroup group : configGroups) {
String groupName = group.getName(); String groupName = group.getName();
Tab tab = new Tab(groupName); Tab tab = new Tab(groupName);
ScrollPane scrollPane = new ScrollPane(); ScrollPane scrollPane = new ScrollPane();

View file

@ -1,7 +1,6 @@
package com.core.ui.dialogs; package com.core.ui.dialogs;
import com.core.Controller; import com.core.Controller;
import com.core.client.rest.GetHooks;
import com.core.data.Hook; import com.core.data.Hook;
import com.core.data.SessionState; import com.core.data.SessionState;
import com.core.ui.Toast; import com.core.ui.Toast;
@ -98,8 +97,8 @@ public class HooksDialog extends StageDialog {
// update hooks // update hooks
try { try {
GetHooks getHooks = getCoreClient().getHooks(); List<Hook> hooks = getCoreClient().getHooks();
for (Hook hook : getHooks.getHooks()) { for (Hook hook : hooks) {
SessionState state = SessionState.get(hook.getState()); SessionState state = SessionState.get(hook.getState());
hook.setStateDisplay(state.name()); hook.setStateDisplay(state.name());
hooksTable.getItems().add(hook); hooksTable.getItems().add(hook);

View file

@ -1,8 +1,8 @@
package com.core.ui.dialogs; package com.core.ui.dialogs;
import com.core.Controller; import com.core.Controller;
import com.core.client.rest.ConfigOption; import com.core.data.ConfigGroup;
import com.core.client.rest.GetConfig; import com.core.data.ConfigOption;
import com.core.data.CoreNode; import com.core.data.CoreNode;
import com.core.ui.Toast; import com.core.ui.Toast;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
@ -50,10 +50,10 @@ public class NodeEmaneDialog extends StageDialog {
private void emaneButtonHandler(ActionEvent event) { private void emaneButtonHandler(ActionEvent event) {
try { try {
GetConfig getConfig = getCoreClient().getEmaneConfig(coreNode); List<ConfigGroup> configGroups = getCoreClient().getEmaneConfig(coreNode);
logger.debug("emane model config: {}", getConfig); logger.debug("emane model config: {}", configGroups);
String title = String.format("%s EMANE Config", coreNode.getName()); String title = String.format("%s EMANE Config", coreNode.getName());
getController().getConfigDialog().showDialog(title, getConfig, () -> { getController().getConfigDialog().showDialog(title, configGroups, () -> {
List<ConfigOption> options = getController().getConfigDialog().getOptions(); List<ConfigOption> options = getController().getConfigDialog().getOptions();
try { try {
getCoreClient().setEmaneConfig(coreNode, options); getCoreClient().setEmaneConfig(coreNode, options);
@ -73,10 +73,10 @@ public class NodeEmaneDialog extends StageDialog {
public void displayEmaneModelConfig(Integer id, String model) { public void displayEmaneModelConfig(Integer id, String model) {
try { try {
GetConfig getConfig = getCoreClient().getEmaneModelConfig(id, model); List<ConfigGroup> configGroups = getCoreClient().getEmaneModelConfig(id, model);
logger.debug("emane model config: {}", getConfig); logger.debug("emane model config: {}", configGroups);
String title = String.format("EMANE(%s) %s Config", id, model); String title = String.format("EMANE(%s) %s Config", id, model);
getController().getConfigDialog().showDialog(title, getConfig, () -> { getController().getConfigDialog().showDialog(title, configGroups, () -> {
List<ConfigOption> options = getController().getConfigDialog().getOptions(); List<ConfigOption> options = getController().getConfigDialog().getOptions();
try { try {
getCoreClient().setEmaneModelConfig(id, model, options); getCoreClient().setEmaneModelConfig(id, model, options);

View file

@ -1,7 +1,6 @@
package com.core.ui.dialogs; package com.core.ui.dialogs;
import com.core.Controller; import com.core.Controller;
import com.core.client.rest.GetServices;
import com.core.data.CoreNode; import com.core.data.CoreNode;
import com.core.ui.ServiceItem; import com.core.ui.ServiceItem;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
@ -81,14 +80,14 @@ public class NodeServicesDialog extends StageDialog {
}); });
} }
public void setServices(GetServices getServices) { public void setServices(Map<String, List<String>> serviceGroups) {
serviceItemGroups.clear(); serviceItemGroups.clear();
getServices.getGroups().keySet().stream() serviceGroups.keySet().stream()
.sorted() .sorted()
.forEach(group -> { .forEach(group -> {
groupListView.getItems().add(group); groupListView.getItems().add(group);
getServices.getGroups().get(group).stream() serviceGroups.get(group).stream()
.sorted() .sorted()
.forEach(service -> { .forEach(service -> {
ServiceItem serviceItem = new ServiceItem(service); ServiceItem serviceItem = new ServiceItem(service);

View file

@ -1,8 +1,7 @@
package com.core.ui.dialogs; package com.core.ui.dialogs;
import com.core.Controller; import com.core.Controller;
import com.core.client.rest.GetSessions; import com.core.data.SessionOverview;
import com.core.client.rest.GetSessionsData;
import com.core.data.SessionState; import com.core.data.SessionState;
import com.core.ui.Toast; import com.core.ui.Toast;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
@ -15,6 +14,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class SessionsDialog extends StageDialog { public class SessionsDialog extends StageDialog {
@ -55,17 +55,17 @@ public class SessionsDialog extends StageDialog {
private String state; private String state;
private Integer nodes; private Integer nodes;
public SessionRow(GetSessionsData getSessionsData) { public SessionRow(SessionOverview sessionOverview) {
id = getSessionsData.getId(); id = sessionOverview.getId();
state = SessionState.get(getSessionsData.getState()).name(); state = SessionState.get(sessionOverview.getState()).name();
nodes = getSessionsData.getNodes(); nodes = sessionOverview.getNodes();
} }
} }
public void showDialog() throws IOException { public void showDialog() throws IOException {
sessionsTable.getItems().clear(); sessionsTable.getItems().clear();
GetSessions getSessions = getCoreClient().getSessions(); List<SessionOverview> sessions = getCoreClient().getSessions();
sessionsTable.getItems().addAll(getSessions.getSessions().stream() sessionsTable.getItems().addAll(sessions.stream()
.map(SessionRow::new) .map(SessionRow::new)
.collect(Collectors.toList())); .collect(Collectors.toList()));

View file

@ -1,8 +1,7 @@
package com.core.ui.dialogs; package com.core.ui.dialogs;
import com.core.Controller; import com.core.Controller;
import com.core.client.rest.GetSessions; import com.core.data.SessionOverview;
import com.core.client.rest.GetSessionsData;
import com.core.data.SessionState; import com.core.data.SessionState;
import com.core.ui.Toast; import com.core.ui.Toast;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
@ -15,6 +14,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class SessionsFoenixDialog extends CoreFoenixDialog { public class SessionsFoenixDialog extends CoreFoenixDialog {
@ -52,17 +52,17 @@ public class SessionsFoenixDialog extends CoreFoenixDialog {
private String state; private String state;
private Integer nodes; private Integer nodes;
public SessionRow(GetSessionsData getSessionsData) { public SessionRow(SessionOverview sessionOverview) {
id = getSessionsData.getId(); id = sessionOverview.getId();
state = SessionState.get(getSessionsData.getState()).name(); state = SessionState.get(sessionOverview.getState()).name();
nodes = getSessionsData.getNodes(); nodes = sessionOverview.getNodes();
} }
} }
public void showDialog() throws IOException { public void showDialog() throws IOException {
sessionsTable.getItems().clear(); sessionsTable.getItems().clear();
GetSessions getSessions = getCoreClient().getSessions(); List<SessionOverview> sessions = getCoreClient().getSessions();
sessionsTable.getItems().addAll(getSessions.getSessions().stream() sessionsTable.getItems().addAll(sessions.stream()
.map(SessionRow::new) .map(SessionRow::new)
.collect(Collectors.toList())); .collect(Collectors.toList()));
getDialog().show(getController().getStackPane()); getDialog().show(getController().getStackPane());