def is_esp_id_present_in_volume(self, esp_id): vols = VOLUMEdata.query.filter_by(esp_id=esp_id).all() db_session.commit() if (len(vols) == 0): return False else: return True
def is_esp_id_present(self, esp_id): esps = ESPdata.query.filter_by(esp_id=esp_id).all() db_session.commit() if (len(esps) == 0): return False else: return True
def update_registered_esp_volume_data(self, volume_data): count = VOLUMEdata.query.filter_by(esp_id=volume_data.esp_id).count() db_session.commit() if (count == 0): return obj = VOLUMEdata.query.filter_by(esp_id=volume_data.esp_id).one() if (obj is not None): print("tnt") db_session.delete(obj) db_session.commit() self.save_volume_data(volume_data)
def update_registered_esp(self, esp_to_update): count = ESPdata.query.filter_by(esp_id=esp_to_update.esp_id).count() db_session.commit() if (count == 0): return obj = ESPdata.query.filter_by(esp_id=esp_to_update.esp_id).one() if (obj is not None): print("tnt") db_session.delete(obj) db_session.commit() self.register_esp(esp_to_update)
def register_esp(self, esp_to_register): #Map ESP_data object into ESPdata entity esp_id = esp_to_register.esp_id esp_ip = esp_to_register.esp_ip x = esp_to_register.x y = esp_to_register.y esp_type = esp_to_register.type side = esp_to_register.side location = esp_to_register.location #Create ESPdata db entity sqlESPdata = ESPdata(esp_id, esp_ip, x, y, esp_type, side, location) db_session.add(sqlESPdata) db_session.commit()
def delete_all_ESPs(self): num_rows_deleted = db_session.query(ESPdata).delete() db_session.commit() return num_rows_deleted
def delete_all_volumes(self): num_rows_deleted = db_session.query(VOLUMEdata).delete() db_session.commit() return num_rows_deleted
def save_volume_data(self, volume_data): sqlVOLUMEdata = VOLUMEdata(volume_data.esp_id, volume_data.timestamp, volume_data.delay, volume_data.volume) db_session.add(sqlVOLUMEdata) db_session.commit()