Commit 503558e2 authored by Hélène Ortiz's avatar Hélène Ortiz

Add method getInstruments for remote access (for the moment, there isn't

any selection on userId, waiting for SI)
parent 4cbadb80
4.0.9 19/05/2020
-----
* Pass property names to ploty2 instead of ids
* Add method getInstruments for remote access (for the moment, there isn't any selection on userId, waiting for SI)
4.0.8 22/04/2020
-----
......
......@@ -6,6 +6,7 @@ startServerForbiddenForRemoteClientTitle=Run Nomad
clientConnectedToServerMessage=Connection with server successful!
clientInitialisingGraphicsMessage=Initialising graphics...
clientInitialisingPropertiesMessage=Loading properties...
clientInitialisingConnectionToPlotyFailed=Connection to ploty2 failed
clientConstructingSelectionPluginsAndToolBarMessage=Constructing selection areas and tool bars...
clientConstructingDisplayMessage=Constructing display...
clientConstructingCommandWindowMessage=Constructing command window...
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadgui</artifactId>
<version>4.0.8</version>
<version>4.0.9</version>
<name>NomadGUI</name>
<description>Graphical user interface for Nomad</description>
<scm>
......@@ -140,7 +140,7 @@
<dependency>
<groupId>fr.ill.ics</groupId>
<artifactId>nomadcommandsystem</artifactId>
<version>4.0.7</version>
<version>4.0.8</version>
</dependency>
<!-- **************************************************************** JFACE ****************************************************************
......
......@@ -159,6 +159,49 @@ public class UserConnection {
}
public ArrayList<Instrument> getInstruments() {
ArrayList<Instrument> instruments = new ArrayList<Instrument>();
try {
if (investigationsMode != MODE_FULL_TEST) {
URL url = new URL(URL + INSTRUMENTS);
HttpURLConnection instrumentsConnection = (HttpURLConnection)url.openConnection();
instrumentsConnection.setRequestMethod("GET");
instrumentsConnection.setUseCaches(false);
instrumentsConnection.setRequestProperty("Content-Type", "application/json");
instrumentsConnection.setDoInput(true); // sets the connection so that we can read from it
if (investigationsMode == MODE_INVESTIGATIONS_TEST) {
instrumentsConnection.addRequestProperty("Test", "true");
}
// Sets connection timeout in milliseconds
instrumentsConnection.setConnectTimeout(TIMEOUT);
// Sets read timeout in milliseconds
instrumentsConnection.setReadTimeout(TIMEOUT);
JSONObject jsonObject = null;
jsonObject = getJSONFrom(instrumentsConnection);
if (jsonObject != null) {
JSONArray data = (JSONArray)jsonObject.get(Proposal.JSON_DATA);
if (data != null) {
for (int i = 0; i < data.size(); i++) {
JSONObject instrument = (JSONObject)data.get(i);
long id = (Long)instrument.get(Instrument.JSON_ID);
String name = (String)instrument.get(Instrument.JSON_NAME);
instruments.add(new Instrument(id, name));
}
}
}
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return instruments;
}
public int connect(HttpURLConnection connection) {
try {
connection.connect();
......
......@@ -22,6 +22,7 @@ import java.util.ArrayList;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.bridge.events.TokenEvent.RemoteControlServerState;
import fr.ill.ics.client.control.experiment.Instrument;
import fr.ill.ics.client.control.login.UserConnection;
import fr.ill.ics.client.control.mock.MockDataAccessor;
import fr.ill.ics.client.view.MainWindowPeer;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
......@@ -55,7 +56,11 @@ public class RemoteControlManager {
public ArrayList<Instrument> getAllInstruments() {
return MockDataAccessor.getInstance().getInstruments();
if (ConfigManager.getInstance().mockMode()) {
return MockDataAccessor.getInstance().getInstruments();
} else {
return UserConnection.getInstance().getInstruments();
}
}
public String getUser() {
......
......@@ -123,7 +123,7 @@ public class Startup {
// if connection unsuccessful, do not go to next step
if (!plotyOk) {
advanceToNextStep = false;
informationKey = "Failled ploty2 connection";
informationKey = "clientInitialisingConnectionToPlotyFailed";
} else {
// set information key for next stage
informationKey = "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment