Peer data sync bugfix
Former-commit-id: d89c27cd778f3bbe26bb256e6a2ce51a786dd7c2
This commit is contained in:
parent
1d57b3f1dd
commit
d1696cd32d
4 changed files with 7 additions and 9 deletions
|
|
@ -57,7 +57,7 @@ public class PCDataSynchronizationClient implements HalDaemon {
|
|||
user.save(db);
|
||||
|
||||
for(SensorDTO sensorDTO : peerData.sensors){
|
||||
Sensor sensor = Sensor.getExternalSensor(db, sensorDTO.sensorId);
|
||||
Sensor sensor = Sensor.getExternalSensor(db, user, sensorDTO.sensorId);
|
||||
if(sensor != null) { // new sensor
|
||||
sensor = new Sensor();
|
||||
logger.fine("Created new external sensor with external_id: "+ sensorDTO.sensorId);
|
||||
|
|
@ -68,6 +68,7 @@ public class PCDataSynchronizationClient implements HalDaemon {
|
|||
sensor.setName(sensorDTO.name);
|
||||
sensor.setType(sensorDTO.type);
|
||||
sensor.setConfig(sensorDTO.config);
|
||||
sensor.setUser(user);
|
||||
sensor.save(db);
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +92,7 @@ public class PCDataSynchronizationClient implements HalDaemon {
|
|||
stmt.setFloat(6, data.confidence);
|
||||
DBConnection.exec(stmt);
|
||||
}
|
||||
logger.fine("Stored " + dataList.size() + " entries for sensor " + sensor.getId() + " from " + user.getUserName());
|
||||
logger.fine("Stored " + dataList.size() + " entries for sensor " + sensor.getId() + " with offset "+ req.offsetSequenceId +" from " + user.getUserName());
|
||||
}
|
||||
else
|
||||
logger.fine("Skipped sensor " + sensor.getId());
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ public class EventConfigHttpPage extends HalHttpPage {
|
|||
tmpl.set("localEventConf", eventConfigurations);
|
||||
tmpl.set("detectedEvents", ControllerManager.getInstance().getDetectedEvents());
|
||||
|
||||
|
||||
tmpl.set("availableEvents", ControllerManager.getInstance().getAvailableEvents());
|
||||
|
||||
return tmpl;
|
||||
|
|
|
|||
|
|
@ -45,9 +45,10 @@ public class Sensor extends DBBean{
|
|||
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor,user WHERE user.external == 1 AND user.id == sensor.user_id" );
|
||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Sensor.class, db) );
|
||||
}
|
||||
public static Sensor getExternalSensor(DBConnection db, long id) throws SQLException{
|
||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor,user WHERE user.external == 1 AND user.id == sensor.user_id AND sensor.external_id == ?" );
|
||||
stmt.setLong(1, id);
|
||||
public static Sensor getExternalSensor(DBConnection db, User user, long id) throws SQLException{
|
||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT sensor.* FROM sensor WHERE user.external == 1 AND ? == sensor.user_id AND sensor.external_id == ?" );
|
||||
stmt.setLong(1, user.getId());
|
||||
stmt.setLong(2, id);
|
||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.create(Sensor.class, db) );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Public</th>
|
||||
<th>Configuration</th>
|
||||
<th>
|
||||
<button class="btn btn-default btn-xs pull-right" data-toggle="modal"
|
||||
|
|
@ -23,7 +22,6 @@
|
|||
<tr>
|
||||
<td>{{.name}}</td>
|
||||
<td>{{.type}}</td>
|
||||
<td>{{.sync}}</td>
|
||||
<td>{{.config}}</td>
|
||||
<td>
|
||||
<form method="POST">
|
||||
|
|
@ -36,7 +34,6 @@
|
|||
data-id="{{.getId()}}"
|
||||
data-name="{{.name}}"
|
||||
data-type="{{.type}}"
|
||||
data-sync="{{.sync}}"
|
||||
data-config="{{.config}}">
|
||||
<span class="glyphicon glyphicon-pencil"></span>
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue