def add_immobile_object(data): db_wrapper = DBWrapper() result = db_wrapper.execute( Q.ADD_IMMOBILE_OBJECT % (data['name'], data.get( 'phone', ''), data['latitude'], data['longitude'])) db_wrapper.dispose() return result
def update_immobile_object(id, data): db_wrapper = DBWrapper() result = db_wrapper.execute( Q.UPDATE_IMMOBILE_OBJECT % (data['name'], data.get( 'phone', ''), data['latitude'], data['longitude'], id)) db_wrapper.dispose() return result
def search_movables_objects(pattern): db_wrapper = DBWrapper() objects = db_wrapper.fetch_all( Q.SEARCH_MOVABLES.replace('PATTERN', pattern.strip().lower())) db_wrapper.dispose() return map(converters.convert_movable, objects)
def add_location_point(movable_object_id, hour, minute, second, latitude, longitude): db_wrapper = DBWrapper() result = db_wrapper.execute( Q.ADD_LOCATION_POINT % (movable_object_id, hour, minute, second, latitude, longitude)) db_wrapper.dispose() return result
def add_movable_object(movable_type_id, data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.ADD_MOVABLE_OBJECT % (data['name'], movable_type_id)) db_wrapper.dispose() return result
def add_movable_type(data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.ADD_MOVABLE_TYPE % (data['name'])) db_wrapper.dispose() return result
def update_movable_type(id, data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.UPDATE_MOVABLE_TYPE % (data['name'], id)) db_wrapper.dispose() return result
def update_movable_object(id, movable_type_id, data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.UPDATE_MOVABLE_OBJECT % (data['name'], movable_type_id, id)) db_wrapper.dispose() return result
def get_immobile_object(id): db_wrapper = DBWrapper() result = db_wrapper.fetch_one(Q.GET_IMMOBILE_OBJECT % id) db_wrapper.dispose() return converters.convert_immobile(result)
def add_location_point(movable_object_id , hour, minute, second, latitude, longitude): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.ADD_LOCATION_POINT % (movable_object_id , hour, minute, second, latitude, longitude)) db_wrapper.dispose() return result
def get_movable_type(id): db_wrapper = DBWrapper() result = db_wrapper.fetch_one(Q.GET_MOVABLE_TYPE % id) db_wrapper.dispose() return converters.convert_movable_type(result)
def delete_movable_type(id): db_wrapper = DBWrapper() db_wrapper.execute(Q.DELETE_MOVABLE_TYPE % id) db_wrapper.dispose() return True
def update_movable_object(id, movable_type_id, data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.UPDATE_MOVABLE_OBJECT % (data['name'],movable_type_id, id)) db_wrapper.dispose() return result
def get_movable_object(id): db_wrapper = DBWrapper() result = db_wrapper.fetch_one(Q.GET_MOVABLE_OBJECT % id) db_wrapper.dispose() return converters.convert_movable(result)
def delete_all_location_points_for(id): db_wrapper = DBWrapper() db_wrapper.execute(Q.DELETE_LOCATION_POINTS_FOR % id) db_wrapper.dispose()
def get_all_movable_types(): db_wrapper = DBWrapper() movable_types = db_wrapper.fetch_all(Q.SELECT_ALL_MOVABLE_TYPES) db_wrapper.dispose() return map(converters.convert_movable_type, movable_types)
def delete_immobile_object(id): db_wrapper = DBWrapper() db_wrapper.execute(Q.DELETE_IMMOBILE_OBJECT % id) db_wrapper.dispose() return True
def get_all_immobiles_objects(): db_wrapper = DBWrapper() immobiles = db_wrapper.fetch_all(Q.SELECT_ALL_IMMOBILES) db_wrapper.dispose() return map(converters.convert_immobile, immobiles)
def update_immobile_object(id, data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.UPDATE_IMMOBILE_OBJECT % (data['name'], data.get('phone', ''), data['latitude'], data['longitude'], id)) db_wrapper.dispose() return result
def get_all_location_points(): db_wrapper = DBWrapper() lps = db_wrapper.fetch_all(Q.SELECT_ALL_LOCATION_POINTS) db_wrapper.dispose() return map(converters.convert_point, lps)
def delete_movable_object(id): db_wrapper = DBWrapper() db_wrapper.execute(Q.DELETE_MOVABLE_OBJECT % id) db_wrapper.dispose() return True
def search_movables_objects(pattern): db_wrapper = DBWrapper() objects = db_wrapper.fetch_all(Q.SEARCH_MOVABLES.replace('PATTERN', pattern.strip().lower())) db_wrapper.dispose() return map(converters.convert_movable, objects)
def add_immobile_object(data): db_wrapper = DBWrapper() result = db_wrapper.execute(Q.ADD_IMMOBILE_OBJECT % (data['name'], data.get('phone', ''), data['latitude'], data['longitude'])) db_wrapper.dispose() return result
def get_all_location_points_for(id): points = () db_wrapper = DBWrapper() points = db_wrapper.fetch_all(Q.LOCATION_POINTS_FOR % id) db_wrapper.dispose() return map(converters.convert_point, points)