@Ignore @Test public void testGetByStatusAndSchedule() { System.out.println("getByStatusAndSchedule"); List<GatewayRequest> expResult = new ArrayList<GatewayRequest>(); md4.setGatewayRequestDetails(grd4); md5.setGatewayRequestDetails(grd5); expResult.add(md4); expResult.add(md5); MStatus status = MStatus.FAILED; List result = mDDAO.getByStatusAndSchedule(status, schedule); Assert.assertFalse(result.isEmpty()); Assert.assertEquals(expResult.size(), result.size()); Assert.assertEquals(true, result.contains(md4)); Assert.assertEquals(true, result.contains(md5)); }
public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) { logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule); try { List<GatewayRequest> allbystatandSdule; Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass()); if (schedule == null) { criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom")).add(Restrictions.eq("messageStatus", status)); } else { criteria = criteria.add(Restrictions.eq("messageStatus", status)).add(Restrictions.or(Restrictions.isNull("dateFrom"),Restrictions.lt("dateFrom", schedule))).add(Restrictions.or(Restrictions.isNull("dateTo"),Restrictions.gt("dateTo", schedule))); } allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails")).list(); logger.debug(allbystatandSdule); return allbystatandSdule; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he); return null; } catch (Exception ex) { logger.error("Exception in Method getByStatusAndSchedule", ex); return null; } }
GatewayRequestDAOImpl extends HibernateGenericDAOImpl<GatewayRequestImpl> implements GatewayRequestDAO<GatewayRequestImpl> { public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) { logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule); try { List<GatewayRequest> allbystatandSdule; Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass()); if (schedule == null) { criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom")).add(Restrictions.eq("messageStatus", status)); } else { criteria = criteria.add(Restrictions.eq("messageStatus", status)).add(Restrictions.or(Restrictions.isNull("dateFrom"),Restrictions.lt("dateFrom", schedule))).add(Restrictions.or(Restrictions.isNull("dateTo"),Restrictions.gt("dateTo", schedule))); } allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails")).list(); logger.debug(allbystatandSdule); return allbystatandSdule; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he); return null; } catch (Exception ex) { logger.error("Exception in Method getByStatusAndSchedule", ex); return null; } } }
GatewayRequestDAOImpl extends HibernateGenericDAOImpl<GatewayRequestImpl> implements GatewayRequestDAO<GatewayRequestImpl> { public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) { logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule); try { List<GatewayRequest> allbystatandSdule; Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass()); if (schedule == null) { criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom")).add(Restrictions.eq("messageStatus", status)); } else { criteria = criteria.add(Restrictions.eq("messageStatus", status)).add(Restrictions.or(Restrictions.isNull("dateFrom"),Restrictions.lt("dateFrom", schedule))).add(Restrictions.or(Restrictions.isNull("dateTo"),Restrictions.gt("dateTo", schedule))); } allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails")).list(); logger.debug(allbystatandSdule); return allbystatandSdule; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he); return null; } catch (Exception ex) { logger.error("Exception in Method getByStatusAndSchedule", ex); return null; } } GatewayRequestDAOImpl(); }
GatewayRequestDAOImpl extends HibernateGenericDAOImpl<GatewayRequestImpl> implements GatewayRequestDAO<GatewayRequestImpl> { public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) { logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule); try { List<GatewayRequest> allbystatandSdule; Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass()); if (schedule == null) { criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom")).add(Restrictions.eq("messageStatus", status)); } else { criteria = criteria.add(Restrictions.eq("messageStatus", status)).add(Restrictions.or(Restrictions.isNull("dateFrom"),Restrictions.lt("dateFrom", schedule))).add(Restrictions.or(Restrictions.isNull("dateTo"),Restrictions.gt("dateTo", schedule))); } allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails")).list(); logger.debug(allbystatandSdule); return allbystatandSdule; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he); return null; } catch (Exception ex) { logger.error("Exception in Method getByStatusAndSchedule", ex); return null; } } GatewayRequestDAOImpl(); List<GatewayRequest> getByStatus(MStatus status); List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule); }
GatewayRequestDAOImpl extends HibernateGenericDAOImpl<GatewayRequestImpl> implements GatewayRequestDAO<GatewayRequestImpl> { public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) { logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule); try { List<GatewayRequest> allbystatandSdule; Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass()); if (schedule == null) { criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom")).add(Restrictions.eq("messageStatus", status)); } else { criteria = criteria.add(Restrictions.eq("messageStatus", status)).add(Restrictions.or(Restrictions.isNull("dateFrom"),Restrictions.lt("dateFrom", schedule))).add(Restrictions.or(Restrictions.isNull("dateTo"),Restrictions.gt("dateTo", schedule))); } allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails")).list(); logger.debug(allbystatandSdule); return allbystatandSdule; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he); return null; } catch (Exception ex) { logger.error("Exception in Method getByStatusAndSchedule", ex); return null; } } GatewayRequestDAOImpl(); List<GatewayRequest> getByStatus(MStatus status); List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule);  }