import java.util.List; import java.util.HashMap; import java.util.Map; import java.util.Iterator; import eu.hsrw.ias.ggd.ScheduledTask import eu.hsrw.ias.ggd.SensorData import javax.swing.JOptionPane import HttpCall.HttpPost import Files.ReadFile import Credentials.UserCredentials; rule "Temperature Check" when // This is like declaring a variable tMap where is Map and contains a key with name battery $tMap: HashMap( containsKey("temperature") == true ) //In this part we are iterating through the entire map e: Map.Entry(k:key, v:value) from $tMap.entrySet() // for(e <- $tMap) { SensorData(level: value ) from v SensorData(tag: sensorTag) from v SensorData(id: deviceId) from v then String fixedIdG1="8bdbe6ae-eafb-4e99-bb01-db8784dd9633"; HttpPost httpPost = new HttpPost(); if (level > 80 && k.equals("temperature") ) { JOptionPane.showMessageDialog(null,"High Temperature : "+level+" in the following sensor: "+tag+"in the following device id: "+id,"Temperature",JOptionPane.INFORMATION_MESSAGE); final String data = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"High Temperature %s in the following sensor: %s \", \"temperature\": %s}]}}", fixedIdG1,level, tag,level); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data); System.out.println("High Temp"); } else if(level < 20 && k.equals("temperature")){ JOptionPane.showMessageDialog(null,"Low Temperature : "+level+" in the following sensor: "+tag+"in the following device id: "+id,"Temperature",JOptionPane.INFORMATION_MESSAGE); final String data1 = String.format("{\"id\":\"%s\",\"data\":{\"measured\":[{ \"status\": \"Low Temperature %s in the following sensor: %s \", \"temperature\": %s}]}}",fixedIdG1,level, tag,level); httpPost.HttpCallPost("http://connector.dev.whysor.com/default/insert?access_token=3hosOhAeh4k0XmcuAMQGfYldvTuQDvtAj2PJJ4irKPBefD5Ijij6gnUkLtVLd4fW",data1); System.out.println("Low Temp "+tag); } end