From a8a5564078e9a6d468fb9723c27d964a6c65b3cb Mon Sep 17 00:00:00 2001 From: lukasgol Date: Mon, 26 Jan 2015 23:45:20 +0100 Subject: [PATCH] sensory get all general --- .../bazy/controllers/SensorsController.java | 5 + .../edu/bazy/dbApi/sensors/SensorsDbApi.java | 4 + .../agh/edu/bazy/path/APIServicePaths.java | 1 + .../mappers/sensors/SensorsRowMapper_new.java | 48 ++++ .../agh/edu/bazy/row/sensors/Sensor_new.java | 256 ++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 src/main/java/hello/agh/edu/bazy/row/mappers/sensors/SensorsRowMapper_new.java create mode 100644 src/main/java/hello/agh/edu/bazy/row/sensors/Sensor_new.java diff --git a/src/main/java/hello/agh/edu/bazy/controllers/SensorsController.java b/src/main/java/hello/agh/edu/bazy/controllers/SensorsController.java index 43747b2..5202b7e 100644 --- a/src/main/java/hello/agh/edu/bazy/controllers/SensorsController.java +++ b/src/main/java/hello/agh/edu/bazy/controllers/SensorsController.java @@ -128,6 +128,11 @@ public class SensorsController { List getTemperatureById(@PathVariable("id") int id) { return sensorsDbApi.getTemperatureById(id); } + @RequestMapping(value = APIServicePaths.GET_ALL_GENERAL) + @ResponseBody + List getAllGeneral() { + return sensorsDbApi.getAllGeneral(); + } } diff --git a/src/main/java/hello/agh/edu/bazy/dbApi/sensors/SensorsDbApi.java b/src/main/java/hello/agh/edu/bazy/dbApi/sensors/SensorsDbApi.java index 5d28877..475e74e 100644 --- a/src/main/java/hello/agh/edu/bazy/dbApi/sensors/SensorsDbApi.java +++ b/src/main/java/hello/agh/edu/bazy/dbApi/sensors/SensorsDbApi.java @@ -36,6 +36,7 @@ public class SensorsDbApi { private static final String GET_ALL_SPEED_ID = "SELECT * FROM speedFamily nt WHERE nt.deviceSpecificationId = ?"; private static final String GET_ALL_QUEUE_ID = "SELECT * FROM queueFamily nt WHERE nt.deviceSpecificationId = ?"; private static final String GET_ALL_COUNTER_ID = "SELECT * FROM counterFamily nt WHERE nt.deviceSpecificationId = ?"; + private static final String GET_ALL_GENERAL = "SELECT sd.*, at.name as areaTypeName FROM sensorDevices sd LEFT JOIN deviceSpecifications ds ON sd.id = ds.sensorDevice_id LEFT JOIN areatypes at ON ds.areatype_id = at.id"; private static final String OBJECT_COLUM_NNAME = "name"; @@ -85,6 +86,9 @@ public class SensorsDbApi { public List getObjectsDetail() { return sensorsJdbcTemplate.query(GET_ALL_DETAIL_OBJECTS,new SensorsRowMapper()); } + public List getAllGeneral() { + return sensorsJdbcTemplate.query(GET_ALL_GENERAL,new SensorsRowMapper_new()); + } public List getClocks() { diff --git a/src/main/java/hello/agh/edu/bazy/path/APIServicePaths.java b/src/main/java/hello/agh/edu/bazy/path/APIServicePaths.java index 6042cf8..373777e 100644 --- a/src/main/java/hello/agh/edu/bazy/path/APIServicePaths.java +++ b/src/main/java/hello/agh/edu/bazy/path/APIServicePaths.java @@ -42,6 +42,7 @@ public final class APIServicePaths { public static final String GET_QUEUE = "/queue"; public static final String GET_SPEED = "/speed"; public static final String GET_TEMPERATURE = "/temperature"; + public static final String GET_ALL_GENERAL = "/getallgeneral"; //PROFILE public static final String PROFILE_CONTROLLER = "/profile"; diff --git a/src/main/java/hello/agh/edu/bazy/row/mappers/sensors/SensorsRowMapper_new.java b/src/main/java/hello/agh/edu/bazy/row/mappers/sensors/SensorsRowMapper_new.java new file mode 100644 index 0000000..c06dada --- /dev/null +++ b/src/main/java/hello/agh/edu/bazy/row/mappers/sensors/SensorsRowMapper_new.java @@ -0,0 +1,48 @@ +package hello.agh.edu.bazy.row.mappers.sensors; + +import hello.agh.edu.bazy.row.sensors.Sensor; +import hello.agh.edu.bazy.row.sensors.Sensor_new; +import org.springframework.jdbc.core.RowMapper; + +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Created by lukasgol on 24.01.15. + */ +public class SensorsRowMapper_new implements RowMapper { + + + @Override + public Sensor_new mapRow(ResultSet rs, int rowNum) throws SQLException { + Sensor_new sensor=new Sensor_new(); + sensor.setSensorId(rs.getInt("id")); + sensor.setName(rs.getString("name")); + sensor.setProducer(rs.getString("producer")); + sensor.setModel(rs.getString("Model")); + sensor.setDimensions(rs.getString("dimensions")); + sensor.setWeight(rs.getString("weight")); + sensor.setWirelessradiofrequency(rs.getString("wirelessradiofrequency")); + sensor.setWirelessprotocol(rs.getString("wirelessprotocol")); + sensor.setBluetooth(rs.getString("bluetooth")); + sensor.setAvglifespan(rs.getFloat("avglifespan")); + sensor.setCommunicatedistancemeters(rs.getInt("communicatedistancemeters")); + sensor.setInstallingtime(rs.getString("installingtime")); + sensor.setProtectionstandard(rs.getString("protectionstandard")); + sensor.setProtectionstandard(rs.getString("protectionstandard")); + sensor.setWorkcondition(rs.getString("workcondition")); + sensor.setOperationmintemperature(rs.getFloat("operationmintemperature")); + sensor.setOperationmaxtemperature(rs.getFloat("operationmaxtemperature")); + sensor.setOperationmaxhumidity(rs.getFloat("operationmaxhumidity")); + sensor.setStoragemintemparature(rs.getFloat("storagemintemparature")); + sensor.setStoragemaxtemperature(rs.getFloat("storagemaxtemperature")); + sensor.setPowersupply(rs.getString("powersupply")); + sensor.setBatterypower(rs.getString("batterypower")); + sensor.setBatterylife(rs.getString("batterylife")); + sensor.setWirelessupdate(rs.getString("wirelessupdate")); + + sensor.setAreatypename(rs.getString("areatypename")); + return sensor; + } + +} diff --git a/src/main/java/hello/agh/edu/bazy/row/sensors/Sensor_new.java b/src/main/java/hello/agh/edu/bazy/row/sensors/Sensor_new.java new file mode 100644 index 0000000..974e1b8 --- /dev/null +++ b/src/main/java/hello/agh/edu/bazy/row/sensors/Sensor_new.java @@ -0,0 +1,256 @@ +package hello.agh.edu.bazy.row.sensors; + +/** + * Created by lukasgol on 24.01.15. + */ +public class Sensor_new { + int SensorId; + String name; + String producer; + String model; + String dimensions; + String weight; + String wirelessradiofrequency; + String wirelessprotocol; + String bluetooth; + float avglifespan; + int communicatedistancemeters; + String installingtime; + String protectionstandard; + String workcondition; + float operationmintemperature; + float operationmaxtemperature; + float operationmaxhumidity; + float storagemintemparature; + float storagemaxtemperature; + String powersupply; + String batterypower; + String batterylife; + String wirelessupdate; + String areatypename; + + public Sensor_new() { + + } + + public int getSensorId() { + return SensorId; + } + + public void setSensorId(int sensorId) { + SensorId = sensorId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getProducer() { + return producer; + } + + public void setProducer(String producer) { + this.producer = producer; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getDimensions() { + return dimensions; + } + + public void setDimensions(String dimensions) { + this.dimensions = dimensions; + } + + public String getWeight() { + return weight; + } + + public void setWeight(String weight) { + this.weight = weight; + } + + public String getWirelessradiofrequency() { + return wirelessradiofrequency; + } + + public void setWirelessradiofrequency(String wirelessradiofrequency) { + this.wirelessradiofrequency = wirelessradiofrequency; + } + + public String getWirelessprotocol() { + return wirelessprotocol; + } + + public void setWirelessprotocol(String wirelessprotocol) { + this.wirelessprotocol = wirelessprotocol; + } + + public String getBluetooth() { + return bluetooth; + } + + public void setBluetooth(String bluetooth) { + this.bluetooth = bluetooth; + } + + public float getAvglifespan() { + return avglifespan; + } + + public void setAvglifespan(float avglifespan) { + this.avglifespan = avglifespan; + } + + public int getCommunicatedistancemeters() { + return communicatedistancemeters; + } + + public void setCommunicatedistancemeters(int communicatedistancemeters) { + this.communicatedistancemeters = communicatedistancemeters; + } + + public String getInstallingtime() { + return installingtime; + } + + public void setInstallingtime(String installingtime) { + this.installingtime = installingtime; + } + + public String getProtectionstandard() { + return protectionstandard; + } + + public void setProtectionstandard(String protectionstandard) { + this.protectionstandard = protectionstandard; + } + + public String getWorkcondition() { + return workcondition; + } + + public void setWorkcondition(String workcondition) { + this.workcondition = workcondition; + } + + public float getOperationmintemperature() { + return operationmintemperature; + } + + public void setOperationmintemperature(float operationmintemperature) { + this.operationmintemperature = operationmintemperature; + } + + public float getOperationmaxtemperature() { + return operationmaxtemperature; + } + + public void setOperationmaxtemperature(float operationmaxtemperature) { + this.operationmaxtemperature = operationmaxtemperature; + } + + public float getOperationmaxhumidity() { + return operationmaxhumidity; + } + + public void setOperationmaxhumidity(float operationmaxhumidity) { + this.operationmaxhumidity = operationmaxhumidity; + } + + public float getStoragemintemparature() { + return storagemintemparature; + } + + public void setStoragemintemparature(float storagemintemparature) { + this.storagemintemparature = storagemintemparature; + } + + public float getStoragemaxtemperature() { + return storagemaxtemperature; + } + + public void setStoragemaxtemperature(float storagemaxtemperature) { + this.storagemaxtemperature = storagemaxtemperature; + } + + public String getPowersupply() { + return powersupply; + } + + public void setPowersupply(String powersupply) { + this.powersupply = powersupply; + } + + public String getBatterypower() { + return batterypower; + } + + public void setBatterypower(String batterypower) { + this.batterypower = batterypower; + } + + public String getBatterylife() { + return batterylife; + } + + public void setBatterylife(String batterylife) { + this.batterylife = batterylife; + } + + public String getWirelessupdate() { + return wirelessupdate; + } + + public void setWirelessupdate(String wirelessupdate) { + this.wirelessupdate = wirelessupdate; + } + + public String getAreatypename() { + return areatypename; + } + + public void setAreatypename(String areatypename) { + this.areatypename = areatypename; + } + + @Override + public String toString() { + return "Sensor{" + + "SensorId=" + SensorId + + ", name='" + name + '\'' + + ", producer='" + producer + '\'' + + ", model='" + model + '\'' + + ", dimensions='" + dimensions + '\'' + + ", weight='" + weight + '\'' + + ", wirelessradiofrequency='" + wirelessradiofrequency + '\'' + + ", wirelessprotocol='" + wirelessprotocol + '\'' + + ", bluetooth='" + bluetooth + '\'' + + ", avglifespan=" + avglifespan + + ", communicatedistancemeters=" + communicatedistancemeters + + ", installingtime='" + installingtime + '\'' + + ", protectionstandard='" + protectionstandard + '\'' + + ", workcondition='" + workcondition + '\'' + + ", operationmintemperature=" + operationmintemperature + + ", operationmaxtemperature=" + operationmaxtemperature + + ", operationmaxhumidity=" + operationmaxhumidity + + ", storagemintemparature=" + storagemintemparature + + ", storagemaxtemperature=" + storagemaxtemperature + + ", powersupply='" + powersupply + '\'' + + ", batterypower='" + batterypower + '\'' + + ", batterylife='" + batterylife + '\'' + + ", wirelessupdate='" + wirelessupdate + '\''+ + '}'; + } +}