@Test public void testFindNumberOFMessagesByHistory() throws DAOException { MessageDVO criteriaDVO; MessageDataSourceDAO dao = super.getTestingTarget(); int result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setMessageId("20080311-155320-90407@192.168.0.1"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(2, result); criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setMessageId("20080311-155320-90407%"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(2, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setMessageBox("inbox"); criteriaDVO.setMessageId("20080311-155320-90407@192.168.0.1"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setService("testhistory:testhistory"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setService("test%history"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setAction("action"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setAction("a%i_n"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setStatus("PD"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setConvId("convId_test5"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setConvId("%test5"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setMessageId("20080311-155320-90407@192.168.0.1"); criteriaDVO.setMessageBox("outbox"); criteriaDVO.setService(" "); criteriaDVO.setAction(" "); criteriaDVO.setCpaId(" "); criteriaDVO.setConvId(" "); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setMessageId("%@192.168.0.1"); criteriaDVO.setService("test%history%"); criteriaDVO.setConvId("convId%"); criteriaDVO.setAction("order"); criteriaDVO.setStatus(""); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(1, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setMessageBox("%box"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(0, result); criteriaDVO = null; result = -1; criteriaDVO = (MessageDVO)dao.createDVO(); criteriaDVO.setStatus("%L"); result = dao.findNumberOfMessagesByHistory(criteriaDVO); Assert.assertEquals(0, result); }
public int findNumberOfMessagesByHistory(MessageDVO data) throws DAOException { try { List parameters = new ArrayList(); String sql = super.getFinder("find_number_of_message_by_history"); if (data.getMessageId() != null && !data.getMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_id"); parameters.add(data.getMessageId()); } if (data.getMessageBox() != null && !data.getMessageBox().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_box"); parameters.add(data.getMessageBox()); } if (data.getCpaId() != null && !data.getCpaId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_cpa_id"); parameters.add(data.getCpaId()); } if (data.getService() != null && !data.getService().trim().equals("")) { sql += " AND " +getFilter("find_number_of_message_by_history_filter_service"); parameters.add(data.getService()); } if (data.getAction() != null && !data.getAction().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_action"); parameters.add(data.getAction()); } if (data.getStatus() != null && !data.getStatus().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_status"); parameters.add(data.getStatus()); } if (data.getConvId() != null && !data.getConvId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_conv_id"); parameters.add(data.getConvId()); } if (data.getPrimalMessageId() != null && !data.getPrimalMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_primal_message_id"); parameters.add(data.getPrimalMessageId()); } List queryResult = executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) queryResult.get(0); return ((Number) resultEntry.get(0)).intValue(); } catch (Exception e) { throw new DAOException( "Unable to find the number of messages by history", e); } }
MessageDataSourceDAO extends DataSourceDAO implements MessageDAO { public int findNumberOfMessagesByHistory(MessageDVO data) throws DAOException { try { List parameters = new ArrayList(); String sql = super.getFinder("find_number_of_message_by_history"); if (data.getMessageId() != null && !data.getMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_id"); parameters.add(data.getMessageId()); } if (data.getMessageBox() != null && !data.getMessageBox().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_box"); parameters.add(data.getMessageBox()); } if (data.getCpaId() != null && !data.getCpaId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_cpa_id"); parameters.add(data.getCpaId()); } if (data.getService() != null && !data.getService().trim().equals("")) { sql += " AND " +getFilter("find_number_of_message_by_history_filter_service"); parameters.add(data.getService()); } if (data.getAction() != null && !data.getAction().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_action"); parameters.add(data.getAction()); } if (data.getStatus() != null && !data.getStatus().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_status"); parameters.add(data.getStatus()); } if (data.getConvId() != null && !data.getConvId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_conv_id"); parameters.add(data.getConvId()); } if (data.getPrimalMessageId() != null && !data.getPrimalMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_primal_message_id"); parameters.add(data.getPrimalMessageId()); } List queryResult = executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) queryResult.get(0); return ((Number) resultEntry.get(0)).intValue(); } catch (Exception e) { throw new DAOException( "Unable to find the number of messages by history", e); } } }
MessageDataSourceDAO extends DataSourceDAO implements MessageDAO { public int findNumberOfMessagesByHistory(MessageDVO data) throws DAOException { try { List parameters = new ArrayList(); String sql = super.getFinder("find_number_of_message_by_history"); if (data.getMessageId() != null && !data.getMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_id"); parameters.add(data.getMessageId()); } if (data.getMessageBox() != null && !data.getMessageBox().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_box"); parameters.add(data.getMessageBox()); } if (data.getCpaId() != null && !data.getCpaId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_cpa_id"); parameters.add(data.getCpaId()); } if (data.getService() != null && !data.getService().trim().equals("")) { sql += " AND " +getFilter("find_number_of_message_by_history_filter_service"); parameters.add(data.getService()); } if (data.getAction() != null && !data.getAction().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_action"); parameters.add(data.getAction()); } if (data.getStatus() != null && !data.getStatus().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_status"); parameters.add(data.getStatus()); } if (data.getConvId() != null && !data.getConvId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_conv_id"); parameters.add(data.getConvId()); } if (data.getPrimalMessageId() != null && !data.getPrimalMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_primal_message_id"); parameters.add(data.getPrimalMessageId()); } List queryResult = executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) queryResult.get(0); return ((Number) resultEntry.get(0)).intValue(); } catch (Exception e) { throw new DAOException( "Unable to find the number of messages by history", e); } }  }
MessageDataSourceDAO extends DataSourceDAO implements MessageDAO { public int findNumberOfMessagesByHistory(MessageDVO data) throws DAOException { try { List parameters = new ArrayList(); String sql = super.getFinder("find_number_of_message_by_history"); if (data.getMessageId() != null && !data.getMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_id"); parameters.add(data.getMessageId()); } if (data.getMessageBox() != null && !data.getMessageBox().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_box"); parameters.add(data.getMessageBox()); } if (data.getCpaId() != null && !data.getCpaId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_cpa_id"); parameters.add(data.getCpaId()); } if (data.getService() != null && !data.getService().trim().equals("")) { sql += " AND " +getFilter("find_number_of_message_by_history_filter_service"); parameters.add(data.getService()); } if (data.getAction() != null && !data.getAction().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_action"); parameters.add(data.getAction()); } if (data.getStatus() != null && !data.getStatus().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_status"); parameters.add(data.getStatus()); } if (data.getConvId() != null && !data.getConvId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_conv_id"); parameters.add(data.getConvId()); } if (data.getPrimalMessageId() != null && !data.getPrimalMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_primal_message_id"); parameters.add(data.getPrimalMessageId()); } List queryResult = executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) queryResult.get(0); return ((Number) resultEntry.get(0)).intValue(); } catch (Exception e) { throw new DAOException( "Unable to find the number of messages by history", e); } }  DVO createDVO(); boolean findMessage(MessageDVO data); void addMessage(MessageDVO data); void deleteMessage(MessageDVO data); boolean updateMessage(MessageDVO data); boolean findRefToMessage(MessageDVO data); List findMessagesByTime(int time_period, MessageDVO data, int numberOfMessage, int offset); List findMessagesBeforeTime(int time_period); List findInboxPendingMessagesByTimestamp(MessageDVO data); List findOutboxPendingMessagesByTimestamp(MessageDVO data); List findOutboxProcessingMessagesByTimestamp(MessageDVO data); List findMessageByCpa(MessageDVO data, int numberOfMessage); int findInboxReadyMaxSequenceNoByCpa(MessageDVO data); int findMaxSequenceNoByMessageBoxAndCpa(MessageDVO data); int findMaxSequenceGroupByMessageBoxAndCpa(MessageDVO data); int findNumOfMessagesByMessageBoxAndCpaAndSequenceGroup(
            MessageDVO data); boolean findOrderedMessageByMessageBoxAndCpaAndSequenceGroupAndSequenceNo(
            MessageDVO data); List findOrderedMessagesByMessageBoxAndCpaAndStatus(MessageDVO data); List findMessagesByHistory(MessageDVO data, int numberOfMessage,
            int offset); int findNumberOfMessagesByHistory(MessageDVO data); int updateTimedOutMessageStatus(String status, Date currentTime); }
MessageDataSourceDAO extends DataSourceDAO implements MessageDAO { public int findNumberOfMessagesByHistory(MessageDVO data) throws DAOException { try { List parameters = new ArrayList(); String sql = super.getFinder("find_number_of_message_by_history"); if (data.getMessageId() != null && !data.getMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_id"); parameters.add(data.getMessageId()); } if (data.getMessageBox() != null && !data.getMessageBox().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_message_box"); parameters.add(data.getMessageBox()); } if (data.getCpaId() != null && !data.getCpaId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_cpa_id"); parameters.add(data.getCpaId()); } if (data.getService() != null && !data.getService().trim().equals("")) { sql += " AND " +getFilter("find_number_of_message_by_history_filter_service"); parameters.add(data.getService()); } if (data.getAction() != null && !data.getAction().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_action"); parameters.add(data.getAction()); } if (data.getStatus() != null && !data.getStatus().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_status"); parameters.add(data.getStatus()); } if (data.getConvId() != null && !data.getConvId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_conv_id"); parameters.add(data.getConvId()); } if (data.getPrimalMessageId() != null && !data.getPrimalMessageId().trim().equals("")) { sql += " AND " + getFilter("find_number_of_message_by_history_filter_primal_message_id"); parameters.add(data.getPrimalMessageId()); } List queryResult = executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) queryResult.get(0); return ((Number) resultEntry.get(0)).intValue(); } catch (Exception e) { throw new DAOException( "Unable to find the number of messages by history", e); } }  DVO createDVO(); boolean findMessage(MessageDVO data); void addMessage(MessageDVO data); void deleteMessage(MessageDVO data); boolean updateMessage(MessageDVO data); boolean findRefToMessage(MessageDVO data); List findMessagesByTime(int time_period, MessageDVO data, int numberOfMessage, int offset); List findMessagesBeforeTime(int time_period); List findInboxPendingMessagesByTimestamp(MessageDVO data); List findOutboxPendingMessagesByTimestamp(MessageDVO data); List findOutboxProcessingMessagesByTimestamp(MessageDVO data); List findMessageByCpa(MessageDVO data, int numberOfMessage); int findInboxReadyMaxSequenceNoByCpa(MessageDVO data); int findMaxSequenceNoByMessageBoxAndCpa(MessageDVO data); int findMaxSequenceGroupByMessageBoxAndCpa(MessageDVO data); int findNumOfMessagesByMessageBoxAndCpaAndSequenceGroup(
            MessageDVO data); boolean findOrderedMessageByMessageBoxAndCpaAndSequenceGroupAndSequenceNo(
            MessageDVO data); List findOrderedMessagesByMessageBoxAndCpaAndStatus(MessageDVO data); List findMessagesByHistory(MessageDVO data, int numberOfMessage,
            int offset); int findNumberOfMessagesByHistory(MessageDVO data); int updateTimedOutMessageStatus(String status, Date currentTime);  }