|
|
@@ -11,6 +11,7 @@ import cz.hsrs.db.model.NoItemFoundException;
|
|
|
import cz.hsrs.db.model.Phenomenon;
|
|
|
import cz.hsrs.db.model.Sensor;
|
|
|
import cz.hsrs.db.model.insert.UnitInsert;
|
|
|
+import cz.hsrs.db.pool.SQLExecutor;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -40,8 +41,13 @@ public class ManagementUtil extends DBUtil {
|
|
|
|
|
|
for (Sensor sensor : sensors) {
|
|
|
long sensorId = sensor.getSensorId();
|
|
|
+ String del = "DELETE FROM units_to_sensors WHERE sensor_id = "+sensorId + " AND unit_id = " + unitId;
|
|
|
+ int result = SQLExecutor.executeUpdate(del);
|
|
|
|
|
|
- // TODO delete sensor in the database
|
|
|
+ // TODO delete sensor in the database
|
|
|
+ //- delete sensor pokud je pouze u teto jednotky
|
|
|
+ //- delete pouze units_to_sensors pokud je u vice jednotek - typ senzoru - OK
|
|
|
+
|
|
|
|
|
|
}
|
|
|
return new UnitInsert(unitId, null, sensors);
|
|
|
@@ -115,7 +121,7 @@ public class ManagementUtil extends DBUtil {
|
|
|
|
|
|
for (Sensor sensor : sensors) {
|
|
|
long sensorId = sensor.getSensorId();
|
|
|
-
|
|
|
+ // 2. iterace
|
|
|
// TODO UPDATE sensor attribute in the database
|
|
|
|
|
|
}
|
|
|
@@ -133,6 +139,8 @@ public class ManagementUtil extends DBUtil {
|
|
|
throw new NoItemFoundException("Attribute 'unit_id' is required.");
|
|
|
}
|
|
|
long unitId = unitJson.getLong("unit_id");
|
|
|
+ String updUnit = "UPDATE units SET description = '"+unitJson.getString("description")+"' WHERE unit_id = "+unitId;
|
|
|
+ int result = SQLExecutor.executeUpdate(updUnit);
|
|
|
|
|
|
// TODO UPDATE unit attributes in the database
|
|
|
|