@Repository
public class SensorRepository
extends java.lang.Object
SensorEntity
Modifier and Type | Field | Description |
---|---|---|
private static org.apache.log4j.Logger |
logger |
|
private org.hibernate.SessionFactory |
sessionFactory |
Constructor | Description |
---|---|
SensorRepository() |
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
Delete all entries in sensor table.
|
SensorEntity |
get(java.lang.String sensorIp) |
Get a
SensorEntity instance for the input sensor IP. |
java.util.List<SensorEntity> |
getAll() |
Fetch all entries in sensor table, ordered by sensor name.
|
java.util.List<SensorEntity> |
getAll(java.lang.String borderRouterIp) |
Fetch all entries of sensors that connected to the input border router.
|
java.util.List<java.lang.String> |
getAllSensorIp() |
Get all sensor IP from the database.
|
java.lang.String |
save(SensorEntity sensorEntity) |
Save the input sensorEntity in database.
|
long |
size() |
Get the total number of entries of sensor.
|
boolean |
updateSensorName(java.lang.String sensorIp,
java.lang.String sensorName) |
Update the name of a sensor.
|
@Autowired private org.hibernate.SessionFactory sessionFactory
private static final org.apache.log4j.Logger logger
public boolean updateSensorName(java.lang.String sensorIp, java.lang.String sensorName)
sensorIp
- IP of the sensor you want to update.sensorName
- The name you want to update for the sensor.true
for success, false
otherwise.public SensorEntity get(java.lang.String sensorIp)
SensorEntity
instance for the input sensor IP.
Return null
if the input sensor IP doesn't exist in database.sensorIp
- The IPv6 address of the sensor you want to get.SensorEntity
public long size()
public java.lang.String save(SensorEntity sensorEntity)
NullPointerException
if the input sensorEntity is null
.sensorEntity
- Instance of SensorEntity
for the sensor
you want to save.public void clear()
public java.util.List<SensorEntity> getAll()
SensorEntity
.public java.util.List<java.lang.String> getAllSensorIp()
String
contains all sensor IP.public java.util.List<SensorEntity> getAll(java.lang.String borderRouterIp)
borderRouterIp
doesn't exist
in database.borderRouterIp
- The IPv6 address of the border router to which the
sensors are connected.SensorEntity
.