refactored core client to use an interface and defined the rest client to adhere to it for now, eventually may help make it easier to switch if needed
This commit is contained in:
parent
f2f83f247d
commit
46730ce216
33 changed files with 479 additions and 481 deletions
|
@ -1,12 +1,10 @@
|
|||
package com.core;
|
||||
|
||||
import com.core.client.ICoreClient;
|
||||
import com.core.client.rest.*;
|
||||
import com.core.data.CoreLink;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.graph.NetworkGraph;
|
||||
import com.core.rest.ConfigOption;
|
||||
import com.core.rest.CoreApi;
|
||||
import com.core.rest.GetConfig;
|
||||
import com.core.rest.SetConfig;
|
||||
import com.core.ui.*;
|
||||
import com.core.utils.ConfigUtils;
|
||||
import com.core.websocket.CoreWebSocket;
|
||||
|
@ -53,8 +51,7 @@ public class Controller implements Initializable {
|
|||
|
||||
// core client utilities
|
||||
private CoreWebSocket coreWebSocket;
|
||||
private CoreApi coreApi;
|
||||
private CoreClient coreClient;
|
||||
private ICoreClient coreClient;
|
||||
|
||||
// ui elements
|
||||
private NetworkGraph networkGraph = new NetworkGraph(this);
|
||||
|
@ -87,8 +84,7 @@ public class Controller implements Initializable {
|
|||
logger.error("error starting web socket", ex);
|
||||
}
|
||||
|
||||
coreApi = new CoreApi(coreUrl);
|
||||
coreClient = new CoreClient(this);
|
||||
coreClient = new CoreRestClient(this, coreUrl);
|
||||
ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
executorService.submit(() -> {
|
||||
try {
|
||||
|
|
|
@ -1,236 +0,0 @@
|
|||
package com.core;
|
||||
|
||||
import com.core.data.*;
|
||||
import com.core.graph.NetworkGraph;
|
||||
import com.core.rest.*;
|
||||
import com.core.ui.Toast;
|
||||
import lombok.Data;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CoreClient {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private final Controller controller;
|
||||
private final NetworkGraph networkGraph;
|
||||
private final CoreApi coreApi;
|
||||
private Integer sessionId;
|
||||
private SessionState sessionState;
|
||||
private GetServices services;
|
||||
private List<String> emaneModels = new ArrayList<>();
|
||||
|
||||
public CoreClient(Controller controller) {
|
||||
this.controller = controller;
|
||||
this.networkGraph = controller.getNetworkGraph();
|
||||
this.coreApi = controller.getCoreApi();
|
||||
}
|
||||
|
||||
public void joinSession(Integer joinId, boolean notification) throws IOException {
|
||||
networkGraph.reset();
|
||||
GetSession session = coreApi.getSession(joinId);
|
||||
sessionId = joinId;
|
||||
sessionState = SessionState.get(session.getState());
|
||||
|
||||
logger.info("joining core session({}) state({}): {}", sessionId, sessionState, session);
|
||||
for (CoreNode node : session.getNodes()) {
|
||||
if (node.getModel() == null) {
|
||||
logger.info("skipping joined session node: {}", node.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeType nodeType = NodeType.getNodeType(node.getNodeTypeKey());
|
||||
node.setIcon(nodeType.getIcon());
|
||||
networkGraph.addNode(node);
|
||||
}
|
||||
|
||||
for (CoreLink link : session.getLinks()) {
|
||||
networkGraph.addLink(link);
|
||||
}
|
||||
|
||||
networkGraph.getGraphViewer().repaint();
|
||||
|
||||
if (notification) {
|
||||
Toast.info(String.format("Joined Session %s", sessionId.toString()));
|
||||
}
|
||||
|
||||
updateController();
|
||||
}
|
||||
|
||||
public void createSession() throws IOException {
|
||||
CreatedSession session = coreApi.createSession();
|
||||
logger.info("created session: {}", session);
|
||||
sessionId = session.getId();
|
||||
sessionState = SessionState.get(session.getState());
|
||||
Toast.info(String.format("Created Session %s", sessionId.toString()));
|
||||
joinSession(sessionId, false);
|
||||
}
|
||||
|
||||
public void initialJoin() throws IOException {
|
||||
services = coreApi.getServices();
|
||||
controller.getNodeServicesDialog().setServices(services);
|
||||
|
||||
logger.info("core services: {}", services);
|
||||
|
||||
logger.info("initial core session join");
|
||||
GetSessions response = coreApi.getSessions();
|
||||
logger.info("existing sessions: {}", response);
|
||||
if (response.getSessions().isEmpty()) {
|
||||
logger.info("creating initial session");
|
||||
createSession();
|
||||
updateController();
|
||||
} else {
|
||||
GetSessionsData getSessionsData = response.getSessions().get(0);
|
||||
Integer joinId = getSessionsData.getId();
|
||||
joinSession(joinId, true);
|
||||
}
|
||||
|
||||
// set emane models
|
||||
emaneModels = coreApi.getEmaneModels(sessionId).getModels();
|
||||
controller.getNodeEmaneDialog().setModels(emaneModels);
|
||||
}
|
||||
|
||||
public boolean start() throws IOException {
|
||||
networkGraph.updatePositions();
|
||||
|
||||
boolean result = setState(SessionState.DEFINITION);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
result = setState(SessionState.CONFIGURATION);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Hook hook : controller.getHooksDialog().getHooks()) {
|
||||
if (!createHook(hook)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (CoreNode node : networkGraph.getGraph().getVertices()) {
|
||||
if (!coreApi.createNode(sessionId, node)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (CoreLink link : networkGraph.getGraph().getEdges()) {
|
||||
if (!coreApi.createLink(sessionId, link)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return setState(SessionState.INSTANTIATION);
|
||||
}
|
||||
|
||||
public boolean setState(SessionState state) throws IOException {
|
||||
boolean result = coreApi.setSessionState(sessionId, state);
|
||||
if (result) {
|
||||
sessionState = state;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public CoreService getService(CoreNode node, String serviceName) throws IOException {
|
||||
return coreApi.getService(sessionId, node, serviceName);
|
||||
}
|
||||
|
||||
public boolean setService(CoreNode node, String serviceName, CoreService service) throws IOException {
|
||||
return coreApi.setService(sessionId, node, serviceName, service);
|
||||
}
|
||||
|
||||
public String getServiceFile(CoreNode node, String serviceName, String fileName) throws IOException {
|
||||
return coreApi.getServiceFile(sessionId, node, serviceName, fileName);
|
||||
}
|
||||
|
||||
public boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException {
|
||||
return coreApi.setServiceFile(sessionId, node, serviceName, serviceFile);
|
||||
}
|
||||
|
||||
public GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException {
|
||||
return coreApi.getEmaneModelConfig(sessionId, node, model);
|
||||
}
|
||||
|
||||
public GetConfig getEmaneConfig(CoreNode node) throws IOException {
|
||||
return coreApi.getEmaneConfig(sessionId, node);
|
||||
}
|
||||
|
||||
public boolean setEmaneConfig(CoreNode node, List<ConfigOption> options) throws IOException {
|
||||
return coreApi.setEmaneConfig(sessionId, node, options);
|
||||
}
|
||||
|
||||
public boolean setEmaneModelConfig(CoreNode node, String model, List<ConfigOption> options) throws IOException {
|
||||
return coreApi.setEmaneModelConfig(sessionId, node, model, options);
|
||||
}
|
||||
|
||||
private void updateController() {
|
||||
controller.getGraphToolbar().setRunButton(isRunning());
|
||||
controller.getHooksDialog().updateHooks();
|
||||
}
|
||||
|
||||
public boolean isRunning() {
|
||||
return sessionState == SessionState.RUNTIME;
|
||||
}
|
||||
|
||||
public void saveSession(File file) throws IOException {
|
||||
coreApi.saveSession(sessionId, file);
|
||||
}
|
||||
|
||||
public void openSession(File file) throws IOException {
|
||||
CreatedSession createdSession = coreApi.openSession(file);
|
||||
joinSession(createdSession.getId(), true);
|
||||
}
|
||||
|
||||
public GetConfig getSessionConfig() throws IOException {
|
||||
return coreApi.getSessionConfig(sessionId);
|
||||
}
|
||||
|
||||
public boolean setSessionConfig(SetConfig config) throws IOException {
|
||||
return coreApi.setSessionConfig(sessionId, config);
|
||||
}
|
||||
|
||||
public boolean createNode(CoreNode node) throws IOException {
|
||||
return coreApi.createNode(sessionId, node);
|
||||
}
|
||||
|
||||
public boolean deleteNode(CoreNode node) throws IOException {
|
||||
return coreApi.deleteNode(sessionId, node);
|
||||
}
|
||||
|
||||
public boolean createHook(Hook hook) throws IOException {
|
||||
return coreApi.createHook(sessionId, hook);
|
||||
}
|
||||
|
||||
public GetHooks getHooks() throws IOException {
|
||||
return coreApi.getHooks(sessionId);
|
||||
}
|
||||
|
||||
public WlanConfig getWlanConfig(CoreNode node) throws IOException {
|
||||
return coreApi.getWlanConfig(sessionId, node);
|
||||
}
|
||||
|
||||
public boolean setWlanConfig(CoreNode node, WlanConfig config) throws IOException {
|
||||
return coreApi.setWlanConfig(sessionId, node, config);
|
||||
}
|
||||
|
||||
public String getTerminalCommand(CoreNode node) throws IOException {
|
||||
return coreApi.getTerminalCommand(sessionId, node);
|
||||
}
|
||||
|
||||
public boolean setMobilityConfig(CoreNode node, MobilityConfig config) throws IOException {
|
||||
return coreApi.setMobilityConfig(sessionId, node, config);
|
||||
}
|
||||
|
||||
public MobilityConfig getMobilityConfig(CoreNode node) throws IOException {
|
||||
return coreApi.getMobilityConfig(sessionId, node);
|
||||
}
|
||||
|
||||
public boolean mobilityAction(CoreNode node, String action) throws IOException {
|
||||
return coreApi.mobilityAction(sessionId, node, action);
|
||||
}
|
||||
}
|
76
corefx/src/main/java/com/core/client/ICoreClient.java
Normal file
76
corefx/src/main/java/com/core/client/ICoreClient.java
Normal file
|
@ -0,0 +1,76 @@
|
|||
package com.core.client;
|
||||
|
||||
import com.core.client.rest.*;
|
||||
import com.core.data.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface ICoreClient {
|
||||
void joinSession(Integer joinId, boolean notification) throws IOException;
|
||||
|
||||
void createSession() throws IOException;
|
||||
|
||||
GetSessions getSessions() throws IOException;
|
||||
|
||||
GetSession getSession(Integer sessionId) throws IOException;
|
||||
|
||||
void initialJoin() throws IOException;
|
||||
|
||||
boolean start() throws IOException;
|
||||
|
||||
boolean setState(SessionState state) throws IOException;
|
||||
|
||||
GetServices getServices() throws IOException;
|
||||
|
||||
CoreService getService(CoreNode node, String serviceName) throws IOException;
|
||||
|
||||
boolean setService(CoreNode node, String serviceName, CoreService service) throws IOException;
|
||||
|
||||
String getServiceFile(CoreNode node, String serviceName, String fileName) throws IOException;
|
||||
|
||||
boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException;
|
||||
|
||||
GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException;
|
||||
|
||||
GetConfig getEmaneConfig(CoreNode node) throws IOException;
|
||||
|
||||
GetEmaneModels getEmaneModels() throws IOException;
|
||||
|
||||
boolean setEmaneConfig(CoreNode node, List<ConfigOption> options) throws IOException;
|
||||
|
||||
boolean setEmaneModelConfig(CoreNode node, String model, List<ConfigOption> options) throws IOException;
|
||||
|
||||
boolean isRunning();
|
||||
|
||||
void saveSession(File file) throws IOException;
|
||||
|
||||
void openSession(File file) throws IOException;
|
||||
|
||||
GetConfig getSessionConfig() throws IOException;
|
||||
|
||||
boolean setSessionConfig(SetConfig config) throws IOException;
|
||||
|
||||
boolean createNode(CoreNode node) throws IOException;
|
||||
|
||||
boolean deleteNode(CoreNode node) throws IOException;
|
||||
|
||||
boolean createLink(CoreLink link) throws IOException;
|
||||
|
||||
boolean createHook(Hook hook) throws IOException;
|
||||
|
||||
GetHooks getHooks() throws IOException;
|
||||
|
||||
WlanConfig getWlanConfig(CoreNode node) throws IOException;
|
||||
|
||||
boolean setWlanConfig(CoreNode node, WlanConfig config) throws IOException;
|
||||
|
||||
String getTerminalCommand(CoreNode node) throws IOException;
|
||||
|
||||
boolean setMobilityConfig(CoreNode node, MobilityConfig config) throws IOException;
|
||||
|
||||
MobilityConfig getMobilityConfig(CoreNode node) throws IOException;
|
||||
|
||||
boolean mobilityAction(CoreNode node, String action) throws IOException;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
351
corefx/src/main/java/com/core/client/rest/CoreRestClient.java
Normal file
351
corefx/src/main/java/com/core/client/rest/CoreRestClient.java
Normal file
|
@ -0,0 +1,351 @@
|
|||
package com.core.client.rest;
|
||||
|
||||
import com.core.Controller;
|
||||
import com.core.client.ICoreClient;
|
||||
import com.core.data.*;
|
||||
import com.core.graph.NetworkGraph;
|
||||
import com.core.ui.Toast;
|
||||
import com.core.utils.JsonUtils;
|
||||
import com.core.utils.WebUtils;
|
||||
import lombok.Data;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class CoreRestClient implements ICoreClient {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private final Controller controller;
|
||||
private final NetworkGraph networkGraph;
|
||||
private final String baseUrl;
|
||||
private Integer sessionId;
|
||||
private SessionState sessionState;
|
||||
|
||||
public CoreRestClient(Controller controller, String baseUrl) {
|
||||
this.controller = controller;
|
||||
this.baseUrl = baseUrl;
|
||||
this.networkGraph = controller.getNetworkGraph();
|
||||
}
|
||||
|
||||
private String getUrl(String path) {
|
||||
return String.format("%s/%s", baseUrl, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void joinSession(Integer joinId, boolean notification) throws IOException {
|
||||
networkGraph.reset();
|
||||
GetSession session = getSession(joinId);
|
||||
sessionId = joinId;
|
||||
sessionState = SessionState.get(session.getState());
|
||||
|
||||
logger.info("joining core session({}) state({}): {}", sessionId, sessionState, session);
|
||||
for (CoreNode node : session.getNodes()) {
|
||||
if (node.getModel() == null) {
|
||||
logger.info("skipping joined session node: {}", node.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeType nodeType = NodeType.getNodeType(node.getNodeTypeKey());
|
||||
node.setIcon(nodeType.getIcon());
|
||||
networkGraph.addNode(node);
|
||||
}
|
||||
|
||||
for (CoreLink link : session.getLinks()) {
|
||||
networkGraph.addLink(link);
|
||||
}
|
||||
|
||||
networkGraph.getGraphViewer().repaint();
|
||||
|
||||
if (notification) {
|
||||
Toast.info(String.format("Joined Session %s", sessionId.toString()));
|
||||
}
|
||||
|
||||
updateController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSession() throws IOException {
|
||||
String url = getUrl("sessions");
|
||||
CreatedSession session = WebUtils.post(url, CreatedSession.class);
|
||||
|
||||
logger.info("created session: {}", session);
|
||||
sessionId = session.getId();
|
||||
sessionState = SessionState.get(session.getState());
|
||||
Toast.info(String.format("Created Session %s", sessionId.toString()));
|
||||
joinSession(sessionId, false);
|
||||
}
|
||||
|
||||
public GetServices getServices() throws IOException {
|
||||
String url = getUrl("services");
|
||||
return WebUtils.getJson(url, GetServices.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialJoin() throws IOException {
|
||||
GetServices services = getServices();
|
||||
logger.info("core services: {}", services);
|
||||
controller.getNodeServicesDialog().setServices(services);
|
||||
|
||||
logger.info("initial core session join");
|
||||
GetSessions response = getSessions();
|
||||
|
||||
logger.info("existing sessions: {}", response);
|
||||
if (response.getSessions().isEmpty()) {
|
||||
logger.info("creating initial session");
|
||||
createSession();
|
||||
updateController();
|
||||
} else {
|
||||
GetSessionsData getSessionsData = response.getSessions().get(0);
|
||||
Integer joinId = getSessionsData.getId();
|
||||
joinSession(joinId, true);
|
||||
}
|
||||
|
||||
// set emane models
|
||||
List<String> emaneModels = getEmaneModels().getModels();
|
||||
controller.getNodeEmaneDialog().setModels(emaneModels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetSession getSession(Integer sessionId) throws IOException {
|
||||
String path = String.format("sessions/%s", sessionId);
|
||||
String url = getUrl(path);
|
||||
return WebUtils.getJson(url, GetSession.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetSessions getSessions() throws IOException {
|
||||
String url = getUrl("sessions");
|
||||
return WebUtils.getJson(url, GetSessions.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() throws IOException {
|
||||
networkGraph.updatePositions();
|
||||
|
||||
boolean result = setState(SessionState.DEFINITION);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
result = setState(SessionState.CONFIGURATION);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Hook hook : controller.getHooksDialog().getHooks()) {
|
||||
if (!createHook(hook)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (CoreNode node : networkGraph.getGraph().getVertices()) {
|
||||
if (!createNode(node)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (CoreLink link : networkGraph.getGraph().getEdges()) {
|
||||
if (!createLink(link)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return setState(SessionState.INSTANTIATION);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean setState(SessionState state) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/state", sessionId));
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
data.put("state", state.getValue());
|
||||
boolean result = WebUtils.putJson(url, JsonUtils.toString(data));
|
||||
|
||||
if (result) {
|
||||
sessionState = state;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CoreService getService(CoreNode node, String serviceName) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s", sessionId, node.getId(), serviceName));
|
||||
return WebUtils.getJson(url, CoreService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setService(CoreNode node, String serviceName, CoreService service) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s", sessionId, node.getId(), serviceName));
|
||||
return WebUtils.putJson(url, JsonUtils.toString(service));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceFile(CoreNode node, String serviceName, String fileName) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s/file", sessionId, node.getId(),
|
||||
serviceName));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("file", fileName);
|
||||
return WebUtils.getJson(url, String.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setServiceFile(CoreNode node, String serviceName, ServiceFile serviceFile) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s/file", sessionId, node.getId(),
|
||||
serviceName));
|
||||
return WebUtils.putJson(url, JsonUtils.toString(serviceFile));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetEmaneModels getEmaneModels() throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/models", sessionId));
|
||||
return WebUtils.getJson(url, GetEmaneModels.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetConfig getEmaneModelConfig(CoreNode node, String model) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("node", node.getId().toString());
|
||||
args.put("name", model);
|
||||
return WebUtils.getJson(url, GetConfig.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetConfig getEmaneConfig(CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/config", sessionId));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("node", node.getId().toString());
|
||||
return WebUtils.getJson(url, GetConfig.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setEmaneConfig(CoreNode node, List<ConfigOption> options) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/config", sessionId));
|
||||
SetEmaneConfig setEmaneConfig = new SetEmaneConfig();
|
||||
setEmaneConfig.setNode(node.getId());
|
||||
setEmaneConfig.setValues(options);
|
||||
return WebUtils.putJson(url, JsonUtils.toString(setEmaneConfig));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setEmaneModelConfig(CoreNode node, String model, List<ConfigOption> options) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/model/config", sessionId));
|
||||
SetEmaneModelConfig setEmaneModelConfig = new SetEmaneModelConfig();
|
||||
setEmaneModelConfig.setNode(node.getId());
|
||||
setEmaneModelConfig.setName(model);
|
||||
setEmaneModelConfig.setValues(options);
|
||||
return WebUtils.putJson(url, JsonUtils.toString(setEmaneModelConfig));
|
||||
}
|
||||
|
||||
private void updateController() {
|
||||
controller.getGraphToolbar().setRunButton(isRunning());
|
||||
controller.getHooksDialog().updateHooks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return sessionState == SessionState.RUNTIME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSession(File file) throws IOException {
|
||||
String path = String.format("sessions/%s/xml", sessionId);
|
||||
String url = getUrl(path);
|
||||
WebUtils.getFile(url, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openSession(File file) throws IOException {
|
||||
String url = getUrl("sessions/xml");
|
||||
CreatedSession createdSession = WebUtils.putFile(url, file, CreatedSession.class);
|
||||
joinSession(createdSession.getId(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetConfig getSessionConfig() throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/options", sessionId));
|
||||
return WebUtils.getJson(url, GetConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSessionConfig(SetConfig config) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/options", sessionId));
|
||||
return WebUtils.putJson(url, JsonUtils.toString(config));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createNode(CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes", sessionId));
|
||||
String data = JsonUtils.toString(node);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteNode(CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("/sessions/%s/nodes/%s", sessionId, node.getId()));
|
||||
return WebUtils.delete(url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createLink(CoreLink link) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/links", sessionId));
|
||||
String data = JsonUtils.toString(link);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createHook(Hook hook) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/hooks", sessionId));
|
||||
String data = JsonUtils.toString(hook);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GetHooks getHooks() throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/hooks", sessionId));
|
||||
return WebUtils.getJson(url, GetHooks.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WlanConfig getWlanConfig(CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/wlan", sessionId, node.getId()));
|
||||
return WebUtils.getJson(url, WlanConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWlanConfig(CoreNode node, WlanConfig config) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/wlan", sessionId, node.getId()));
|
||||
String jsonData = JsonUtils.toString(config);
|
||||
return WebUtils.putJson(url, jsonData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTerminalCommand(CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/terminal", sessionId, node.getId()));
|
||||
return WebUtils.getJson(url, String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMobilityConfig(CoreNode node, MobilityConfig config) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/mobility", sessionId, node.getId()));
|
||||
String data = JsonUtils.toString(config);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobilityConfig getMobilityConfig(CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/mobility", sessionId, node.getId()));
|
||||
return WebUtils.getJson(url, MobilityConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mobilityAction(CoreNode node, String action) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/mobility/%s", sessionId, node.getId(), action));
|
||||
return WebUtils.putJson(url, null);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import com.core.data.Hook;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.data.CoreLink;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.core.rest;
|
||||
package com.core.client.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
|
@ -133,10 +133,13 @@ public class NetworkGraph {
|
|||
|
||||
@Override
|
||||
public void graphReleased(CoreNode node, MouseEvent mouseEvent) {
|
||||
logger.info("graph released mouse event: {}", mouseEvent);
|
||||
if (SwingUtilities.isLeftMouseButton(mouseEvent)) {
|
||||
logger.debug("moved node({}): {}", node.getName(), mouseEvent.getPoint());
|
||||
node.getPosition().setX(mouseEvent.getPoint().getX());
|
||||
node.getPosition().setY(mouseEvent.getPoint().getY());
|
||||
double x = graphLayout.getX(node);
|
||||
double y = graphLayout.getY(node);
|
||||
logger.debug("graph moved node({}): {},{}", node.getName(), x, y);
|
||||
node.getPosition().setX(x);
|
||||
node.getPosition().setY(y);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,193 +0,0 @@
|
|||
package com.core.rest;
|
||||
|
||||
import com.core.data.*;
|
||||
import com.core.utils.JsonUtils;
|
||||
import com.core.utils.WebUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CoreApi {
|
||||
private final String baseUrl;
|
||||
|
||||
private String getUrl(String path) {
|
||||
return String.format("%s/%s", baseUrl, path);
|
||||
}
|
||||
|
||||
public GetSessions getSessions() throws IOException {
|
||||
String url = getUrl("sessions");
|
||||
return WebUtils.getJson(url, GetSessions.class);
|
||||
}
|
||||
|
||||
public GetSession getSession(Integer session) throws IOException {
|
||||
String path = String.format("sessions/%s", session);
|
||||
String url = getUrl(path);
|
||||
return WebUtils.getJson(url, GetSession.class);
|
||||
}
|
||||
|
||||
public CreatedSession createSession() throws IOException {
|
||||
String url = getUrl("sessions");
|
||||
return WebUtils.post(url, CreatedSession.class);
|
||||
}
|
||||
|
||||
public void saveSession(Integer id, File file) throws IOException {
|
||||
String path = String.format("sessions/%s/xml", id);
|
||||
String url = getUrl(path);
|
||||
WebUtils.getFile(url, file);
|
||||
}
|
||||
|
||||
public CreatedSession openSession(File file) throws IOException {
|
||||
String url = getUrl("sessions/xml");
|
||||
return WebUtils.putFile(url, file, CreatedSession.class);
|
||||
}
|
||||
|
||||
public GetConfig getSessionConfig(Integer session) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/options", session));
|
||||
return WebUtils.getJson(url, GetConfig.class);
|
||||
}
|
||||
|
||||
public boolean setSessionConfig(Integer session, SetConfig config) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/options", session));
|
||||
return WebUtils.putJson(url, JsonUtils.toString(config));
|
||||
}
|
||||
|
||||
public boolean setSessionState(Integer session, SessionState state) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/state", session));
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
data.put("state", state.getValue());
|
||||
return WebUtils.putJson(url, JsonUtils.toString(data));
|
||||
}
|
||||
|
||||
public boolean createNode(Integer session, CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes", session));
|
||||
String data = JsonUtils.toString(node);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
public boolean deleteNode(Integer session, CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("/sessions/%s/nodes/%s", session, node.getId()));
|
||||
return WebUtils.delete(url);
|
||||
}
|
||||
|
||||
public boolean createLink(Integer session, CoreLink link) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/links", session));
|
||||
String data = JsonUtils.toString(link);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
public GetServices getServices() throws IOException {
|
||||
String url = getUrl("services");
|
||||
return WebUtils.getJson(url, GetServices.class);
|
||||
}
|
||||
|
||||
public CoreService getService(Integer session, CoreNode node, String serviceName) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s", session, node.getId(), serviceName));
|
||||
return WebUtils.getJson(url, CoreService.class);
|
||||
}
|
||||
|
||||
public String getServiceFile(Integer session, CoreNode node, String serviceName, String fileName)
|
||||
throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s/file", session, node.getId(), serviceName));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("file", fileName);
|
||||
return WebUtils.getJson(url, String.class, args);
|
||||
}
|
||||
|
||||
public boolean setService(Integer session, CoreNode node, String serviceName, CoreService service)
|
||||
throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s", session, node.getId(), serviceName));
|
||||
return WebUtils.putJson(url, JsonUtils.toString(service));
|
||||
}
|
||||
|
||||
public boolean setServiceFile(Integer session, CoreNode node, String service, ServiceFile serviceFile)
|
||||
throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/services/%s/file", session, node.getId(), service));
|
||||
return WebUtils.putJson(url, JsonUtils.toString(serviceFile));
|
||||
}
|
||||
|
||||
public GetEmaneModels getEmaneModels(Integer session) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/models", session));
|
||||
return WebUtils.getJson(url, GetEmaneModels.class);
|
||||
}
|
||||
|
||||
public GetConfig getEmaneModelConfig(Integer session, CoreNode node, String model) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/model/config", session));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("node", node.getId().toString());
|
||||
args.put("name", model);
|
||||
return WebUtils.getJson(url, GetConfig.class, args);
|
||||
}
|
||||
|
||||
public GetConfig getEmaneConfig(Integer session, CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/config", session));
|
||||
Map<String, String> args = new HashMap<>();
|
||||
args.put("node", node.getId().toString());
|
||||
return WebUtils.getJson(url, GetConfig.class, args);
|
||||
}
|
||||
|
||||
public boolean setEmaneConfig(Integer session, CoreNode node, List<ConfigOption> options) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/config", session));
|
||||
SetEmaneConfig setEmaneConfig = new SetEmaneConfig();
|
||||
setEmaneConfig.setNode(node.getId());
|
||||
setEmaneConfig.setValues(options);
|
||||
return WebUtils.putJson(url, JsonUtils.toString(setEmaneConfig));
|
||||
}
|
||||
|
||||
public boolean setEmaneModelConfig(Integer session, CoreNode node, String model, List<ConfigOption> options)
|
||||
throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/emane/model/config", session));
|
||||
SetEmaneModelConfig setEmaneModelConfig = new SetEmaneModelConfig();
|
||||
setEmaneModelConfig.setNode(node.getId());
|
||||
setEmaneModelConfig.setName(model);
|
||||
setEmaneModelConfig.setValues(options);
|
||||
return WebUtils.putJson(url, JsonUtils.toString(setEmaneModelConfig));
|
||||
}
|
||||
|
||||
public boolean createHook(Integer session, Hook hook) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/hooks", session));
|
||||
String data = JsonUtils.toString(hook);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
public GetHooks getHooks(Integer session) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/hooks", session));
|
||||
return WebUtils.getJson(url, GetHooks.class);
|
||||
}
|
||||
|
||||
public WlanConfig getWlanConfig(Integer session, CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/wlan", session, node.getId()));
|
||||
return WebUtils.getJson(url, WlanConfig.class);
|
||||
}
|
||||
|
||||
public boolean setWlanConfig(Integer session, CoreNode node, WlanConfig config) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/wlan", session, node.getId()));
|
||||
String jsonData = JsonUtils.toString(config);
|
||||
return WebUtils.putJson(url, jsonData);
|
||||
}
|
||||
|
||||
public boolean setMobilityConfig(Integer session, CoreNode node, MobilityConfig config) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/mobility", session, node.getId()));
|
||||
String data = JsonUtils.toString(config);
|
||||
return WebUtils.postJson(url, data);
|
||||
}
|
||||
|
||||
public MobilityConfig getMobilityConfig(Integer session, CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/mobility", session, node.getId()));
|
||||
return WebUtils.getJson(url, MobilityConfig.class);
|
||||
}
|
||||
|
||||
public boolean mobilityAction(Integer session, CoreNode node, String action) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/mobility/%s", session, node.getId(), action));
|
||||
return WebUtils.putJson(url, null);
|
||||
}
|
||||
|
||||
public String getTerminalCommand(Integer session, CoreNode node) throws IOException {
|
||||
String url = getUrl(String.format("sessions/%s/nodes/%s/terminal", session, node.getId()));
|
||||
return WebUtils.getJson(url, String.class);
|
||||
}
|
||||
}
|
|
@ -2,9 +2,9 @@ package com.core.ui;
|
|||
|
||||
import com.core.Controller;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.rest.ConfigGroup;
|
||||
import com.core.rest.ConfigOption;
|
||||
import com.core.rest.GetConfig;
|
||||
import com.core.client.rest.ConfigGroup;
|
||||
import com.core.client.rest.ConfigOption;
|
||||
import com.core.client.rest.GetConfig;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXScrollPane;
|
||||
import com.jfoenix.controls.JFXTabPane;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.core.ui;
|
||||
|
||||
import com.core.data.ConfigDataType;
|
||||
import com.core.rest.ConfigOption;
|
||||
import com.core.client.rest.ConfigOption;
|
||||
import com.jfoenix.controls.JFXComboBox;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import com.jfoenix.controls.JFXToggleButton;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.core.ui;
|
||||
|
||||
import com.core.Controller;
|
||||
import com.core.CoreClient;
|
||||
import com.core.client.ICoreClient;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXDialog;
|
||||
import com.jfoenix.controls.JFXDialogLayout;
|
||||
|
@ -40,13 +40,13 @@ public class CoreFoenixDialog extends JFXDialog {
|
|||
dialogLayout.setHeading(heading);
|
||||
dialog = new JFXDialog(controller.getStackPane(), dialogLayout, DialogTransition.CENTER);
|
||||
dialogLayout.setPrefWidth(800);
|
||||
dialogLayout.setPrefHeight(600);;
|
||||
dialogLayout.setPrefHeight(600);
|
||||
}
|
||||
|
||||
public void setOwner(Stage window) {
|
||||
}
|
||||
|
||||
public CoreClient getCoreClient() {
|
||||
public ICoreClient getCoreClient() {
|
||||
return controller.getCoreClient();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.core.ui;
|
|||
import com.core.Controller;
|
||||
import com.core.data.Hook;
|
||||
import com.core.data.SessionState;
|
||||
import com.core.rest.GetHooks;
|
||||
import com.core.client.rest.GetHooks;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.core.ui;
|
|||
|
||||
import com.core.Controller;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.rest.ConfigOption;
|
||||
import com.core.rest.GetConfig;
|
||||
import com.core.client.rest.ConfigOption;
|
||||
import com.core.client.rest.GetConfig;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXComboBox;
|
||||
import javafx.event.ActionEvent;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.core.ui;
|
|||
|
||||
import com.core.Controller;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.rest.GetServices;
|
||||
import com.core.client.rest.GetServices;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXComboBox;
|
||||
import com.jfoenix.controls.JFXScrollPane;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.core.ui;
|
|||
|
||||
import com.core.Controller;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.rest.WlanConfig;
|
||||
import com.core.client.rest.WlanConfig;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import javafx.fxml.FXML;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.core.ui;
|
|||
import com.core.Controller;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.data.CoreService;
|
||||
import com.core.rest.ServiceFile;
|
||||
import com.core.client.rest.ServiceFile;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXComboBox;
|
||||
import com.jfoenix.controls.JFXTextArea;
|
||||
|
@ -64,12 +64,13 @@ public class ServiceDialog extends StageDialog {
|
|||
coreService.setValidate(textToList(validateTextArea.getText()));
|
||||
coreService.setShutdown(textToList(shutdownTextArea.getText()));
|
||||
|
||||
try {
|
||||
getCoreClient().setService(coreNode, serviceName, coreService);
|
||||
|
||||
// service file data
|
||||
String fileName = filesComboBox.getSelectionModel().getSelectedItem();
|
||||
String data = fileTextArea.getText();
|
||||
ServiceFile serviceFile = new ServiceFile(fileName, data);
|
||||
|
||||
try {
|
||||
getCoreClient().setService(coreNode, serviceName, coreService);
|
||||
getCoreClient().setServiceFile(coreNode, serviceName, serviceFile);
|
||||
} catch (IOException ex) {
|
||||
logger.error("error setting node service", ex);
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.core.ui;
|
|||
|
||||
import com.core.Controller;
|
||||
import com.core.data.SessionState;
|
||||
import com.core.rest.GetSessions;
|
||||
import com.core.rest.GetSessionsData;
|
||||
import com.core.client.rest.GetSessions;
|
||||
import com.core.client.rest.GetSessionsData;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
|
@ -70,7 +70,7 @@ public class SessionsDialog extends StageDialog {
|
|||
|
||||
public void showDialog() throws IOException {
|
||||
sessionsTable.getItems().clear();
|
||||
GetSessions getSessions = getCoreClient().getCoreApi().getSessions();
|
||||
GetSessions getSessions = getCoreClient().getSessions();
|
||||
sessionsTable.getItems().addAll(getSessions.getSessions().stream()
|
||||
.map(SessionRow::new)
|
||||
.collect(Collectors.toList()));
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.core.ui;
|
||||
|
||||
import com.core.Controller;
|
||||
import com.core.client.rest.GetSessions;
|
||||
import com.core.client.rest.GetSessionsData;
|
||||
import com.core.data.SessionState;
|
||||
import com.core.rest.GetSessions;
|
||||
import com.core.rest.GetSessionsData;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
|
@ -67,7 +67,7 @@ public class SessionsFoenixDialog extends CoreFoenixDialog {
|
|||
|
||||
public void showDialog() throws IOException {
|
||||
sessionsTable.getItems().clear();
|
||||
GetSessions getSessions = getCoreClient().getCoreApi().getSessions();
|
||||
GetSessions getSessions = getCoreClient().getSessions();
|
||||
sessionsTable.getItems().addAll(getSessions.getSessions().stream()
|
||||
.map(SessionRow::new)
|
||||
.collect(Collectors.toList()));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.core.ui;
|
||||
|
||||
import com.core.Controller;
|
||||
import com.core.CoreClient;
|
||||
import com.core.client.ICoreClient;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXDecorator;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
|
@ -88,7 +88,7 @@ public class StageDialog {
|
|||
stage.close();
|
||||
}
|
||||
|
||||
public CoreClient getCoreClient() {
|
||||
public ICoreClient getCoreClient() {
|
||||
return controller.getCoreClient();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CoreWebSocket {
|
|||
SessionState state = SessionState.get(event.getEventType().getValue());
|
||||
if (state != null) {
|
||||
logger.info("event updating session state: {}", state);
|
||||
controller.getCoreClient().setSessionState(state);
|
||||
controller.getCoreClient().setState(state);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
logger.error("error getting core event", ex);
|
||||
|
|
Loading…
Reference in a new issue