@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; }
@Override public PositionBaseBo getPosition(String positionNumber, LocalDate effectiveDate) { Criteria root = new Criteria(); root.addEqualTo("positionNumber", positionNumber); root.addEqualTo( "effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQuery( PositionBaseBo.class, effectiveDate, PositionBaseBo.BUSINESS_KEYS, false)); root.addEqualTo( "timestamp", OjbSubQueryUtil.getTimestampSubQuery( PositionBaseBo.class, PositionBaseBo.BUSINESS_KEYS, false)); Criteria activeFilter = new Criteria(); // Inner Join For Activity activeFilter.addEqualTo("active", true); root.addAndCriteria(activeFilter); Query query = QueryFactory.newQuery(PositionBaseBo.class, root); return (PositionBaseBo) this.getPersistenceBrokerTemplate().getObjectByQuery(query); }