From bd1edabb7cec68206d3447a5535e7edc150355ce Mon Sep 17 00:00:00 2001 From: "Blake J. Harnden" Date: Mon, 26 Nov 2018 10:42:02 -0800 Subject: [PATCH] corefx - updated client interface to use non rest specific classes --- corefx/src/main/java/com/core/Controller.java | 43 +++++++------- .../java/com/core/client/ICoreClient.java | 28 ++++----- .../com/core/client/rest/CoreRestClient.java | 57 +++++++++++-------- .../com/core/client/rest/CreatedSession.java | 10 ---- .../java/com/core/client/rest/GetConfig.java | 1 + .../com/core/client/rest/GetSessions.java | 3 +- .../java/com/core/client/rest/SetConfig.java | 1 + .../com/core/client/rest/SetEmaneConfig.java | 1 + .../core/client/rest/SetEmaneModelConfig.java | 1 + .../{client/rest => data}/ConfigGroup.java | 2 +- .../{client/rest => data}/ConfigOption.java | 2 +- .../GetSession.java => data/Session.java} | 6 +- .../java/com/core/data/SessionOverview.java | 13 +++++ .../com/core/ui/config/BaseConfigItem.java | 2 +- .../com/core/ui/config/BooleanConfigItem.java | 2 +- .../com/core/ui/config/ConfigItemUtils.java | 2 +- .../com/core/ui/config/DefaultConfigItem.java | 2 +- .../com/core/ui/config/FileConfigItem.java | 2 +- .../java/com/core/ui/config/IConfigItem.java | 2 +- .../com/core/ui/config/SelectConfigItem.java | 2 +- .../com/core/ui/dialogs/ConfigDialog.java | 9 ++- .../java/com/core/ui/dialogs/HooksDialog.java | 5 +- .../com/core/ui/dialogs/NodeEmaneDialog.java | 16 +++--- .../core/ui/dialogs/NodeServicesDialog.java | 7 +-- .../com/core/ui/dialogs/SessionsDialog.java | 16 +++--- .../core/ui/dialogs/SessionsFoenixDialog.java | 16 +++--- 26 files changed, 132 insertions(+), 119 deletions(-) delete mode 100644 corefx/src/main/java/com/core/client/rest/CreatedSession.java rename corefx/src/main/java/com/core/{client/rest => data}/ConfigGroup.java (86%) rename corefx/src/main/java/com/core/{client/rest => data}/ConfigOption.java (89%) rename corefx/src/main/java/com/core/{client/rest/GetSession.java => data/Session.java} (69%) create mode 100644 corefx/src/main/java/com/core/data/SessionOverview.java diff --git a/corefx/src/main/java/com/core/Controller.java b/corefx/src/main/java/com/core/Controller.java index a512cc4b..2ac2fc63 100644 --- a/corefx/src/main/java/com/core/Controller.java +++ b/corefx/src/main/java/com/core/Controller.java @@ -1,7 +1,7 @@ package com.core; import com.core.client.ICoreClient; -import com.core.client.rest.*; +import com.core.client.rest.CoreRestClient; import com.core.data.*; import com.core.graph.NetworkGraph; import com.core.ui.*; @@ -100,30 +100,30 @@ public class Controller implements Initializable { } private void initialJoin() throws IOException { - GetServices services = coreClient.getServices(); - logger.info("core services: {}", services); - nodeServicesDialog.setServices(services); + Map> serviceGroups = coreClient.getServices(); + logger.info("core services: {}", serviceGroups); + nodeServicesDialog.setServices(serviceGroups); logger.info("initial core session join"); - GetSessions response = coreClient.getSessions(); + List sessions = coreClient.getSessions(); - logger.info("existing sessions: {}", response); + logger.info("existing sessions: {}", sessions); Integer sessionId; - if (response.getSessions().isEmpty()) { + if (sessions.isEmpty()) { logger.info("creating initial session"); - CreatedSession createdSession = coreClient.createSession(); - sessionId = createdSession.getId(); + SessionOverview sessionOverview = coreClient.createSession(); + sessionId = sessionOverview.getId(); Toast.info(String.format("Created Session %s", sessionId)); } else { - GetSessionsData getSessionsData = response.getSessions().get(0); - sessionId = getSessionsData.getId(); + SessionOverview sessionOverview = sessions.get(0); + sessionId = sessionOverview.getId(); Toast.info(String.format("Joined Session %s", sessionId)); } joinSession(sessionId); // set emane models - List emaneModels = coreClient.getEmaneModels().getModels(); + List emaneModels = coreClient.getEmaneModels(); nodeEmaneDialog.setModels(emaneModels); } @@ -132,7 +132,7 @@ public class Controller implements Initializable { networkGraph.reset(); // get session to join - GetSession session = coreClient.getSession(joinId); + Session session = coreClient.getSession(joinId); SessionState sessionState = SessionState.get(session.getState()); // update client to use this session @@ -170,11 +170,11 @@ public class Controller implements Initializable { hooksDialog.updateHooks(); // display first mobility script in player - GetMobilityConfigs getMobilityConfigs = coreClient.getMobilityConfigs(); - Optional nodeIdOptional = getMobilityConfigs.getConfigurations().keySet().stream().findFirst(); + Map mobilityConfigMap = coreClient.getMobilityConfigs(); + Optional nodeIdOptional = mobilityConfigMap.keySet().stream().findFirst(); if (nodeIdOptional.isPresent()) { Integer nodeId = nodeIdOptional.get(); - MobilityConfig mobilityConfig = getMobilityConfigs.getConfigurations().get(nodeId); + MobilityConfig mobilityConfig = mobilityConfigMap.get(nodeId); CoreNode node = networkGraph.getVertex(nodeId); mobilityPlayer.show(node, mobilityConfig); Platform.runLater(() -> bottom.getChildren().add(mobilityPlayer)); @@ -305,8 +305,8 @@ public class Controller implements Initializable { if (file != null) { logger.info("opening session xml: {}", file.getPath()); try { - CreatedSession createdSession = coreClient.openSession(file); - Integer sessionId = createdSession.getId(); + SessionOverview sessionOverview = coreClient.openSession(file); + Integer sessionId = sessionOverview.getId(); joinSession(sessionId); Toast.info(String.format("Joined Session %s", sessionId)); } catch (IOException ex) { @@ -352,12 +352,11 @@ public class Controller implements Initializable { @FXML private void onSessionOptionsMenu(ActionEvent event) { try { - GetConfig config = coreClient.getSessionConfig(); - configDialog.showDialog("Session Options", config, () -> { + List configGroups = coreClient.getSessionConfig(); + configDialog.showDialog("Session Options", configGroups, () -> { List options = configDialog.getOptions(); - SetConfig setConfig = new SetConfig(options); try { - boolean result = coreClient.setSessionConfig(setConfig); + boolean result = coreClient.setSessionConfig(options); if (result) { Toast.info("Session options saved"); } else { diff --git a/corefx/src/main/java/com/core/client/ICoreClient.java b/corefx/src/main/java/com/core/client/ICoreClient.java index 87529f86..8f36d1da 100644 --- a/corefx/src/main/java/com/core/client/ICoreClient.java +++ b/corefx/src/main/java/com/core/client/ICoreClient.java @@ -1,12 +1,14 @@ 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 java.io.File; import java.io.IOException; import java.util.Collection; import java.util.List; +import java.util.Map; public interface ICoreClient { void setUrl(String url); @@ -15,11 +17,11 @@ public interface ICoreClient { void updateState(SessionState state); - CreatedSession createSession() throws IOException; + SessionOverview createSession() throws IOException; - GetSessions getSessions() throws IOException; + List getSessions() throws IOException; - GetSession getSession(Integer sessionId) throws IOException; + Session getSession(Integer sessionId) throws IOException; boolean start(Collection nodes, Collection links, List hooks) throws IOException; @@ -27,7 +29,7 @@ public interface ICoreClient { boolean setState(SessionState state) throws IOException; - GetServices getServices() throws IOException; + Map> getServices() 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; - GetConfig getEmaneConfig(CoreNode node) throws IOException; + List getEmaneConfig(CoreNode node) throws IOException; - GetEmaneModels getEmaneModels() throws IOException; + List getEmaneModels() throws IOException; boolean setEmaneConfig(CoreNode node, List options) throws IOException; - GetConfig getEmaneModelConfig(Integer id, String model) throws IOException; + List getEmaneModelConfig(Integer id, String model) throws IOException; boolean setEmaneModelConfig(Integer id, String model, List options) throws IOException; @@ -51,11 +53,11 @@ public interface ICoreClient { void saveSession(File file) throws IOException; - CreatedSession openSession(File file) throws IOException; + SessionOverview openSession(File file) throws IOException; - GetConfig getSessionConfig() throws IOException; + List getSessionConfig() throws IOException; - boolean setSessionConfig(SetConfig config) throws IOException; + boolean setSessionConfig(List configOptions) throws IOException; boolean createNode(CoreNode node) throws IOException; @@ -69,7 +71,7 @@ public interface ICoreClient { boolean createHook(Hook hook) throws IOException; - GetHooks getHooks() throws IOException; + List getHooks() throws IOException; WlanConfig getWlanConfig(CoreNode node) throws IOException; @@ -77,7 +79,7 @@ public interface ICoreClient { String getTerminalCommand(CoreNode node) throws IOException; - GetMobilityConfigs getMobilityConfigs() throws IOException; + Map getMobilityConfigs() throws IOException; boolean setMobilityConfig(CoreNode node, MobilityConfig config) throws IOException; diff --git a/corefx/src/main/java/com/core/client/rest/CoreRestClient.java b/corefx/src/main/java/com/core/client/rest/CoreRestClient.java index f29d2d36..6303bf99 100644 --- a/corefx/src/main/java/com/core/client/rest/CoreRestClient.java +++ b/corefx/src/main/java/com/core/client/rest/CoreRestClient.java @@ -41,27 +41,29 @@ public class CoreRestClient implements ICoreClient { } @Override - public CreatedSession createSession() throws IOException { + public SessionOverview createSession() throws IOException { String url = getUrl("sessions"); - return WebUtils.post(url, CreatedSession.class); + return WebUtils.post(url, SessionOverview.class); } - public GetServices getServices() throws IOException { + public Map> getServices() throws IOException { String url = getUrl("services"); - return WebUtils.getJson(url, GetServices.class); + GetServices getServices = WebUtils.getJson(url, GetServices.class); + return getServices.getGroups(); } @Override - public GetSession getSession(Integer sessionId) throws IOException { + public Session getSession(Integer sessionId) throws IOException { String path = String.format("sessions/%s", sessionId); String url = getUrl(path); - return WebUtils.getJson(url, GetSession.class); + return WebUtils.getJson(url, Session.class); } @Override - public GetSessions getSessions() throws IOException { + public List getSessions() throws IOException { String url = getUrl("sessions"); - return WebUtils.getJson(url, GetSessions.class); + GetSessions getSessions = WebUtils.getJson(url, GetSessions.class); + return getSessions.getSessions(); } @Override @@ -155,26 +157,29 @@ public class CoreRestClient implements ICoreClient { } @Override - public GetEmaneModels getEmaneModels() throws IOException { + public List getEmaneModels() throws IOException { 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 - public GetConfig getEmaneModelConfig(Integer id, String model) throws IOException { + public List getEmaneModelConfig(Integer id, String model) throws IOException { String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId)); Map args = new HashMap<>(); args.put("node", id.toString()); args.put("name", model); - return WebUtils.getJson(url, GetConfig.class, args); + GetConfig getConfig = WebUtils.getJson(url, GetConfig.class, args); + return getConfig.getGroups(); } @Override - public GetConfig getEmaneConfig(CoreNode node) throws IOException { + public List getEmaneConfig(CoreNode node) throws IOException { String url = getUrl(String.format("sessions/%s/emane/config", sessionId)); Map args = new HashMap<>(); 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 @@ -209,21 +214,23 @@ public class CoreRestClient implements ICoreClient { } @Override - public CreatedSession openSession(File file) throws IOException { + public SessionOverview openSession(File file) throws IOException { String url = getUrl("sessions/xml"); - return WebUtils.postFile(url, file, CreatedSession.class); + return WebUtils.postFile(url, file, SessionOverview.class); } @Override - public GetConfig getSessionConfig() throws IOException { + public List getSessionConfig() throws IOException { 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 - public boolean setSessionConfig(SetConfig config) throws IOException { + public boolean setSessionConfig(List configOptions) throws IOException { 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 @@ -275,9 +282,10 @@ public class CoreRestClient implements ICoreClient { } @Override - public GetHooks getHooks() throws IOException { + public List getHooks() throws IOException { 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 @@ -311,9 +319,10 @@ public class CoreRestClient implements ICoreClient { } @Override - public GetMobilityConfigs getMobilityConfigs() throws IOException { + public Map getMobilityConfigs() throws IOException { 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 diff --git a/corefx/src/main/java/com/core/client/rest/CreatedSession.java b/corefx/src/main/java/com/core/client/rest/CreatedSession.java deleted file mode 100644 index 6ffd5c64..00000000 --- a/corefx/src/main/java/com/core/client/rest/CreatedSession.java +++ /dev/null @@ -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; -} diff --git a/corefx/src/main/java/com/core/client/rest/GetConfig.java b/corefx/src/main/java/com/core/client/rest/GetConfig.java index bafd35b6..61a843b6 100644 --- a/corefx/src/main/java/com/core/client/rest/GetConfig.java +++ b/corefx/src/main/java/com/core/client/rest/GetConfig.java @@ -1,5 +1,6 @@ package com.core.client.rest; +import com.core.data.ConfigGroup; import lombok.Data; import java.util.ArrayList; diff --git a/corefx/src/main/java/com/core/client/rest/GetSessions.java b/corefx/src/main/java/com/core/client/rest/GetSessions.java index 56784460..674fc83a 100644 --- a/corefx/src/main/java/com/core/client/rest/GetSessions.java +++ b/corefx/src/main/java/com/core/client/rest/GetSessions.java @@ -1,5 +1,6 @@ package com.core.client.rest; +import com.core.data.SessionOverview; import lombok.Data; import lombok.NoArgsConstructor; @@ -9,5 +10,5 @@ import java.util.List; @Data @NoArgsConstructor public class GetSessions { - private List sessions = new ArrayList<>(); + private List sessions = new ArrayList<>(); } diff --git a/corefx/src/main/java/com/core/client/rest/SetConfig.java b/corefx/src/main/java/com/core/client/rest/SetConfig.java index f3e4bd05..0d3f11ea 100644 --- a/corefx/src/main/java/com/core/client/rest/SetConfig.java +++ b/corefx/src/main/java/com/core/client/rest/SetConfig.java @@ -1,5 +1,6 @@ package com.core.client.rest; +import com.core.data.ConfigOption; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/corefx/src/main/java/com/core/client/rest/SetEmaneConfig.java b/corefx/src/main/java/com/core/client/rest/SetEmaneConfig.java index c7f7f922..ee947c51 100644 --- a/corefx/src/main/java/com/core/client/rest/SetEmaneConfig.java +++ b/corefx/src/main/java/com/core/client/rest/SetEmaneConfig.java @@ -1,5 +1,6 @@ package com.core.client.rest; +import com.core.data.ConfigOption; import lombok.Data; import java.util.ArrayList; diff --git a/corefx/src/main/java/com/core/client/rest/SetEmaneModelConfig.java b/corefx/src/main/java/com/core/client/rest/SetEmaneModelConfig.java index 4f1d16b0..e5c37092 100644 --- a/corefx/src/main/java/com/core/client/rest/SetEmaneModelConfig.java +++ b/corefx/src/main/java/com/core/client/rest/SetEmaneModelConfig.java @@ -1,5 +1,6 @@ package com.core.client.rest; +import com.core.data.ConfigOption; import lombok.Data; import java.util.ArrayList; diff --git a/corefx/src/main/java/com/core/client/rest/ConfigGroup.java b/corefx/src/main/java/com/core/data/ConfigGroup.java similarity index 86% rename from corefx/src/main/java/com/core/client/rest/ConfigGroup.java rename to corefx/src/main/java/com/core/data/ConfigGroup.java index 4640cf45..9b45bdb7 100644 --- a/corefx/src/main/java/com/core/client/rest/ConfigGroup.java +++ b/corefx/src/main/java/com/core/data/ConfigGroup.java @@ -1,4 +1,4 @@ -package com.core.client.rest; +package com.core.data; import lombok.Data; diff --git a/corefx/src/main/java/com/core/client/rest/ConfigOption.java b/corefx/src/main/java/com/core/data/ConfigOption.java similarity index 89% rename from corefx/src/main/java/com/core/client/rest/ConfigOption.java rename to corefx/src/main/java/com/core/data/ConfigOption.java index 56a464c8..77af265e 100644 --- a/corefx/src/main/java/com/core/client/rest/ConfigOption.java +++ b/corefx/src/main/java/com/core/data/ConfigOption.java @@ -1,4 +1,4 @@ -package com.core.client.rest; +package com.core.data; import lombok.Data; diff --git a/corefx/src/main/java/com/core/client/rest/GetSession.java b/corefx/src/main/java/com/core/data/Session.java similarity index 69% rename from corefx/src/main/java/com/core/client/rest/GetSession.java rename to corefx/src/main/java/com/core/data/Session.java index ee835adc..374e379d 100644 --- a/corefx/src/main/java/com/core/client/rest/GetSession.java +++ b/corefx/src/main/java/com/core/data/Session.java @@ -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.NoArgsConstructor; @@ -10,7 +8,7 @@ import java.util.List; @Data @NoArgsConstructor -public class GetSession { +public class Session { private Integer state; private List nodes = new ArrayList<>(); private List links = new ArrayList<>(); diff --git a/corefx/src/main/java/com/core/data/SessionOverview.java b/corefx/src/main/java/com/core/data/SessionOverview.java new file mode 100644 index 00000000..47773338 --- /dev/null +++ b/corefx/src/main/java/com/core/data/SessionOverview.java @@ -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; +} diff --git a/corefx/src/main/java/com/core/ui/config/BaseConfigItem.java b/corefx/src/main/java/com/core/ui/config/BaseConfigItem.java index 90929c30..99ff43ed 100644 --- a/corefx/src/main/java/com/core/ui/config/BaseConfigItem.java +++ b/corefx/src/main/java/com/core/ui/config/BaseConfigItem.java @@ -1,6 +1,6 @@ package com.core.ui.config; -import com.core.client.rest.ConfigOption; +import com.core.data.ConfigOption; import javafx.scene.control.Label; import javafx.stage.Stage; import lombok.Data; diff --git a/corefx/src/main/java/com/core/ui/config/BooleanConfigItem.java b/corefx/src/main/java/com/core/ui/config/BooleanConfigItem.java index dcc6c196..482d9b50 100644 --- a/corefx/src/main/java/com/core/ui/config/BooleanConfigItem.java +++ b/corefx/src/main/java/com/core/ui/config/BooleanConfigItem.java @@ -1,6 +1,6 @@ package com.core.ui.config; -import com.core.client.rest.ConfigOption; +import com.core.data.ConfigOption; import com.jfoenix.controls.JFXToggleButton; import javafx.scene.Node; import javafx.stage.Stage; diff --git a/corefx/src/main/java/com/core/ui/config/ConfigItemUtils.java b/corefx/src/main/java/com/core/ui/config/ConfigItemUtils.java index dcba2a9c..37a5dd27 100644 --- a/corefx/src/main/java/com/core/ui/config/ConfigItemUtils.java +++ b/corefx/src/main/java/com/core/ui/config/ConfigItemUtils.java @@ -1,6 +1,6 @@ package com.core.ui.config; -import com.core.client.rest.ConfigOption; +import com.core.data.ConfigOption; import com.core.data.ConfigDataType; import javafx.stage.Stage; diff --git a/corefx/src/main/java/com/core/ui/config/DefaultConfigItem.java b/corefx/src/main/java/com/core/ui/config/DefaultConfigItem.java index 06f799d4..674041c8 100644 --- a/corefx/src/main/java/com/core/ui/config/DefaultConfigItem.java +++ b/corefx/src/main/java/com/core/ui/config/DefaultConfigItem.java @@ -1,6 +1,6 @@ package com.core.ui.config; -import com.core.client.rest.ConfigOption; +import com.core.data.ConfigOption; import com.jfoenix.controls.JFXTextField; import javafx.scene.Node; import javafx.stage.Stage; diff --git a/corefx/src/main/java/com/core/ui/config/FileConfigItem.java b/corefx/src/main/java/com/core/ui/config/FileConfigItem.java index aa733faa..9648c38c 100644 --- a/corefx/src/main/java/com/core/ui/config/FileConfigItem.java +++ b/corefx/src/main/java/com/core/ui/config/FileConfigItem.java @@ -1,6 +1,6 @@ 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.JFXTextField; import javafx.scene.Node; diff --git a/corefx/src/main/java/com/core/ui/config/IConfigItem.java b/corefx/src/main/java/com/core/ui/config/IConfigItem.java index f815a9d5..057693ae 100644 --- a/corefx/src/main/java/com/core/ui/config/IConfigItem.java +++ b/corefx/src/main/java/com/core/ui/config/IConfigItem.java @@ -1,6 +1,6 @@ package com.core.ui.config; -import com.core.client.rest.ConfigOption; +import com.core.data.ConfigOption; import javafx.scene.Node; import javafx.scene.control.Label; diff --git a/corefx/src/main/java/com/core/ui/config/SelectConfigItem.java b/corefx/src/main/java/com/core/ui/config/SelectConfigItem.java index af3915d3..f2dbea22 100644 --- a/corefx/src/main/java/com/core/ui/config/SelectConfigItem.java +++ b/corefx/src/main/java/com/core/ui/config/SelectConfigItem.java @@ -1,6 +1,6 @@ package com.core.ui.config; -import com.core.client.rest.ConfigOption; +import com.core.data.ConfigOption; import com.jfoenix.controls.JFXComboBox; import javafx.scene.Node; import javafx.stage.Stage; diff --git a/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java b/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java index 10f04b27..aadef236 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/ConfigDialog.java @@ -1,9 +1,8 @@ package com.core.ui.dialogs; import com.core.Controller; -import com.core.client.rest.ConfigGroup; -import com.core.client.rest.ConfigOption; -import com.core.client.rest.GetConfig; +import com.core.data.ConfigGroup; +import com.core.data.ConfigOption; import com.core.ui.config.ConfigItemUtils; import com.core.ui.config.IConfigItem; import com.jfoenix.controls.JFXButton; @@ -38,12 +37,12 @@ public class ConfigDialog extends StageDialog { return configItems.stream().map(IConfigItem::getOption).collect(Collectors.toList()); } - public void showDialog(String title, GetConfig getConfig, Runnable runnable) { + public void showDialog(String title, List configGroups, Runnable runnable) { setTitle(title); configItems.clear(); tabPane.getTabs().clear(); - for (ConfigGroup group : getConfig.getGroups()) { + for (ConfigGroup group : configGroups) { String groupName = group.getName(); Tab tab = new Tab(groupName); ScrollPane scrollPane = new ScrollPane(); diff --git a/corefx/src/main/java/com/core/ui/dialogs/HooksDialog.java b/corefx/src/main/java/com/core/ui/dialogs/HooksDialog.java index 2bcb9b85..a3bef3b2 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/HooksDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/HooksDialog.java @@ -1,7 +1,6 @@ package com.core.ui.dialogs; import com.core.Controller; -import com.core.client.rest.GetHooks; import com.core.data.Hook; import com.core.data.SessionState; import com.core.ui.Toast; @@ -98,8 +97,8 @@ public class HooksDialog extends StageDialog { // update hooks try { - GetHooks getHooks = getCoreClient().getHooks(); - for (Hook hook : getHooks.getHooks()) { + List hooks = getCoreClient().getHooks(); + for (Hook hook : hooks) { SessionState state = SessionState.get(hook.getState()); hook.setStateDisplay(state.name()); hooksTable.getItems().add(hook); diff --git a/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java b/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java index 17e44ad6..80a04ae5 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/NodeEmaneDialog.java @@ -1,8 +1,8 @@ package com.core.ui.dialogs; import com.core.Controller; -import com.core.client.rest.ConfigOption; -import com.core.client.rest.GetConfig; +import com.core.data.ConfigGroup; +import com.core.data.ConfigOption; import com.core.data.CoreNode; import com.core.ui.Toast; import com.jfoenix.controls.JFXButton; @@ -50,10 +50,10 @@ public class NodeEmaneDialog extends StageDialog { private void emaneButtonHandler(ActionEvent event) { try { - GetConfig getConfig = getCoreClient().getEmaneConfig(coreNode); - logger.debug("emane model config: {}", getConfig); + List configGroups = getCoreClient().getEmaneConfig(coreNode); + logger.debug("emane model config: {}", configGroups); String title = String.format("%s EMANE Config", coreNode.getName()); - getController().getConfigDialog().showDialog(title, getConfig, () -> { + getController().getConfigDialog().showDialog(title, configGroups, () -> { List options = getController().getConfigDialog().getOptions(); try { getCoreClient().setEmaneConfig(coreNode, options); @@ -73,10 +73,10 @@ public class NodeEmaneDialog extends StageDialog { public void displayEmaneModelConfig(Integer id, String model) { try { - GetConfig getConfig = getCoreClient().getEmaneModelConfig(id, model); - logger.debug("emane model config: {}", getConfig); + List configGroups = getCoreClient().getEmaneModelConfig(id, model); + logger.debug("emane model config: {}", configGroups); String title = String.format("EMANE(%s) %s Config", id, model); - getController().getConfigDialog().showDialog(title, getConfig, () -> { + getController().getConfigDialog().showDialog(title, configGroups, () -> { List options = getController().getConfigDialog().getOptions(); try { getCoreClient().setEmaneModelConfig(id, model, options); diff --git a/corefx/src/main/java/com/core/ui/dialogs/NodeServicesDialog.java b/corefx/src/main/java/com/core/ui/dialogs/NodeServicesDialog.java index 121091e0..fed4e7fe 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/NodeServicesDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/NodeServicesDialog.java @@ -1,7 +1,6 @@ package com.core.ui.dialogs; import com.core.Controller; -import com.core.client.rest.GetServices; import com.core.data.CoreNode; import com.core.ui.ServiceItem; import com.jfoenix.controls.JFXButton; @@ -81,14 +80,14 @@ public class NodeServicesDialog extends StageDialog { }); } - public void setServices(GetServices getServices) { + public void setServices(Map> serviceGroups) { serviceItemGroups.clear(); - getServices.getGroups().keySet().stream() + serviceGroups.keySet().stream() .sorted() .forEach(group -> { groupListView.getItems().add(group); - getServices.getGroups().get(group).stream() + serviceGroups.get(group).stream() .sorted() .forEach(service -> { ServiceItem serviceItem = new ServiceItem(service); diff --git a/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java b/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java index 1d136cb8..5144b023 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/SessionsDialog.java @@ -1,8 +1,7 @@ package com.core.ui.dialogs; import com.core.Controller; -import com.core.client.rest.GetSessions; -import com.core.client.rest.GetSessionsData; +import com.core.data.SessionOverview; import com.core.data.SessionState; import com.core.ui.Toast; import com.jfoenix.controls.JFXButton; @@ -15,6 +14,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; +import java.util.List; import java.util.stream.Collectors; public class SessionsDialog extends StageDialog { @@ -55,17 +55,17 @@ public class SessionsDialog extends StageDialog { private String state; private Integer nodes; - public SessionRow(GetSessionsData getSessionsData) { - id = getSessionsData.getId(); - state = SessionState.get(getSessionsData.getState()).name(); - nodes = getSessionsData.getNodes(); + public SessionRow(SessionOverview sessionOverview) { + id = sessionOverview.getId(); + state = SessionState.get(sessionOverview.getState()).name(); + nodes = sessionOverview.getNodes(); } } public void showDialog() throws IOException { sessionsTable.getItems().clear(); - GetSessions getSessions = getCoreClient().getSessions(); - sessionsTable.getItems().addAll(getSessions.getSessions().stream() + List sessions = getCoreClient().getSessions(); + sessionsTable.getItems().addAll(sessions.stream() .map(SessionRow::new) .collect(Collectors.toList())); diff --git a/corefx/src/main/java/com/core/ui/dialogs/SessionsFoenixDialog.java b/corefx/src/main/java/com/core/ui/dialogs/SessionsFoenixDialog.java index 5d13d91e..98c76ddc 100644 --- a/corefx/src/main/java/com/core/ui/dialogs/SessionsFoenixDialog.java +++ b/corefx/src/main/java/com/core/ui/dialogs/SessionsFoenixDialog.java @@ -1,8 +1,7 @@ package com.core.ui.dialogs; import com.core.Controller; -import com.core.client.rest.GetSessions; -import com.core.client.rest.GetSessionsData; +import com.core.data.SessionOverview; import com.core.data.SessionState; import com.core.ui.Toast; import com.jfoenix.controls.JFXButton; @@ -15,6 +14,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; +import java.util.List; import java.util.stream.Collectors; public class SessionsFoenixDialog extends CoreFoenixDialog { @@ -52,17 +52,17 @@ public class SessionsFoenixDialog extends CoreFoenixDialog { private String state; private Integer nodes; - public SessionRow(GetSessionsData getSessionsData) { - id = getSessionsData.getId(); - state = SessionState.get(getSessionsData.getState()).name(); - nodes = getSessionsData.getNodes(); + public SessionRow(SessionOverview sessionOverview) { + id = sessionOverview.getId(); + state = SessionState.get(sessionOverview.getState()).name(); + nodes = sessionOverview.getNodes(); } } public void showDialog() throws IOException { sessionsTable.getItems().clear(); - GetSessions getSessions = getCoreClient().getSessions(); - sessionsTable.getItems().addAll(getSessions.getSessions().stream() + List sessions = getCoreClient().getSessions(); + sessionsTable.getItems().addAll(sessions.stream() .map(SessionRow::new) .collect(Collectors.toList())); getDialog().show(getController().getStackPane());