FINALIZED : FULLY WORKING
TODO : DATA MANIPULATION
This commit is contained in:
@@ -36,8 +36,8 @@ public class BoxCall4Partner {
|
||||
String baseURL = userCredentials.getBaseURL();
|
||||
String homeRoot = userCredentials.getHomeRoot();
|
||||
|
||||
String outputGeneral = null;
|
||||
outputGeneral = GeneralCall4All.FetchAll(token);
|
||||
|
||||
String outputGeneral = GeneralCall4All.FetchAll(token);
|
||||
JSONArray jsonarray = new JSONArray(outputGeneral);
|
||||
|
||||
cName = readFile.ReadFromFile(homeRoot +cName +".txt");
|
||||
@@ -55,10 +55,13 @@ public class BoxCall4Partner {
|
||||
String companyOutput = httpCall.HttpGet(baseURL + "devices/" + jsonID + "/sensors" + "?access_token=" + token, token);
|
||||
listOfCompanyOutputs.add(companyOutput);
|
||||
writingIntoFile.WriteFile(homeRoot +i+" "+ cName + ".json", companyOutput);
|
||||
System.out.println(listOfCompanyOutputs);
|
||||
loopTerminator++;
|
||||
System.out.println(loopTerminator + " "+arrayOfCompany.length+" "+jsonarray.length()+" "+iterator);
|
||||
}
|
||||
|
||||
if(loopTerminator == arrayOfCompany.length ){
|
||||
System.out.println("Entered ");
|
||||
return listOfCompanyOutputs;
|
||||
}
|
||||
|
||||
|
@@ -12,9 +12,6 @@ import java.util.ArrayList;
|
||||
///url/sensors/id/read
|
||||
|
||||
public class ReadSensors4Partner {
|
||||
|
||||
|
||||
|
||||
public String FetchSensor4Box(String companyName, String token) throws Exception {
|
||||
|
||||
switch (companyName) {
|
||||
@@ -40,19 +37,22 @@ public class ReadSensors4Partner {
|
||||
|
||||
BoxCall4Partner boxCall4Partner = new BoxCall4Partner();
|
||||
String outputBox = boxCall4Partner.FetchBox(cName,token);
|
||||
String outputBoxFixed=outputBox.replace("[[","[") + outputBox.replace("]]","]"); //to make the
|
||||
String outputBoxFixed=outputBox.replace("[[","[") + outputBox.replace("]]","]");// To convert in Jsonarray we need to remove the array list brackets
|
||||
JSONArray jsonArray = new JSONArray(outputBoxFixed);
|
||||
|
||||
System.out.println("The working array:"+jsonArray);
|
||||
ArrayList<String> list=new ArrayList<String>();
|
||||
int loopTerminator = 0;
|
||||
|
||||
char par = '"';
|
||||
for(int j=0; j<jsonArray.length(); j++){
|
||||
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||
String jsonID = jsonobject.getString("id");
|
||||
String jsonTag = jsonobject.getString("tag");
|
||||
|
||||
String sensorOutput = httpCall.HttpGet(baseURL + "sensors/" + jsonID + "/read" + "?access_token=" + token, token);
|
||||
list.add(sensorOutput);
|
||||
String sensorTag= par+"sensortag"+par+":"+jsonTag+"}]";
|
||||
String makingList=sensorOutput.replace("}]","") ;
|
||||
list.add(makingList+","+sensorTag); // This modification of the list is done for the purpse of converting this list to a jsonarray.
|
||||
|
||||
writingIntoFile.WriteFile(homeRoot + jsonID + ".json", sensorOutput + jsonTag);
|
||||
loopTerminator++;
|
||||
if(loopTerminator == jsonArray.length()){
|
||||
|
@@ -1,4 +0,0 @@
|
||||
package JSON_Unpack;
|
||||
|
||||
public class Reading4AllSensors {
|
||||
}
|
Reference in New Issue
Block a user