protected long getRowCountFromDataBase() {
    long rowCount = 0;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
      session = factory.openSession();
      session = setFilter(session);

      String queryString =
          "SELECT COUNT(*) FROM FLRLohnartstundenfaktor AS lohnartstundenfaktor"
              + buildWhereClause();

      Query query = session.createQuery(queryString);
      List<?> rowCountResult = query.list();
      if (rowCountResult != null && rowCountResult.size() > 0) {
        rowCount = ((Long) rowCountResult.get(0)).longValue();
      }
    } catch (Exception e) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
      if (session != null) {
        try {
          session.close();
        } catch (HibernateException he) {
          throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
        }
      }
    }
    return rowCount;
  }
Exemple #2
0
  protected long getRowCountFromDataBase() {
    long rowCount = 0;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
      session = factory.openSession();
      String queryString =
          "SELECT count(distinct lieferant.i_id) FROM FLRLieferant AS lieferant "
              + " left join lieferant.flrpartner.flrlandplzort as flrlandplzort "
              + " left join lieferant.flrpartner.flrlandplzort.flrort as flrort "
              + " left join lieferant.flrkonto as flrkonto "
              + " left join lieferant.flrpartner.flrlandplzort.flrland as flrland "
              + " LEFT OUTER JOIN lieferant.flrpartner.ansprechpartner AS ansprechpartnerset "
              + " LEFT OUTER JOIN ansprechpartnerset.flrpartneransprechpartner AS partneransprechpartner "
              + buildWhereClause();

      Query query = session.createQuery(queryString);
      List<?> rowCountResult = query.list();
      if (rowCountResult != null && rowCountResult.size() > 0) {
        rowCount = ((Long) rowCountResult.get(0)).longValue();
      }
    } catch (Exception e) {
      throw new EJBExceptionLP(e);
    } finally {
      if (session != null) {
        try {
          session.close();
        } catch (HibernateException he) {
          throw new EJBExceptionLP(he);
        }
      }
    }
    return rowCount;
  }
 protected long getRowCountFromDataBase() {
   long rowCount = 0;
   SessionFactory factory = FLRSessionFactory.getFactory();
   Session session = null;
   try {
     session = factory.openSession();
     String queryString = "select count(*) " + this.getFromClause() + this.buildWhereClause();
     Query query = session.createQuery(queryString);
     List<?> rowCountResult = query.list();
     if (rowCountResult != null && rowCountResult.size() > 0) {
       rowCount = ((Long) rowCountResult.get(0)).longValue();
     }
   } catch (Exception e) {
     throw new EJBExceptionLP(EJBExceptionLP.FEHLER, e);
   } finally {
     if (session != null) {
       try {
         session.close();
       } catch (HibernateException he) {
         throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
       }
     }
   }
   return rowCount;
 }
  /**
   * The information needed for the kundes table.
   *
   * @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 = 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);
      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()) {

        FLRLohnartstundenfaktor lohnartstundenfaktor =
            (FLRLohnartstundenfaktor) resultListIterator.next();

        rows[row][col++] = lohnartstundenfaktor.getI_id();
        rows[row][col++] = lohnartstundenfaktor.getFlrlohnart().getI_lohnart();
        rows[row][col++] = lohnartstundenfaktor.getFlrlohnart().getC_bez();
        rows[row][col++] = lohnartstundenfaktor.getFlrlohnart().getPersonalart_c_nr();
        rows[row][col++] = lohnartstundenfaktor.getF_faktor();

        String s = lohnartstundenfaktor.getFlrlohnstundenart().getC_nr();
        if (lohnartstundenfaktor.getFlrlohnstundenart().getC_bez() != null) {
          s = lohnartstundenfaktor.getFlrlohnstundenart().getC_bez();
        }
        rows[row][col++] = s;

        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;
  }
Exemple #5
0
  public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {

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

      session = factory.openSession();
      String queryString = getFromClause() + buildWhereClause() + 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();

        rows[row][col++] = o[0];
        rows[row][col++] = o[1];
        rows[row][col++] = o[2];
        rows[row][col++] = o[3];
        if (o[4] != null) {
          rows[row][col++] = LocaleFac.STATUS_GESPERRT;
        } else {
          rows[row][col++] = null;
        }
        rows[row][col++] = o[5];
        rows[row][col++] = o[6];
        rows[row][col++] = o[7];
        rows[row][col++] = o[8];

        if (Helper.short2boolean((Short) o[9])) {
          rows[row][col++] = Color.LIGHT_GRAY;
        }

        row++;
        col = 0;
      }
      result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER, e);
    } finally {
      try {
        session.close();
      } catch (HibernateException he) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
      }
    }
    return result;
  }
  public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId)
      throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
      SessionFactory factory = FLRSessionFactory.getFactory();
      Session session = null;

      try {
        session = factory.openSession();
        String queryString =
            "select reportvariante.i_id from FLRReportvariante reportvariante "
                + this.buildWhereClause()
                + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        ScrollableResults scrollableResult = query.scroll();
        //				boolean idFound = false;
        if (scrollableResult != null) {
          scrollableResult.beforeFirst();
          while (scrollableResult.next()) {
            Integer id = (Integer) scrollableResult.getInteger(0); // TYPE
            // OF
            // KEY
            // ATTRIBUTE
            // !
            // !
            // !
            if (selectedId.equals(id)) {
              rowNumber = scrollableResult.getRowNumber();
              break;
            }
          }
        }
      } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
      } finally {
        try {
          session.close();
        } catch (HibernateException he) {
          throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
      }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
      rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
  }
  public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId)
      throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
      SessionFactory factory = FLRSessionFactory.getFactory();
      Session session = null;

      try {
        session = factory.openSession();
        String queryString =
            "select "
                + FLR_ZVL
                + EingangsrechnungFac.FLR_ZV_LAUF_I_ID
                + FLR_ZVL_FROM_CLAUSE
                + this.buildWhereClause()
                + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        ScrollableResults scrollableResult = query.scroll();
        if (scrollableResult != null) {
          scrollableResult.beforeFirst();
          while (scrollableResult.next()) {
            Integer id = scrollableResult.getInteger(0);
            if (selectedId.equals(id)) {
              rowNumber = scrollableResult.getRowNumber();
              break;
            }
          }
        }
      } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
      } finally {
        try {
          session.close();
        } catch (HibernateException he) {
          throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
        }
      }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
      rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
  }
  public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId)
      throws EJBExceptionLP {

    getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null) {
      SessionFactory factory = FLRSessionFactory.getFactory();
      Session session = null;

      try {
        session = factory.openSession();
        session = setFilter(session);
        String queryString = getFromClause() + buildWhereClause() + buildOrderByClause();

        Query query = session.createQuery(queryString);
        ScrollableResults scrollableResult = query.scroll();
        if (scrollableResult != null) {
          scrollableResult.beforeFirst();
          while (scrollableResult.next()) {
            FLRLohnartstundenfaktor artikelkommentarart =
                (FLRLohnartstundenfaktor) scrollableResult.get(0);
            Integer iId = artikelkommentarart.getI_id();
            if (selectedId.equals(iId)) {
              rowNumber = scrollableResult.getRowNumber();
              break;
            }
          }
        }
      } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
      } finally {
        try {
          session.close();
        } catch (HibernateException he) {
          throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
        }
      }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
      rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
  }
  public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId)
      throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null) {
      SessionFactory factory = FLRSessionFactory.getFactory();
      Session session = null;

      try {
        session = factory.openSession();
        String queryString =
            "select "
                + FLR_WVKNR
                + FinanzServiceFac.FLR_WARENVERKEHRSNUMMER_C_NR
                + FLR_WVKNR_FROM_CLAUSE
                + this.buildWhereClause()
                + this.buildOrderByClause();
        Query query = session.createQuery(queryString);
        ScrollableResults scrollableResult = query.scroll();
        if (scrollableResult != null) {
          scrollableResult.beforeFirst();
          while (scrollableResult.next()) {
            String id = scrollableResult.getString(0);
            if (selectedId.equals(id)) {
              rowNumber = scrollableResult.getRowNumber();
              break;
            }
          }
        }
      } catch (Exception e) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
      } finally {
        closeSession(session);
      }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
      rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
  }
  /** The information needed for the kundes table. */
  public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;
    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()) {
        FLRReportvariante rv = (FLRReportvariante) resultListIterator.next();
        rows[row][col++] = rv.getI_id();
        rows[row][col++] = rv.getC_reportname();
        rows[row][col++] = rv.getC_reportnamevariante();

        rows[row++][col++] =
            getTextRespectUISpr(
                rv.getC_ressource(), theClientDto.getMandant(), theClientDto.getLocUi());

        col = 0;
      }
      result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (HibernateException e) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
      try {
        session.close();
      } catch (HibernateException he) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
      }
    }
    return result;
  }
Exemple #11
0
  /**
   * Ueber diese Methode kann eine Facade auf eine Lieferantenliste zugreifen.
   *
   * @param cQueryStringI der Hibernate Query String
   * @return List<?> die Liste der Lieferanten.
   * @throws EJBExceptionLP Ausnahme
   */
  public static List<?> getFLRLieferantenliste(String cQueryStringI) throws EJBExceptionLP {

    List<?> resultList = null;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;

    try {
      session = factory.openSession();
      Query query = session.createQuery(cQueryStringI);
      resultList = query.list();
    } catch (Exception t) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, t);
    } finally {
      try {
        session.close();
      } catch (HibernateException he) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER_HIBERNATE, he);
      }
    }

    return resultList;
  }
  public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;
    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()) {
        int col = 0;
        FLRFinanzWarenverkehrsnummer intbest =
            (FLRFinanzWarenverkehrsnummer) resultListIterator.next();
        rows[row][col++] = intbest.getC_nr();
        rows[row][col++] = intbest.getC_nr();
        rows[row][col++] = intbest.getC_bez();
        row++;
      }
      result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0);
    } catch (Exception e) {
      throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
    } finally {
      closeSession(session);
    }
    return result;
  }
  public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {
    QueryResult result = null;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
      int colCount = getTableInfo().getColumnClasses().length;
      int startIndex = Math.max(rowIndex.intValue() - (PAGE_SIZE / 2), 0);
      int endIndex = startIndex + PAGE_SIZE - 1;

      session = factory.openSession();
      String queryString =
          this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause();
      Query query = session.createQuery(queryString);
      query.setFirstResult(startIndex);
      query.setMaxResults(PAGE_SIZE);
      List<?> resultList = query.list();
      Iterator<?> resultListIterator = resultList.iterator();
      Object[][] rows = new Object[resultList.size()][colCount];
      String[] tooltipData = new String[resultList.size()];
      int row = 0;
      int col = 0;
      while (resultListIterator.hasNext()) {
        FLRZahlungsvorschlaglauf zvLauf = (FLRZahlungsvorschlaglauf) resultListIterator.next();
        rows[row][col++] = zvLauf.getI_id();
        rows[row][col++] = new java.sql.Timestamp(zvLauf.getT_anlegen().getTime());
        rows[row][col++] = zvLauf.getT_zahlungsstichtag();
        rows[row][col++] = zvLauf.getT_naechsterzahlungslauf();
        rows[row][col++] = Helper.short2Boolean(zvLauf.getB_mitskonto());
        rows[row][col++] = zvLauf.getI_skontoueberziehungsfristintagen();
        if (zvLauf.getFlrbankverbindung().getC_bez() != null) {
          rows[row][col++] = zvLauf.getFlrbankverbindung().getC_bez();
        } else {
          rows[row][col++] =
              zvLauf.getFlrbankverbindung().getC_kontonummer()
                  + " | "
                  + zvLauf
                      .getFlrbankverbindung()
                      .getFlrbank()
                      .getFlrpartner()
                      .getC_name1nachnamefirmazeile1();
        }

        if (zvLauf.getT_gespeichert() != null) {
          String s =
              getTextRespectUISpr(
                      "er.zahlungsvorschlag.gespeichert",
                      theClientDto.getMandant(),
                      theClientDto.getLocUi())
                  + Helper.formatTimestamp(
                      new Timestamp(zvLauf.getT_gespeichert().getTime()), theClientDto.getLocUi());
          if (zvLauf.getFlrpersonalgespeichert() != null) {
            s +=
                " ("
                    + HelperServer.formatPersonAusFLRPartner(
                        zvLauf.getFlrpersonalgespeichert().getFlrpartner())
                    + ")";
          }
          rows[row][col++] = LocaleFac.STATUS_GELIEFERT;
          tooltipData[row] = s;
        }

        row++;
        col = 0;
      }
      result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0, tooltipData);
    } 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;
  }
Exemple #14
0
  public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP {

    QueryResult result = null;
    SessionFactory factory = FLRSessionFactory.getFactory();
    Session session = null;
    try {
      int colCount = getTableInfo().getColumnClasses().length;
      int pageSize = ArtikelgruHandler.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);
      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;

      String sLocUI = Helper.locale2String(theClientDto.getLocUi());

      while (resultListIterator.hasNext()) {
        Object o[] = (Object[]) resultListIterator.next();
        FLRArtikelgruppe artikelgruppe = (FLRArtikelgruppe) o[0];
        Iterator<?> sprsetIterator = artikelgruppe.getArtikelgruppesprset().iterator();

        rows[row][col++] = artikelgruppe.getI_id();
        rows[row][col++] = artikelgruppe.getC_nr();
        rows[row][col++] = findSpr(sLocUI, sprsetIterator);

        rows[row][col++] =
            artikelgruppe.getFlrartikelgruppe() == null
                ? null
                : artikelgruppe.getFlrartikelgruppe().getC_nr();

        if (artikelgruppe.getFlrartikelgruppe() != null) {
          Iterator<?> sprsetIteratorV =
              artikelgruppe.getFlrartikelgruppe().getArtikelgruppesprset().iterator();

          rows[row][col++] = findSpr(sLocUI, sprsetIteratorV);
        } else {
          rows[row][col++] = null;
        }

        rows[row][col++] =
            artikelgruppe.getFlrkonto() == null ? null : artikelgruppe.getFlrkonto().getC_nr();

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