small refactoring
This commit is contained in:
parent
08754d7adb
commit
4a9f08cbb7
3 changed files with 3 additions and 10 deletions
|
|
@ -67,7 +67,6 @@ public class HalContext {
|
|||
//Read DB conf
|
||||
if(firstTime){
|
||||
dbConf = new Properties();
|
||||
dbConf.put(PROPERTY_DB_VERSION, 0);
|
||||
}else{
|
||||
dbConf = db.exec("SELECT * FROM conf", new PropertiesSQLResult());
|
||||
}
|
||||
|
|
@ -77,11 +76,11 @@ public class HalContext {
|
|||
Properties defaultDBConf =
|
||||
referenceDB.exec("SELECT * FROM conf", new PropertiesSQLResult());
|
||||
// Check DB version
|
||||
logger.info("DB version: "+ dbConf.getProperty(PROPERTY_DB_VERSION));
|
||||
final int defaultDBVersion = Integer.parseInt(defaultDBConf.getProperty(PROPERTY_DB_VERSION));
|
||||
final int dbVersion = (dbConf.getProperty(PROPERTY_DB_VERSION) != null ?
|
||||
Integer.parseInt(dbConf.getProperty(PROPERTY_DB_VERSION)) :
|
||||
-1);
|
||||
logger.info("DB version: "+ dbVersion);
|
||||
if(defaultDBVersion > dbVersion ) {
|
||||
logger.info("Starting DB upgrade...");
|
||||
if(!firstTime){
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ public class EventConfigHttpPage extends HalHttpPage {
|
|||
if(request.containsKey("action")){
|
||||
int id = (request.containsKey("id") ? Integer.parseInt(request.get("id")) : -1);
|
||||
Event event;
|
||||
Configurator<HalEventData> configurator;
|
||||
switch(request.get("action")) {
|
||||
// Local events
|
||||
case "create_local_event":
|
||||
|
|
@ -61,9 +60,7 @@ public class EventConfigHttpPage extends HalHttpPage {
|
|||
event.setName(request.get("name"));
|
||||
event.setType(request.get("type"));
|
||||
event.setUser(localUser);
|
||||
configurator = event.getDeviceConfig();
|
||||
configurator.setValues(request);
|
||||
configurator.applyConfiguration();
|
||||
event.getDeviceConfig().setValues(request).applyConfiguration();
|
||||
event.save(db);
|
||||
ControllerManager.getInstance().register(event);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ public class SensorConfigHttpPage extends HalHttpPage {
|
|||
int id = (request.containsKey("id") ? Integer.parseInt(request.get("id")) : -1);
|
||||
Sensor sensor;
|
||||
User user;
|
||||
Configurator<HalSensorData> configurator;
|
||||
switch(request.get("action")) {
|
||||
// Local Sensors
|
||||
case "create_local_sensor":
|
||||
|
|
@ -63,9 +62,7 @@ public class SensorConfigHttpPage extends HalHttpPage {
|
|||
sensor.setType(request.get("type"));
|
||||
sensor.setSynced(Boolean.parseBoolean(request.get("sync")));
|
||||
sensor.setUser(localUser);
|
||||
configurator = sensor.getDeviceConfig();
|
||||
configurator.setValues(request);
|
||||
configurator.applyConfiguration();
|
||||
sensor.getDeviceConfig().setValues(request).applyConfiguration();
|
||||
sensor.save(db);
|
||||
ControllerManager.getInstance().register(sensor);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue