Source:
<code>public List<RadiologyOrder> getRadiologyOrders(RadiologyOrderSearchCriteria searchCriteria) { final Criteria crit = sessionFactory.getCurrentSession() .createCriteria(RadiologyOrder.class); if (searchCriteria.getPatient() != null) { crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); } if (!searchCriteria.getIncludeVoided()) { crit.add(Restrictions.not(Restrictions.eq("voided", true))); } if (searchCriteria.getUrgency() != null) { crit.add(Restrictions.eq("urgency", searchCriteria.getUrgency())); } if (searchCriteria.getFromEffectiveStartDate() != null) { <START> Disjunction disjunction = Restrictions.disjunction(); <END> disjunction.add(Restrictions.and((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)), Restrictions.ge("scheduledDate", searchCriteria.getFromEffectiveStartDate()))); disjunction.add(Restrictions.and(Restrictions.not((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE))), Restrictions.ge("dateActivated", searchCriteria.getFromEffectiveStartDate()))); crit.add(disjunction); } if (searchCriteria.getToEffectiveStartDate() != null) { Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.and((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)), Restrictions.le("scheduledDate", searchCriteria.getToEffectiveStartDate()))); disjunction.add(Restrictions.and(Restrictions.not((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE))), Restrictions.le("dateActivated", searchCriteria.getToEffectiveStartDate()))); crit.add(disjunction); } return crit.list(); }</code><technical_language>@bgeVam please final temp vars :)</technical_language>

Target:
public List<RadiologyOrder> getRadiologyOrders(RadiologyOrderSearchCriteria searchCriteria) { final Criteria crit = sessionFactory.getCurrentSession() .createCriteria(RadiologyOrder.class); if (searchCriteria.getPatient() != null) { crit.add(Restrictions.eq("patient", searchCriteria.getPatient())); } if (!searchCriteria.getIncludeVoided()) { crit.add(Restrictions.not(Restrictions.eq("voided", true))); } if (searchCriteria.getUrgency() != null) { crit.add(Restrictions.eq("urgency", searchCriteria.getUrgency())); } if (searchCriteria.getFromEffectiveStartDate() != null) { final Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.conjunction() .add(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)) .add(Restrictions.ge("scheduledDate", searchCriteria.getFromEffectiveStartDate()))); disjunction.add(Restrictions.conjunction() .add(Restrictions.not(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE))) .add(Restrictions.ge("dateActivated", searchCriteria.getFromEffectiveStartDate()))); crit.add(disjunction); } if (searchCriteria.getToEffectiveStartDate() != null) { final Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.conjunction() .add(Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)) .add(Restrictions.le("scheduledDate", searchCriteria.getToEffectiveStartDate()))); disjunction.add(Restrictions.conjunction() .add(Restrictions.not((Restrictions.eq("urgency", Urgency.ON_SCHEDULED_DATE)))) .add(Restrictions.le("dateActivated", searchCriteria.getToEffectiveStartDate()))); crit.add(disjunction); } return crit.list(); }