Exemple #1
0
def find_all_by_destination(session, destination, destination_id):
    if not QueryHelper.destination_exists(destination):
        return []

    query = QueryHelper(session).select_destination(destination, destination_id)

    func_key_rows = query.all()
    return [db_converter.to_model(row) for row in func_key_rows]
Exemple #2
0
def get(session, func_key_id):
    query = QueryHelper(session).select_func_key(func_key_id)
    row = query.first()

    if not row:
        raise errors.not_found('FuncKey', id=func_key_id)

    return db_converter.to_model(row)
Exemple #3
0
def get(session, func_key_id):
    query = QueryHelper(session).select_func_key(func_key_id)
    row = query.first()

    if not row:
        raise ElementNotExistsError('FuncKey')

    return db_converter.to_model(row)
Exemple #4
0
def get(session, func_key_id):
    query = QueryHelper(session).select_func_key(func_key_id)
    row = query.first()

    if not row:
        raise ElementNotExistsError('FuncKey')

    return db_converter.to_model(row)
Exemple #5
0
def delete(session, func_key):
    helper = QueryHelper(session)
    func_key_query = helper.delete_func_key(func_key.id)
    destination_query = helper.delete_destination(func_key.destination,
                                                  func_key.destination_id)

    with commit_or_abort(session, DataError.on_delete, 'FuncKey'):
        destination_query.delete()
        func_key_query.delete()
Exemple #6
0
def delete(session, func_key):
    helper = QueryHelper(session)
    func_key_query = helper.delete_func_key(func_key.id)
    destination_query = helper.delete_destination(func_key.destination,
                                                  func_key.destination_id)

    with commit_or_abort(session, ElementDeletionError, 'FuncKey'):
        destination_query.delete()
        func_key_query.delete()
Exemple #7
0
def find_all_by_destination(session, destination, destination_id):
    if not QueryHelper.destination_exists(destination):
        return []

    query = QueryHelper(session).select_destination(destination,
                                                    destination_id)

    func_key_rows = query.all()
    return [db_converter.to_model(row) for row in func_key_rows]
Exemple #8
0
def search(session, **parameters):
    rows, total = QueryHelper(session).search(parameters)

    func_keys = [db_converter.to_model(row) for row in rows]
    return SearchResult(total, func_keys)