forked from kevin.shehu/GGD
ADD: NEW CHANGES
FIX : Reworked ApiCall FIX : Reworked Rule Engine FIX : Reworked drl files
This commit is contained in:
@@ -6,17 +6,17 @@ import JSON_Unpack.ReadSensors4Partner;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class ApiCall {
|
||||
private static String token = "0";
|
||||
private static String oldId = "1";
|
||||
|
||||
|
||||
public static HashMap<String, Double> FetchDataFromApi() throws Exception {
|
||||
public static HashMap<String, SensorData> FetchDataFromApi() throws Exception {
|
||||
|
||||
|
||||
UserCredentials userCredentials = new UserCredentials();
|
||||
@@ -35,64 +35,34 @@ public class ApiCall {
|
||||
JSONObject obj = new JSONObject(outputToken);
|
||||
token = obj.getString("id");
|
||||
|
||||
writingIntoFile.WriteFile(homeRoot+"securityToken.txt", token);
|
||||
writingIntoFile.WriteFile(homeRoot + "securityToken.txt", token);
|
||||
oldId = token;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
ReadSensors4Partner readSensors4Partner = new ReadSensors4Partner();
|
||||
ArrayList<String> outputValue = (readSensors4Partner.FetchSensor4Box("Germes",token));
|
||||
String workingArray = String.valueOf(outputValue).replace("[{","{").replace("}]","}");
|
||||
ArrayList<String> outputValue = (readSensors4Partner.FetchSensor4Box("Germes", token));
|
||||
String workingArray = String.valueOf(outputValue).replace("[{", "{").replace("}]", "}");
|
||||
|
||||
JSONArray jsonArray = new JSONArray(workingArray);
|
||||
|
||||
HashMap<String, Double> sensors = new HashMap<String, Double>();
|
||||
for(int j = 0; j<jsonArray.length(); j++) {
|
||||
HashMap<String,
|
||||
SensorData> finalOutput = new HashMap();
|
||||
|
||||
for (int j = 0; j < jsonArray.length(); j++) {
|
||||
|
||||
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||
double value = jsonobject.getDouble("value");
|
||||
String sensorTag = jsonobject.getString("sensorTag");
|
||||
// System.out.println(value);
|
||||
// System.out.println(sensorTag);
|
||||
// sensorsMap.setSensors(sensorTag,value);
|
||||
sensors.put(sensorTag,value);
|
||||
String sensorId = jsonobject.getString("sensorId");
|
||||
|
||||
finalOutput.put(sensorTag, new SensorData(sensorId, value));
|
||||
|
||||
}
|
||||
|
||||
// ArrayList<String> listOfCompanies = new ArrayList<>();
|
||||
// String germesOutput = FetchData("Germes",token);
|
||||
// listOfCompanies.add(FetchData(c1,token));
|
||||
// listOfCompanies.add(FetchData("Heufs",token));
|
||||
|
||||
JOptionPane.showMessageDialog(null,sensors,"Germes sensors"+now,JOptionPane.INFORMATION_MESSAGE);
|
||||
|
||||
return sensors;
|
||||
return finalOutput;
|
||||
|
||||
}
|
||||
|
||||
// public static void FetchData(String companyName, String token){
|
||||
// ReadSensors4Partner readSensors4Partner = new ReadSensors4Partner();
|
||||
// ArrayList<String> outputValue = null;
|
||||
// try {
|
||||
// outputValue = (readSensors4Partner.FetchSensor4Box(companyName,token));
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// String workingArray = String.valueOf(outputValue).replace("[{","{").replace("}]","}");
|
||||
// JSONArray jsonArray = new JSONArray(workingArray);
|
||||
//
|
||||
// HashMap<String, Double> sensors = new HashMap<String, Double>();
|
||||
// for(int j = 0; j<jsonArray.length(); j++) {
|
||||
// JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||
// double value = jsonobject.getDouble("value");
|
||||
// String sensorTag = jsonobject.getString("sensorTag");
|
||||
//// System.out.println(value);
|
||||
//// System.out.println(sensorTag);
|
||||
//// sensorsMap.setSensors(sensorTag,value);
|
||||
// sensors.put(sensorTag,value);
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user