diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 797acea..0000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index a1c26ad..b364086 100644
--- a/pom.xml
+++ b/pom.xml
@@ -109,6 +109,23 @@
+
+
+
+ org.apache.poi
+ poi
+ 5.2.1
+
+
+
+ org.apache.poi
+ poi-ooxml
+ 5.2.1
+
+
+
+
+
org.jbpm
jbpm-test
diff --git a/src/main/java/Data/Spritztagebuch.xlsx b/src/main/java/Data/Spritztagebuch.xlsx
new file mode 100644
index 0000000..162d10b
Binary files /dev/null and b/src/main/java/Data/Spritztagebuch.xlsx differ
diff --git a/src/main/java/Data/securityToken.txt b/src/main/java/Data/securityToken.txt
index 4116f70..18b3348 100644
--- a/src/main/java/Data/securityToken.txt
+++ b/src/main/java/Data/securityToken.txt
@@ -1 +1 @@
-MmfFR7KvbrelQJAsfKnmLKfdIATdIuHOTZc0H4B9gJweQ3Ifx6SJjVoBs59hW1iY
\ No newline at end of file
+936JzYXxJIzzITnuVOGYMDHRCYtKuaF4EOSY3p8jUPeZNV9HeqPBYXQ0WybUy11V
\ No newline at end of file
diff --git a/src/main/java/Files/ReadExcelFile.java b/src/main/java/Files/ReadExcelFile.java
new file mode 100644
index 0000000..8627791
--- /dev/null
+++ b/src/main/java/Files/ReadExcelFile.java
@@ -0,0 +1,17 @@
+package Files;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import static Credentials.UserCredentials.getHomeRoot;
+
+
+public class ReadExcelFile {
+
+ public void readExcel() throws IOException {
+ // Create an instance of the class that reads Excel files
+
+ // Read XLSX file
+ FileInputStream file = new FileInputStream(getHomeRoot() + "Spritztagebuch.xlsx");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/Files/UnZipFile.java b/src/main/java/Files/UnZipFile.java
new file mode 100644
index 0000000..dd59b4c
--- /dev/null
+++ b/src/main/java/Files/UnZipFile.java
@@ -0,0 +1,113 @@
+package Files;
+
+import Credentials.UserCredentials;
+import HttpCall.PlonkHttpGet;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class UnZipFile {
+// public static void main(String[] args) {
+//
+// UserCredentials userCredentials = new UserCredentials();
+// String workPath = userCredentials.getHomeRoot();
+//
+// Path source = Paths.get(workPath+"PlonkData.zip");
+// Path target = Paths.get(workPath);
+//
+// try {
+//
+// unzipFolder(source, target);
+// System.out.println("Done");
+//
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+//
+// }
+
+ public static void unzipFolder(Path source, Path target) throws IOException {
+
+ try (ZipInputStream zis = new ZipInputStream(new FileInputStream(source.toFile()))) {
+
+ // list files in zip
+ ZipEntry zipEntry = zis.getNextEntry();
+
+ while (zipEntry != null) {
+
+ boolean isDirectory = false;
+ // example 1.1
+ // some zip stored files and folders separately
+ // e.g data/
+ // data/folder/
+ // data/folder/file.txt
+ if (zipEntry.getName().endsWith(File.separator)) {
+ isDirectory = true;
+ }
+
+ Path newPath = zipSlipProtect(zipEntry, target);
+
+ if (isDirectory) {
+ Files.createDirectories(newPath);
+ } else {
+
+ // example 1.2
+ // some zip stored file path only, need create parent directories
+ // e.g data/folder/file.txt
+ if (newPath.getParent() != null) {
+ if (Files.notExists(newPath.getParent())) {
+ Files.createDirectories(newPath.getParent());
+ }
+ }
+
+ // copy files, nio
+ Files.copy(zis, newPath, StandardCopyOption.REPLACE_EXISTING);
+
+ // copy files, classic
+ /*try (FileOutputStream fos = new FileOutputStream(newPath.toFile())) {
+ byte[] buffer = new byte[1024];
+ int len;
+ while ((len = zis.read(buffer)) > 0) {
+ fos.write(buffer, 0, len);
+ }
+ }*/
+ }
+
+ zipEntry = zis.getNextEntry();
+
+ }
+ zis.closeEntry();
+
+ }
+
+ }
+
+ // protect zip slip attack
+ public static Path zipSlipProtect(ZipEntry zipEntry, Path targetDir)
+ throws IOException {
+
+ // test zip slip vulnerability
+ // Path targetDirResolved = targetDir.resolve("../../" + zipEntry.getName());
+
+ Path targetDirResolved = targetDir.resolve(zipEntry.getName());
+
+ // make sure normalized file still has targetDir as its prefix
+ // else throws exception
+ Path normalizePath = targetDirResolved.normalize();
+ if (!normalizePath.startsWith(targetDir)) {
+ throw new IOException("Bad zip entry: " + zipEntry.getName());
+ }
+
+ return normalizePath;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/eu/hsrw/ias/ggd/ApiCall.java b/src/main/java/eu/hsrw/ias/ggd/ApiCall.java
index 2129529..8e19ecd 100644
--- a/src/main/java/eu/hsrw/ias/ggd/ApiCall.java
+++ b/src/main/java/eu/hsrw/ias/ggd/ApiCall.java
@@ -42,7 +42,7 @@ public class ApiCall {
ReadSensors4Partner readSensors4Partner = new ReadSensors4Partner();
ArrayList outputValue =
- (readSensors4Partner.FetchSensor4Box("Germes", token));
+ (readSensors4Partner.FetchSensor4Box("Nica", token));
for (int i = 0; i < outputValue.size(); i++) {
Device device;
diff --git a/src/main/java/eu/hsrw/ias/ggd/Greenhouse.java b/src/main/java/eu/hsrw/ias/ggd/Greenhouse.java
index 107144b..e6d5416 100644
--- a/src/main/java/eu/hsrw/ias/ggd/Greenhouse.java
+++ b/src/main/java/eu/hsrw/ias/ggd/Greenhouse.java
@@ -6,6 +6,7 @@ import java.util.List;
public class Greenhouse {
private String id = "8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ private String id2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
private Severity state = Severity.Unknown;
public Greenhouse() {
@@ -16,6 +17,14 @@ public class Greenhouse {
this.devices = devices;
}
+ public String getId2() {
+ return id2;
+ }
+
+ public void setId2(String id2) {
+ this.id2 = id2;
+ }
+
public void addDevice(Device device) {
this.devices.add(device);
}
diff --git a/src/main/java/eu/hsrw/ias/ggd/PlonkDataRequest.java b/src/main/java/eu/hsrw/ias/ggd/PlonkDataRequest.java
index bf60f0e..77f16f9 100644
--- a/src/main/java/eu/hsrw/ias/ggd/PlonkDataRequest.java
+++ b/src/main/java/eu/hsrw/ias/ggd/PlonkDataRequest.java
@@ -1,9 +1,17 @@
package eu.hsrw.ias.ggd;
import Credentials.PlonkTest;
+import Credentials.UserCredentials;
+import Files.ReadExcelFile;
+import Files.UnZipFile;
import HttpCall.PlonkHttpGet;
+
import org.json.JSONObject;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
public class PlonkDataRequest {
public static String x() throws Exception {
String token;
@@ -14,7 +22,7 @@ public class PlonkDataRequest {
String outputToken = PlonkHttpPostRequest.OnCallMethod();
JSONObject obj = new JSONObject(outputToken);
token = obj.getString("access_token");
- String urlExtension= plonkTest.getServer()+"/api/pre/objects";
+ String urlExtension= plonkTest.getServer()+"/api/pre/ ubersicht/data/Gießen-Düngen%20(Stufen)";
result = plonkHttpGet.PlonkHttpGetCall(urlExtension,token);
}
@@ -23,10 +31,30 @@ public class PlonkDataRequest {
}
public static void main(String[] args) {
+ //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();
+
try {
- String output = x();
- System.out.println(output);
- } catch (Exception e) {
+
+ unZipFile.unzipFolder(source, target);
+ DT.readExcel();
+ System.out.println("Done");
+ } catch (IOException e) {
e.printStackTrace();
}
}
diff --git a/src/main/resources/rules/CriticalBattery.drl b/src/main/resources/rules/CriticalBattery.drl
index d36a328..bad9126 100644
--- a/src/main/resources/rules/CriticalBattery.drl
+++ b/src/main/resources/rules/CriticalBattery.drl
@@ -16,8 +16,9 @@ rule "CriticalBattery"
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalBatteryOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Battery %s in the following sensor %s \", \"battery\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalBatteryOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Battery %s in the following sensor %s \", \"battery\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalBatteryOutput);
insert(new Notification("battery", sensorData, Severity.Critical));
diff --git a/src/main/resources/rules/CriticalPrecipitation.drl b/src/main/resources/rules/CriticalPrecipitation.drl
index 1d32305..6cc9f40 100644
--- a/src/main/resources/rules/CriticalPrecipitation.drl
+++ b/src/main/resources/rules/CriticalPrecipitation.drl
@@ -13,8 +13,9 @@ rule "CriticalPrecipitation"
sensorData: SensorData(tag == "precipitation", value > 15.5) from sensorDatas
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput);
insert(new Notification("precipitation", sensorData, Severity.Warning));
diff --git a/src/main/resources/rules/CriticalSoilMoisture.drl b/src/main/resources/rules/CriticalSoilMoisture.drl
index bd6a81d..505d8c6 100644
--- a/src/main/resources/rules/CriticalSoilMoisture.drl
+++ b/src/main/resources/rules/CriticalSoilMoisture.drl
@@ -12,9 +12,10 @@ rule "CriticalSoilMoisture"
device: Device(sensorDatas: sensorData)
sensorData: SensorData(tag == "soilMoisture", value < 28.0) from sensorDatas
then
- String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+// String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";//Germes
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s. It’s too dry and the field needs fertilizer \", \"soilMoisture\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalSoilMoistureOutput);
final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical);
diff --git a/src/main/resources/rules/CriticalTemperature.drl b/src/main/resources/rules/CriticalTemperature.drl
index cde7f84..21dc8c2 100644
--- a/src/main/resources/rules/CriticalTemperature.drl
+++ b/src/main/resources/rules/CriticalTemperature.drl
@@ -13,8 +13,9 @@ rule "CriticalTemperature"
sensorData: SensorData(tag == "temperature", value < 10.0 || value > 30.0) from sensorDatas
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalTemperatureOutput);
final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical);
diff --git a/src/main/resources/rules/DielectricPermittivity.drl b/src/main/resources/rules/DielectricPermittivity.drl
index 80e781f..ee915b4 100644
--- a/src/main/resources/rules/DielectricPermittivity.drl
+++ b/src/main/resources/rules/DielectricPermittivity.drl
@@ -13,8 +13,9 @@ rule "DielectricPermittivity"
sensorData: SensorData(tag == "dielectricPermittivity", value > 20.0) from sensorDatas
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String dielectricPermittivityOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical dielectricPermittivity %s in the following sensor %s \", \"dielectricPermittivityOutput\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String dielectricPermittivityOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical dielectricPermittivity %s in the following sensor %s \", \"dielectricPermittivityOutput\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",dielectricPermittivityOutput);
insert(new Notification("dielectricPermittivity", sensorData, Severity.Warning));
end
diff --git a/src/main/resources/rules/optimal.drl b/src/main/resources/rules/optimal.drl
index 9d0657f..b3e714f 100644
--- a/src/main/resources/rules/optimal.drl
+++ b/src/main/resources/rules/optimal.drl
@@ -9,7 +9,7 @@ when
then
HttpPost httpPost = new HttpPost();
- final String optimalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is optimal\"}]}}");
+ final String optimalGreenhouse = String.format("{\"id\":\"nica-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is optimal\"}]}}");
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",optimalGreenhouse);
System.out.println("Green House optimal, because of: '"+warning.getType()+"'");
end
diff --git a/src/main/resources/rules/warnings.drl b/src/main/resources/rules/warnings.drl
index b6bc444..2dfbede 100644
--- a/src/main/resources/rules/warnings.drl
+++ b/src/main/resources/rules/warnings.drl
@@ -7,7 +7,7 @@ when
warning: Notification(severity > Severity.Warning)
then
HttpPost httpPost = new HttpPost();
- final String criticalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\"}]}}");
+ final String criticalGreenhouse = String.format("{\"id\":\"nica-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\"}]}}");
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalGreenhouse);
System.out.println(criticalGreenhouse);
System.out.println("Green House critical, because of: '"+warning.getType()+"'");
diff --git a/target/classes/rules/CriticalBattery.drl b/target/classes/rules/CriticalBattery.drl
index d36a328..bad9126 100644
--- a/target/classes/rules/CriticalBattery.drl
+++ b/target/classes/rules/CriticalBattery.drl
@@ -16,8 +16,9 @@ rule "CriticalBattery"
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalBatteryOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Battery %s in the following sensor %s \", \"battery\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalBatteryOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Battery %s in the following sensor %s \", \"battery\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalBatteryOutput);
insert(new Notification("battery", sensorData, Severity.Critical));
diff --git a/target/classes/rules/CriticalPrecipitation.drl b/target/classes/rules/CriticalPrecipitation.drl
index 1d32305..6cc9f40 100644
--- a/target/classes/rules/CriticalPrecipitation.drl
+++ b/target/classes/rules/CriticalPrecipitation.drl
@@ -13,8 +13,9 @@ rule "CriticalPrecipitation"
sensorData: SensorData(tag == "precipitation", value > 15.5) from sensorDatas
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalPrecipitationOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Precipitation %s in the following sensor %s \", \"precipitation\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalPrecipitationOutput);
insert(new Notification("precipitation", sensorData, Severity.Warning));
diff --git a/target/classes/rules/CriticalSoilMoisture.drl b/target/classes/rules/CriticalSoilMoisture.drl
index 8340986..bd71d93 100644
--- a/target/classes/rules/CriticalSoilMoisture.drl
+++ b/target/classes/rules/CriticalSoilMoisture.drl
@@ -12,9 +12,10 @@ rule "CriticalSoilMoisture"
device: Device(sensorDatas: sensorData)
sensorData: SensorData(tag == "soilMoisture", value < 28.0) from sensorDatas
then
- String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+// String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";//Germes
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s \", \"soilMoisture\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalSoilMoistureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Soil Moisture %s in the following device %s. It’s too dry and the field needs fertilizer \", \"soilMoisture\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalSoilMoistureOutput);
final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical);
diff --git a/target/classes/rules/CriticalTemperature.drl b/target/classes/rules/CriticalTemperature.drl
index cde7f84..21dc8c2 100644
--- a/target/classes/rules/CriticalTemperature.drl
+++ b/target/classes/rules/CriticalTemperature.drl
@@ -13,8 +13,9 @@ rule "CriticalTemperature"
sensorData: SensorData(tag == "temperature", value < 10.0 || value > 30.0) from sensorDatas
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String criticalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String criticalTemperatureOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical Temperature %s in the following device %s \", \"temperature\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalTemperatureOutput);
final String deviceCritical = String.format("{\"id\":\"%s-status\",\"data\":{\"measured\":[{ \"criticalStatus\": \"The status of %s device is critical\"}]}}",device.IdMapper(device.getId()),device.getId());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",deviceCritical);
diff --git a/target/classes/rules/DielectricPermittivity.drl b/target/classes/rules/DielectricPermittivity.drl
index 80e781f..ee915b4 100644
--- a/target/classes/rules/DielectricPermittivity.drl
+++ b/target/classes/rules/DielectricPermittivity.drl
@@ -13,8 +13,9 @@ rule "DielectricPermittivity"
sensorData: SensorData(tag == "dielectricPermittivity", value > 20.0) from sensorDatas
then
String greenhouse1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633";
+ String greenhouse2="e5ec9f15-f214-455d-9f02-3c134c770dc1";//Nica
HttpPost httpPost = new HttpPost();
- final String dielectricPermittivityOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical dielectricPermittivity %s in the following sensor %s \", \"dielectricPermittivityOutput\": %s}]}}",greenhouse1, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
+ final String dielectricPermittivityOutput = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Critical dielectricPermittivity %s in the following sensor %s \", \"dielectricPermittivityOutput\": %s}]}}",greenhouse2, sensorData.getValue(),sensorData.getTag(),sensorData.getValue());
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",dielectricPermittivityOutput);
insert(new Notification("dielectricPermittivity", sensorData, Severity.Warning));
end
diff --git a/target/classes/rules/warnings.drl b/target/classes/rules/warnings.drl
index b6bc444..2dfbede 100644
--- a/target/classes/rules/warnings.drl
+++ b/target/classes/rules/warnings.drl
@@ -7,7 +7,7 @@ when
warning: Notification(severity > Severity.Warning)
then
HttpPost httpPost = new HttpPost();
- final String criticalGreenhouse = String.format("{\"id\":\"germes-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\"}]}}");
+ final String criticalGreenhouse = String.format("{\"id\":\"nica-greenhouse-status\",\"data\":{\"measured\":[{ \"status\": \"The status of the greenhouse is critical\"}]}}");
httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",criticalGreenhouse);
System.out.println(criticalGreenhouse);
System.out.println("Green House critical, because of: '"+warning.getType()+"'");