Example usage for org.hibernate Query setFirstResult

List of usage examples for org.hibernate Query setFirstResult

Introduction

In this page you can find the example usage for org.hibernate Query setFirstResult.

Prototype

@Override
    Query<R> setFirstResult(int startPosition);

Source Link

Usage

From source file:com.lp.server.finanz.fastlanereader.ErgebnisgruppeHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;//  ww w  .j a va 2 s  .c o  m
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzErgebnisgruppe ergebnisgruppe = (FLRFinanzErgebnisgruppe) resultListIterator.next();
            rows[row][INDEX_ID] = ergebnisgruppe.getI_id();
            // switch (ergebnisgruppe.getI_typ().intValue()) {
            // case FinanzFac.ERGEBNISGRUPPE_TYP_ERGEBNISGRUPPE: {
            rows[row][INDEX_BEZ] = ergebnisgruppe.getC_bez();
            if (ergebnisgruppe.getFlrergebnisgruppe_summe() != null) {
                rows[row][INDEX_SUMMENGRUPPE] = ergebnisgruppe.getFlrergebnisgruppe_summe().getC_bez();
            } else {
                rows[row][INDEX_SUMMENGRUPPE] = "";
            }
            rows[row][INDEX_SUMMENNEG] = Helper.short2Boolean(ergebnisgruppe.getB_summe_negativ());
            rows[row][INDEX_INVERTIERT] = Helper.short2Boolean(ergebnisgruppe.getB_invertiert());
            rows[row][INDEX_PROZENTBASIS] = Helper.short2Boolean(ergebnisgruppe.getB_prozentbasis());
            // }
            // break;
            // case FinanzFac.ERGEBNISGRUPPE_TYP_LEEREZEILE: {
            // rows[row][INDEX_BEZ] =
            // getSystemMultilanguageFac().uebersetzePositionsartOptimal(
            // LocaleFac.POSITIONSART_LEERZEILE, theClientDto.getLocUi(),
            // theClientDto.getLocMandant());
            // rows[row][INDEX_SUMMENGRUPPE] = "";
            // rows[row][INDEX_SUMMENNEG] = Boolean.FALSE;
            // rows[row][INDEX_INVERTIERT] = Boolean.FALSE;
            // rows[row][col++] = Boolean.FALSE;
            // }
            // break;
            // case FinanzFac.ERGEBNISGRUPPE_TYP_LINIE: {
            // rows[row][INDEX_BEZ] =
            // "-----------------------------------------------------------------------------------------------"
            // ;
            // rows[row][INDEX_SUMMENGRUPPE] =
            // "-----------------------------------------------------------------------------------------------"
            // ;
            // rows[row][INDEX_SUMMENNEG] = Boolean.FALSE;
            // rows[row][INDEX_INVERTIERT] = Boolean.FALSE;
            // rows[row][col++] = Boolean.FALSE;
            // }
            // break;
            // case FinanzFac.ERGEBNISGRUPPE_TYP_SEITENUMBRUCH: {
            // rows[row][INDEX_BEZ] =
            // getSystemMultilanguageFac().uebersetzePositionsartOptimal(
            // LocaleFac.POSITIONSART_SEITENUMBRUCH,
            // theClientDto.getLocUi(),
            // theClientDto.getLocMandant());
            // rows[row][INDEX_SUMMENGRUPPE] = "";
            // rows[row][INDEX_SUMMENNEG] = Boolean.FALSE;
            // rows[row][INDEX_INVERTIERT] = Boolean.FALSE;
            // rows[row][INDEX_PROZENTBASIS] = Boolean.FALSE;
            // }
            // break;
            // }
            row++;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.ExportdatenHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;/*from  ww  w.j a  v a2  s .  c o m*/
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        // LocaleFilter fuer die Belegart
        session = setFilter(session);

        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();

        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;

        while (resultListIterator.hasNext()) {
            FLRFinanzExportdaten exportDaten = (FLRFinanzExportdaten) ((Object[]) resultListIterator.next())[0];
            rows[row][col++] = exportDaten.getI_id();
            String sBelegart = exportDaten.getBelegart_c_nr();
            Set<?> sprSet = exportDaten.getFlrbelegart().getBelegart_belegart_set();
            if (!sprSet.isEmpty()) {
                sBelegart = ((FLRBelegartspr) sprSet.toArray()[0]).getC_bez();
            }
            rows[row][col++] = sBelegart;
            String sBelegnummer = "";
            if (exportDaten.getBelegart_c_nr().equals(LocaleFac.BELEGART_EINGANGSRECHNUNG)) {
                EingangsrechnungDto erDto = getEingangsrechnungFac()
                        .eingangsrechnungFindByPrimaryKey(exportDaten.getI_belegiid());
                sBelegnummer = erDto.getCNr();
            } else if (exportDaten.getBelegart_c_nr().equals(LocaleFac.BELEGART_RECHNUNG)
                    || exportDaten.getBelegart_c_nr().equals(LocaleFac.BELEGART_GUTSCHRIFT)) {
                RechnungDto erDto = getRechnungFac().rechnungFindByPrimaryKey(exportDaten.getI_belegiid());
                sBelegnummer = erDto.getCNr();
            }
            rows[row][col++] = sBelegnummer;
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.ExportlaufHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;//from   www  .  jav  a  2s.c  o  m
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        // LocaleFilter fuer die Belegart
        session = setFilter(session);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzExportlauf buchungsjournal = (FLRFinanzExportlauf) resultListIterator.next();
            rows[row][col++] = buchungsjournal.getI_id();
            rows[row][col++] = buchungsjournal.getT_aendern();
            rows[row][col++] = buchungsjournal.getT_stichtag();
            String sBelegart = null;
            if (buchungsjournal.getExportdatenset().size() > 0) {
                // Die Belegart ist einfach die des ersten exportierten
                // Belegs
                for (Iterator<?> iter = buchungsjournal.getExportdatenset().iterator(); iter.hasNext();) {
                    FLRFinanzExportdaten item = (FLRFinanzExportdaten) iter.next();

                    sBelegart = item.getBelegart_c_nr();
                    Set<?> sprSet = item.getFlrbelegart().getBelegart_belegart_set();
                    if (!sprSet.isEmpty()) {
                        sBelegart = ((FLRBelegartspr) sprSet.toArray()[0]).getC_bez();
                    }
                    break;
                }
            }
            rows[row][col++] = sBelegart;
            rows[row][col++] = new Integer(buchungsjournal.getExportdatenset().size());
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.FinanzamtHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;/*from  w  w  w  .  j ava 2 s.c  o m*/
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzFinanzamt finanzamt = (FLRFinanzFinanzamt) resultListIterator.next();
            FLRPartner partner = finanzamt.getFlrpartner();
            rows[row][col++] = finanzamt.getI_id();
            rows[row][col++] = partner.getC_name1nachnamefirmazeile1();
            if (partner.getFlrlandplzort() != null) {
                FLRLandplzort lplzort = partner.getFlrlandplzort();
                rows[row][col++] = lplzort.getC_plz() + " " + lplzort.getFlrort().getC_name();
                rows[row][col++] = lplzort.getFlrland().getC_lkz();
            } else {
                rows[row][col++] = "";
                rows[row][col++] = "";
            }
            //            rows[row][col++] = finanzamt.getFlrpartner().getFlrlandplzort()
            //               .getFlrland().getC_lkz();
            rows[row][col++] = finanzamt.getC_steuernummer();
            rows[row][col++] = finanzamt.getC_referat();
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.FinanzBuchungenDetailliertHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;/*from  w w w .  jav  a  2 s.  co  m*/
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;

    BuchungdetailText buchungdetailText = new BuchungdetailText(getBenutzerServicesFac(), theClientDto);

    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            Object o[] = (Object[]) resultListIterator.next();
            FLRFinanzBuchungDetail buchungDetail = (FLRFinanzBuchungDetail) o[0];

            rows[row][col++] = buchungDetail.getI_id();
            rows[row][col++] = buchungDetail.getFlrbuchung().getT_anlegen();
            rows[row][col++] = buchungDetail.getFlrbuchung().getD_buchungsdatum();

            rows[row][col++] = buchungdetailText.getTextFuerBuchungsart(buchungDetail.getFlrbuchung());
            rows[row][col++] = buchungDetail.getFlrbuchung().getC_belegnummer();
            rows[row][col++] = buchungDetail.getFlrkonto().getC_nr() + ", "
                    + buchungDetail.getFlrkonto().getC_bez();

            rows[row][col++] = buchungDetail.getFlrbuchung().getC_text();

            if (buchungDetail.getBuchungdetailart_c_nr().equals(BuchenFac.HabenBuchung)) {
                rows[row][col++] = null;
                rows[row][col++] = buchungDetail.getN_betrag();
            } else {
                rows[row][col++] = buchungDetail.getN_betrag();
                rows[row][col++] = null;
            }

            FLRFinanzKonto gegenkonto = buchungDetail.getFlrgegenkonto();
            if (gegenkonto != null) {
                rows[row][col++] = gegenkonto.getC_nr() + ", " + gegenkonto.getC_bez();
            } else {
                rows[row][col++] = "";
            }
            rows[row][col++] = buchungDetail.getI_auszug();

            if (buchungDetail.getFlrbuchung().getT_storniert() != null) {
                rows[row][col++] = LocaleFac.STATUS_STORNIERT;
            } else {
                rows[row][col++] = null;
            }
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.KassenbuchHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;/*ww w.  j av  a  2s  .  com*/
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = KassenbuchHandler.PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int geschaeftsjahr = calculateGeschaeftsjahr();
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzKassenbuch kassenbuch = (FLRFinanzKassenbuch) resultListIterator.next();
            rows[row][col++] = kassenbuch.getI_id();
            rows[row][col++] = kassenbuch.getC_bez();
            BigDecimal saldoKonto = getBuchenFac().getSaldoOhneEBVonKonto(kassenbuch.getFlrkonto().getI_id(),
                    geschaeftsjahr, 12, true, theClientDto);
            BigDecimal ebKonto = getBuchenFac().getSummeEroeffnungKontoIId(kassenbuch.getFlrkonto().getI_id(),
                    geschaeftsjahr, 12, true, theClientDto);
            rows[row][col++] = saldoKonto.add(ebKonto);

            boolean hauptKassenbuch = Helper.short2boolean(kassenbuch.getB_hauptkassenbuch());
            if (hauptKassenbuch) {
                rows[row][col++] = getTextRespectUISpr("fb.hauptkassenbuch", theClientDto.getMandant(),
                        theClientDto.getLocUi());
            } else {
                rows[row][col++] = "";
            }
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.KontoartHandler.java

License:Open Source License

public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;//w  w  w  .ja v a  2  s  . c o  m
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = getTableInfo().getColumnClasses().length;
        int pageSize = PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;

        Locale locUI = theClientDto.getLocUi();
        while (resultListIterator.hasNext()) {
            FLRFinanzKontoart kontoart = (FLRFinanzKontoart) resultListIterator.next();
            rows[row][col++] = kontoart.getC_nr();
            rows[row][col++] = kontoart.getC_nr();
            rows[row][col++] = getFinanzServiceFac().uebersetzeKontoartOptimal(kontoart.getC_nr(), locUI,
                    locUI);
            rows[row][col++] = kontoart.getI_sort();
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.KontoHandlerAuswahl.java

License:Open Source License

/**
 * gets the data page for the specified row using the current query. The row
 * at rowIndex will be located in the middle of the page.
 * //from  ww w. j  av  a 2  s  . c o  m
 * @see KontoHandler#getPageAt(java.lang.Integer)
 * @param rowIndex
 *            Integer
 * @throws EJBExceptionLP
 * @return QueryResult
 */
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {

    QueryResult result = null;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = this.getTableInfo().getColumnClasses().length;
        int pageSize = KontoHandler.PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzKonto konto = (FLRFinanzKonto) resultListIterator.next();
            rows[row][col++] = konto.getI_id();
            rows[row][col++] = konto.getC_nr();
            rows[row][col++] = konto.getC_bez();
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.KontoHandlerDebitorenkonten.java

License:Open Source License

/**
 * gets the data page for the specified row using the current query. The row
 * at rowIndex will be located in the middle of the page.
 * /*from  w ww  .j  av  a  2 s  . com*/
 * @see KontoHandler#getPageAt(java.lang.Integer)
 * @param rowIndex
 *            Integer
 * @throws EJBExceptionLP
 * @return QueryResult
 */
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {

    QueryResult result = null;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = this.getTableInfo().getColumnClasses().length;
        int pageSize = KontoHandler.PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzKonto konto = (FLRFinanzKonto) resultListIterator.next();
            rows[row][col++] = konto.getI_id();
            rows[row][col++] = konto.getC_nr();
            rows[row][col++] = konto.getC_bez();
            if (konto.getFlrsteuerkategorie() != null) {
                rows[row][col++] = konto.getFlrsteuerkategorie().getC_nr();
            } else {
                rows[row][col++] = "";
            }
            if (getPartnerFac().partnerFindByPrimaryKey(konto.getFinanzamt_i_id(), theClientDto) != null) {
                rows[row][col++] = getPartnerFac()
                        .partnerFindByPrimaryKey(konto.getFinanzamt_i_id(), theClientDto)
                        .getCName1nachnamefirmazeile1();
            } else {
                rows[row][col++] = "";
            }
            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}

From source file:com.lp.server.finanz.fastlanereader.KontoHandlerSachkonten.java

License:Open Source License

/**
 * gets the data page for the specified row using the current query. The row
 * at rowIndex will be located in the middle of the page.
 * //  www .  j  a v  a 2 s  . co  m
 * @see KontoHandler#getPageAt(java.lang.Integer)
 * @param rowIndex
 *            Integer
 * @throws EJBExceptionLP
 * @return QueryResult
 */
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {

    QueryResult result = null;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
        int colCount = this.getTableInfo().getColumnClasses().length;
        int pageSize = KontoHandler.PAGE_SIZE;
        int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0);
        int endIndex = startIndex + pageSize - 1;

        session = factory.openSession();
        String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        query.setFirstResult(startIndex);
        query.setMaxResults(pageSize);
        List<?> resultList = query.list();
        Iterator<?> resultListIterator = resultList.iterator();
        Object[][] rows = new Object[resultList.size()][colCount];
        int row = 0;
        int col = 0;
        while (resultListIterator.hasNext()) {
            FLRFinanzKonto konto = (FLRFinanzKonto) resultListIterator.next();
            rows[row][col++] = konto.getI_id();
            rows[row][col++] = konto.getC_nr();
            rows[row][col++] = konto.getC_bez();
            if (konto.getFlrergebnisgruppe() != null) {

                if (Helper.short2boolean(konto.getFlrergebnisgruppe().getB_bilanzgruppe()) == true) {
                    rows[row][col++] = "B:" + konto.getFlrergebnisgruppe().getC_bez();
                } else {
                    rows[row][col++] = "E:" + konto.getFlrergebnisgruppe().getC_bez();
                }

            } else {
                rows[row][col++] = "";
            }
            if (konto.getFlrkontoust() != null) {
                rows[row][col++] = konto.getFlrkontoust().getC_nr();
            } else {
                rows[row][col++] = "";
            }
            if (konto.getFlrkontoart() != null) {
                rows[row][col++] = getFinanzServiceFac().uebersetzeKontoartOptimal(
                        konto.getFlrkontoart().getC_nr(), theClientDto.getLocUi(),
                        theClientDto.getLocMandant());
            } else {
                rows[row][col++] = "";
            }
            if (konto.getFinanzamt_i_id() != null) {
                rows[row][col++] = getPartnerFac()
                        .partnerFindByPrimaryKey(konto.getFinanzamt_i_id(), theClientDto)
                        .getCName1nachnamefirmazeile1();
            } else {
                rows[row][col++] = "";
            }

            // getFinanzFac().finanzamtFindByPrimaryKey(konto.getFinanzamt_i_id(),
            // theClientDto.getMandant(), theClientDto);

            row++;
            col = 0;
        }
        result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
        try {
            session.close();
        } catch (HibernateException he) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
    }
    return result;
}