class DBReportManager extends DBManager<Report> implements ReportManager {

    @Override
    @SuppressWarnings("checkstyle:parameternumber")
    public final FilteredRecordsList<IMAMeasurementRecord> getOrderedRecordList(
            final IMARecordScope scope,
            final String id,
            final boolean sinceLastFullReport,
            final IMARecordField columnToOrder,
            final boolean ascending,
            final int firstResult,
            final int maxResults,
            final String search)
            throws ReportManagerException {

        // check columnToOrder
        if (columnToOrder == null) {
            final String msg = "columnToOrder cannot be null";
            LOGGER.error(msg);
            throw new IllegalArgumentException(msg);
        }

        // check scope
        if (scope == null) {
            throw new IllegalArgumentException("IMARecordScope cannot be null");
        }

        Transaction tx = null;
        Session session = getFactory().getCurrentSession();
        try {
            tx = session.beginTransaction();

            final DbImaRecordQueryParameters params
                    = new DbImaRecordQueryParameters(id, columnToOrder, ascending,
                            firstResult, maxResults, search);

            switch (scope) {
                case NONE:
                    return new DbImaRecordQueryForNone().query();
                case REPORT:
                    return new DbImaRecordQueryForReport(session, params).query();
                case DEVICE:
                    if (sinceLastFullReport) {
                        DbImaRecordQueryForDeviceSinceLastFullReport q
                                = new DbImaRecordQueryForDeviceSinceLastFullReport(session, params);
                        return q.query();
                    } else {
                        return new DbImaRecordQueryForDevice(session, params).query();
                    }
                default:
                    throw new UnsupportedOperationException(
                            "IMARecordScope " + scope + " is not supported");
            }

        } catch (Exception ex) {
            String msg = "Error executing IMA Record query for " + scope + " scope.";
            if (scope == IMARecordScope.DEVICE) {
                msg += "Since last full report = " + sinceLastFullReport;
            }
            LOGGER.error(msg, ex);
            throw ex;
        } finally {
            if (tx != null) {
                tx.rollback();
            }
        }

    }

    public  DBReportManager(final SessionFactory sessionFactory);

}