parent
e357d53584
commit
5b21bd77d5
|
@ -11,7 +11,35 @@
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_14_PREVIEW" default="false" project-jdk-name="14.0.1" project-jdk-type="JavaSDK">
|
<component name="ProjectPlainTextFileTypeManager">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/0 0004A30B00227D68,70B3D5705000E019.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/12 70B3D57050004682,70B3D570500046AB,70B3D57050004D14.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/12 70B3D57050004682,70B3D57050004D14.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/13 70B3D57050004223,70B3D570500042D7,70B3D57050004EEF,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/13 70B3D57050004223,70B3D570500042D7,70B3D57050004EF4,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/13ebfdd7-8a4f-4410-97ee-e51d6fccd569.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/14 70B3D57050004223,70B3D570500042D7,70B3D57050004EF4,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/15 70B3D57050004223,70B3D570500042D7,70B3D57050004EEF,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/15 70B3D57050004223,70B3D570500042D7,70B3D57050004EF4,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/23d6a70b-befb-4895-b138-20e08d2a195c.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/26bc66de-66af-4430-ace4-ea4eac6f8c95.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/389d6a48-cc10-4160-ba53-2b3cd80622d6.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/3eb4f776-8eca-4354-a3d8-d4b988b387ad.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/4 70B3D57050004223,70B3D570500042D7,70B3D57050004EEF,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/4 70B3D57050004223,70B3D570500042D7,70B3D57050004EF4,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/6 70B3D57050004682,70B3D570500046AB,70B3D57050004D14.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/6 70B3D57050004682,70B3D57050004D14.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/64a3d8c3-027c-4125-afeb-f53bbd0b7cc3.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/6b5ae232-2ada-49e5-8f79-4dbfc276dc7a.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/7 0004A30B00227D68,70B3D5705000E019.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/7669429f-94e4-4e4f-a0cc-56e96523ded5.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/8 70B3D57050004223,70B3D570500042D7,70B3D57050004EEF,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/8 70B3D57050004223,70B3D570500042D7,70B3D57050004EF4,70B3D57050006223,70B3D5705000623C.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/bdc213b0-50c4-4085-867a-c724fd454670.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/devicesOutput.json" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java/Data/e01b1f84-41c9-4cbf-8690-9b3552c8bc6d.json" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" project-jdk-name="14.0.1" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
24
pom.xml
24
pom.xml
|
@ -3,10 +3,13 @@
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<properties>
|
||||||
|
<runtime.version>7.48.0.Final</runtime.version>
|
||||||
|
</properties>
|
||||||
<groupId>org.example</groupId>
|
<groupId>org.example</groupId>
|
||||||
<artifactId>GGD</artifactId>
|
<artifactId>GGD</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -17,12 +20,13 @@
|
||||||
<target>11</target>
|
<target>11</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<properties>
|
|
||||||
<runtime.version>7.48.0.Final</runtime.version>
|
|
||||||
</properties>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>info.picocli</groupId>
|
<groupId>info.picocli</groupId>
|
||||||
<artifactId>picocli</artifactId>
|
<artifactId>picocli</artifactId>
|
||||||
|
@ -50,25 +54,25 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.drools</groupId>
|
<groupId>org.drools</groupId>
|
||||||
<artifactId>drools-core</artifactId>
|
<artifactId>drools-core</artifactId>
|
||||||
<version>7.48.0.Final</version>
|
<version>${runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.drools/drools-compiler -->
|
<!-- https://mvnrepository.com/artifact/org.drools/drools-compiler -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.drools</groupId>
|
<groupId>org.drools</groupId>
|
||||||
<artifactId>drools-compiler</artifactId>
|
<artifactId>drools-compiler</artifactId>
|
||||||
<version>7.48.0.Final</version>
|
<version>${runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.drools/drools-decisiontables -->
|
<!-- https://mvnrepository.com/artifact/org.drools/drools-decisiontables -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.drools</groupId>
|
<groupId>org.drools</groupId>
|
||||||
<artifactId>drools-decisiontables</artifactId>
|
<artifactId>drools-decisiontables</artifactId>
|
||||||
<version>7.48.0.Final</version>
|
<version>${runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.drools/kiebase-inclusion -->
|
<!-- https://mvnrepository.com/artifact/org.drools/kiebase-inclusion -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.drools</groupId>
|
<groupId>org.drools</groupId>
|
||||||
<artifactId>kiebase-inclusion</artifactId>
|
<artifactId>kiebase-inclusion</artifactId>
|
||||||
<version>7.48.0.Final</version>
|
<version>${runtime.version}</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -76,14 +80,14 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kie</groupId>
|
<groupId>org.kie</groupId>
|
||||||
<artifactId>kie-api</artifactId>
|
<artifactId>kie-api</artifactId>
|
||||||
<version>7.48.0.Final</version>
|
<version>${runtime.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.kie/kie-ci -->
|
<!-- https://mvnrepository.com/artifact/org.kie/kie-ci -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.kie</groupId>
|
<groupId>org.kie</groupId>
|
||||||
<artifactId>kie-ci</artifactId>
|
<artifactId>kie-ci</artifactId>
|
||||||
<version>7.48.0.Final</version>
|
<version>${runtime.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <repositories>-->
|
<!-- <repositories>-->
|
||||||
<!-- <repository>-->
|
<!-- <repository>-->
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import Credentials.UserCredentials;
|
import Credentials.UserCredentials;
|
||||||
import Files.WriteFile;
|
import Files.WriteFile;
|
||||||
import JSON_Unpack.ReadSensors4Partner;
|
import JSON_Unpack.ReadSensors4Partner;
|
||||||
|
import Knowledgebase.SensorReadings;
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ApiCall {
|
public class ApiCall {
|
||||||
|
@ -33,11 +36,29 @@ public class ApiCall {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ReadSensors4Partner readSensors4Partner = new ReadSensors4Partner();
|
ReadSensors4Partner readSensors4Partner = new ReadSensors4Partner();
|
||||||
String y = (readSensors4Partner.FetchSensor4Box("Germes",token));
|
SensorReadings sensorReadings = new SensorReadings();
|
||||||
|
String outputValue = (readSensors4Partner.FetchSensor4Box("Germes",token));
|
||||||
|
System.out.println(outputValue);
|
||||||
|
String outputValueFixed=outputValue.replace("[[","[") +outputValue.replace("[{","{")+outputValue.replace("}]","}")+ outputValue.replace("]]","]");
|
||||||
|
System.out.println(outputValueFixed);
|
||||||
|
JSONArray jsonArray = new JSONArray(outputValueFixed);
|
||||||
|
System.out.println(jsonArray.length());
|
||||||
|
for(int j=0; j<jsonArray.length(); j++) {
|
||||||
|
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||||
|
String sensorTag = jsonobject.getString("sensortag");
|
||||||
|
int value = jsonobject.getInt("value");
|
||||||
|
System.out.println(sensorTag+":"+value);
|
||||||
|
sensorReadings.setSensorTag(sensorTag);
|
||||||
|
sensorReadings.setValue(value);
|
||||||
|
|
||||||
return y;
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
70B3D57050004223,70B3D570500042D7,70B3D57050004EEF,70B3D57050006223,70B3D5705000623C
|
70B3D57050004223,70B3D570500042D7,70B3D57050004EF4,70B3D57050006223,70B3D5705000623C
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
70B3D57050004682,70B3D570500046AB,70B3D57050004D14
|
70B3D57050004682,70B3D57050004D14
|
|
@ -1 +1 @@
|
||||||
PlixJiy6sktkQZcj1WJVqLZCR4abCgnNaMlG2DYGZ2ga75aOA00E9jTzBmSC88tw
|
CyGrh8jKqXXZCBgLzG6gnI6lMWGdzCjGW3LP9sPrH6FEu2M19UcOBF9PZaTJH963
|
|
@ -36,8 +36,8 @@ public class BoxCall4Partner {
|
||||||
String baseURL = userCredentials.getBaseURL();
|
String baseURL = userCredentials.getBaseURL();
|
||||||
String homeRoot = userCredentials.getHomeRoot();
|
String homeRoot = userCredentials.getHomeRoot();
|
||||||
|
|
||||||
String outputGeneral = null;
|
|
||||||
outputGeneral = GeneralCall4All.FetchAll(token);
|
String outputGeneral = GeneralCall4All.FetchAll(token);
|
||||||
JSONArray jsonarray = new JSONArray(outputGeneral);
|
JSONArray jsonarray = new JSONArray(outputGeneral);
|
||||||
|
|
||||||
cName = readFile.ReadFromFile(homeRoot +cName +".txt");
|
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);
|
String companyOutput = httpCall.HttpGet(baseURL + "devices/" + jsonID + "/sensors" + "?access_token=" + token, token);
|
||||||
listOfCompanyOutputs.add(companyOutput);
|
listOfCompanyOutputs.add(companyOutput);
|
||||||
writingIntoFile.WriteFile(homeRoot +i+" "+ cName + ".json", companyOutput);
|
writingIntoFile.WriteFile(homeRoot +i+" "+ cName + ".json", companyOutput);
|
||||||
|
System.out.println(listOfCompanyOutputs);
|
||||||
loopTerminator++;
|
loopTerminator++;
|
||||||
|
System.out.println(loopTerminator + " "+arrayOfCompany.length+" "+jsonarray.length()+" "+iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(loopTerminator == arrayOfCompany.length ){
|
if(loopTerminator == arrayOfCompany.length ){
|
||||||
|
System.out.println("Entered ");
|
||||||
return listOfCompanyOutputs;
|
return listOfCompanyOutputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,6 @@ import java.util.ArrayList;
|
||||||
///url/sensors/id/read
|
///url/sensors/id/read
|
||||||
|
|
||||||
public class ReadSensors4Partner {
|
public class ReadSensors4Partner {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String FetchSensor4Box(String companyName, String token) throws Exception {
|
public String FetchSensor4Box(String companyName, String token) throws Exception {
|
||||||
|
|
||||||
switch (companyName) {
|
switch (companyName) {
|
||||||
|
@ -40,19 +37,22 @@ public class ReadSensors4Partner {
|
||||||
|
|
||||||
BoxCall4Partner boxCall4Partner = new BoxCall4Partner();
|
BoxCall4Partner boxCall4Partner = new BoxCall4Partner();
|
||||||
String outputBox = boxCall4Partner.FetchBox(cName,token);
|
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);
|
JSONArray jsonArray = new JSONArray(outputBoxFixed);
|
||||||
|
System.out.println("The working array:"+jsonArray);
|
||||||
ArrayList<String> list=new ArrayList<String>();
|
ArrayList<String> list=new ArrayList<String>();
|
||||||
int loopTerminator = 0;
|
int loopTerminator = 0;
|
||||||
|
char par = '"';
|
||||||
for(int j=0; j<jsonArray.length(); j++){
|
for(int j=0; j<jsonArray.length(); j++){
|
||||||
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
JSONObject jsonobject = jsonArray.getJSONObject(j);
|
||||||
String jsonID = jsonobject.getString("id");
|
String jsonID = jsonobject.getString("id");
|
||||||
String jsonTag = jsonobject.getString("tag");
|
String jsonTag = jsonobject.getString("tag");
|
||||||
|
|
||||||
String sensorOutput = httpCall.HttpGet(baseURL + "sensors/" + jsonID + "/read" + "?access_token=" + token, token);
|
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);
|
writingIntoFile.WriteFile(homeRoot + jsonID + ".json", sensorOutput + jsonTag);
|
||||||
loopTerminator++;
|
loopTerminator++;
|
||||||
if(loopTerminator == jsonArray.length()){
|
if(loopTerminator == jsonArray.length()){
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
package JSON_Unpack;
|
|
||||||
|
|
||||||
public class Reading4AllSensors {
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package Knowledgebase;
|
package Knowledgebase;
|
||||||
|
|
||||||
import org.kie.api.KieServices;
|
import org.kie.api.KieServices;
|
||||||
|
import org.kie.api.KieServices.Factory;
|
||||||
import org.kie.api.runtime.KieContainer;
|
import org.kie.api.runtime.KieContainer;
|
||||||
import org.kie.api.runtime.KieSession;
|
import org.kie.api.runtime.KieSession;
|
||||||
import org.kie.api.runtime.rule.FactHandle;
|
import org.kie.api.runtime.rule.FactHandle;
|
||||||
|
@ -17,10 +18,12 @@ public class DroolsTest {
|
||||||
|
|
||||||
Product product = new Product();
|
Product product = new Product();
|
||||||
product.setType("gold");
|
product.setType("gold");
|
||||||
|
System.out.println(product.getDiscount());
|
||||||
|
|
||||||
FactHandle fact1;
|
FactHandle fact1;
|
||||||
|
|
||||||
fact1 = kSession.insert(product);
|
fact1 = kSession.insert(product);
|
||||||
|
System.out.println(fact1);
|
||||||
kSession.fireAllRules();
|
kSession.fireAllRules();
|
||||||
|
|
||||||
System.out.println("The discount for the jewellery product "
|
System.out.println("The discount for the jewellery product "
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
package Knowledgebase;
|
|
||||||
|
|
||||||
public class Plants {
|
|
||||||
private String plantType;
|
|
||||||
private String sensorTag;
|
|
||||||
private double outputValue;
|
|
||||||
|
|
||||||
public String getPlantType() {
|
|
||||||
return plantType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlantType(String plantType) {
|
|
||||||
this.plantType = plantType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSensorTag() {
|
|
||||||
return sensorTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSensorTag(String sensorTag) {
|
|
||||||
this.sensorTag = sensorTag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getOutputValue() {
|
|
||||||
return outputValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutputValue(double outputValue) {
|
|
||||||
this.outputValue = outputValue;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package Knowledgebase;
|
||||||
|
|
||||||
|
public class SensorReadings {
|
||||||
|
private String sensorTag;
|
||||||
|
private double value;
|
||||||
|
|
||||||
|
public String getSensorTag() {
|
||||||
|
return sensorTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSensorTag(String sensorTag) {
|
||||||
|
this.sensorTag = sensorTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(double value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
groupId=com.javainuse
|
||||||
|
artifactId=drools-hello-world
|
||||||
|
version=0.0.1-SNAPSHOT
|
|
@ -10,5 +10,5 @@ rule "Offer for Gold"
|
||||||
when
|
when
|
||||||
productObject: Product(type=="gold")
|
productObject: Product(type=="gold")
|
||||||
then
|
then
|
||||||
productObject.setDiscount(25);
|
productObject.setDiscount(10);
|
||||||
end
|
end
|
|
@ -1,14 +0,0 @@
|
||||||
import Knowledgebase.Product
|
|
||||||
|
|
||||||
rule "Offer for Diamond"
|
|
||||||
when
|
|
||||||
productObject: Product(type=="diamond")
|
|
||||||
then
|
|
||||||
productObject.setDiscount(15);
|
|
||||||
end
|
|
||||||
rule "Offer for Gold"
|
|
||||||
when
|
|
||||||
productObject: Product(type=="gold")
|
|
||||||
then
|
|
||||||
productObject.setDiscount(25);
|
|
||||||
end
|
|
Loading…
Reference in New Issue