Exemplo n.º 1
0
  @Override
  @SuppressWarnings("unchecked")
  public List<PositionBaseBo> getPositions(
      String positionNum,
      String description,
      LocalDate fromEffdt,
      LocalDate toEffdt,
      String active,
      String showHistory) {
    List<PositionBaseBo> results = new ArrayList<PositionBaseBo>();

    Criteria root = new Criteria();

    if (StringUtils.isNotBlank(positionNum)) {
      root.addLike("positionNumber", positionNum);
    }

    if (StringUtils.isNotBlank(description)) {
      root.addLike("UPPER(description)", description.toUpperCase()); // KPME-2695
    }

    Criteria effectiveDateFilter = new Criteria();
    if (fromEffdt != null) {
      effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate());
    }
    if (toEffdt != null) {
      effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate());
    }
    if (fromEffdt == null && toEffdt == null) {
      effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate());
    }
    root.addAndCriteria(effectiveDateFilter);

    if (StringUtils.isNotBlank(active)) {
      Criteria activeFilter = new Criteria();
      if (StringUtils.equals(active, "Y")) {
        activeFilter.addEqualTo("active", true);
      } else if (StringUtils.equals(active, "N")) {
        activeFilter.addEqualTo("active", false);
      }
      root.addAndCriteria(activeFilter);
    }

    if (StringUtils.equals(showHistory, "N")) {
      root.addEqualTo(
          "effectiveDate",
          OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(
              PositionBaseBo.class, effectiveDateFilter, PositionBaseBo.BUSINESS_KEYS, false));
      root.addEqualTo(
          "timestamp",
          OjbSubQueryUtil.getTimestampSubQuery(
              PositionBaseBo.class, PositionBaseBo.BUSINESS_KEYS, false));
    }

    Query query = QueryFactory.newQuery(PositionBaseBo.class, root);
    results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));

    return results;
  }
Exemplo n.º 2
0
 public Collection findOwners(String lastName) throws DataAccessException {
   Criteria criteria = new Criteria();
   criteria.addLike("lastName", lastName + "%");
   Query query = new QueryByCriteria(Owner.class, criteria);
   return getPersistenceBrokerTemplate().getCollectionByQuery(query);
 }