GGD/src/main/java/eu/hsrw/ias/ggd/PlonkDataRequest.java

62 lines
1.8 KiB
Java
Raw Normal View History

2022-03-02 17:15:00 +01:00
package eu.hsrw.ias.ggd;
import Credentials.PlonkTest;
2022-04-06 09:59:48 +02:00
import Credentials.UserCredentials;
import Files.ReadExcelFile;
import Files.UnZipFile;
2022-03-02 17:15:00 +01:00
import HttpCall.PlonkHttpGet;
2022-04-06 09:59:48 +02:00
2022-03-02 17:15:00 +01:00
import org.json.JSONObject;
2022-04-06 09:59:48 +02:00
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
2022-03-02 17:15:00 +01:00
public class PlonkDataRequest {
public static String x() throws Exception {
String token;
String result;
{
PlonkTest plonkTest = new PlonkTest();
PlonkHttpGet plonkHttpGet = new PlonkHttpGet();
String outputToken = PlonkHttpPostRequest.OnCallMethod();
JSONObject obj = new JSONObject(outputToken);
token = obj.getString("access_token");
2022-04-06 09:59:48 +02:00
String urlExtension= plonkTest.getServer()+"/api/pre/ ubersicht/data/Gießen-Düngen%20(Stufen)";
2022-03-02 17:15:00 +01:00
result = plonkHttpGet.PlonkHttpGetCall(urlExtension,token);
}
return result;
}
public static void main(String[] args) {
2022-04-06 09:59:48 +02:00
//if we want to fetch data from PlonkApi
// try {
// String output = x();
// System.out.println(output);
// } catch (Exception e) {
// e.printStackTrace();
// }
//This part is unziping the excel file from the url
UnZipFile unZipFile = new UnZipFile();
UserCredentials userCredentials = new UserCredentials();
String workPath = userCredentials.getHomeRoot();
Path source = Paths.get(workPath+"PlonkData.zip");
Path target = Paths.get(workPath);
ReadExcelFile DT = new ReadExcelFile();
2022-03-02 17:15:00 +01:00
try {
2022-04-06 09:59:48 +02:00
unZipFile.unzipFolder(source, target);
DT.readExcel();
System.out.println("Done");
} catch (IOException e) {
2022-03-02 17:15:00 +01:00
e.printStackTrace();
}
}
}