@Test public void testFindNumOfSegmentByMessageIdAndBoxAndTypeAndStatues() throws Exception{ SFRMMessageSegmentDAO dao = this.getTestingTarget(); List statues = new ArrayList(); statues.add("PS"); statues.add("DL"); Calendar cal = Calendar.getInstance(); cal.set(2008, 9-1, 19); long numBytes = dao.findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues("testFindNumOfSegmentByMessageIdAndBoxAndTypeAndStatues", SFRMConstant.MSGBOX_OUT, SFRMConstant.MSGT_PAYLOAD, cal.getTimeInMillis(), statues); Assert.assertEquals("Number of segment which is in PS and DL status should be 100", 100, numBytes); }
public long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues( String messageId, String messageBox, String type, long proceedTime, List<String> statues) throws DAOException{ if(statues == null || statues.size() == 0) throw new DAOException("Status should not be NULL"); String sql = super.getFinder("find_num_of_bytes_by_msgid_msgbox_type_statues"); String filter = super.getFilter("find_num_of_bytes_by_msgid_msgbox_type_statues_filter"); String questionToken = buildQuestionToken(statues.size()); filter = filter.replace("?", questionToken); sql += " AND " + filter; ArrayList parameters = new ArrayList(); parameters.add(messageId); parameters.add(messageBox); parameters.add(type); parameters.add(new Timestamp(proceedTime)); parameters.addAll(statues); List results = super.executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) results.get(0); if(resultEntry.get(0) == null) return 0L; return ((Number) resultEntry.get(0)).longValue(); }
SFRMMessageSegmentDSDAO extends DataSourceDAO implements
		SFRMMessageSegmentDAO { public long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues( String messageId, String messageBox, String type, long proceedTime, List<String> statues) throws DAOException{ if(statues == null || statues.size() == 0) throw new DAOException("Status should not be NULL"); String sql = super.getFinder("find_num_of_bytes_by_msgid_msgbox_type_statues"); String filter = super.getFilter("find_num_of_bytes_by_msgid_msgbox_type_statues_filter"); String questionToken = buildQuestionToken(statues.size()); filter = filter.replace("?", questionToken); sql += " AND " + filter; ArrayList parameters = new ArrayList(); parameters.add(messageId); parameters.add(messageBox); parameters.add(type); parameters.add(new Timestamp(proceedTime)); parameters.addAll(statues); List results = super.executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) results.get(0); if(resultEntry.get(0) == null) return 0L; return ((Number) resultEntry.get(0)).longValue(); } }
SFRMMessageSegmentDSDAO extends DataSourceDAO implements
		SFRMMessageSegmentDAO { public long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues( String messageId, String messageBox, String type, long proceedTime, List<String> statues) throws DAOException{ if(statues == null || statues.size() == 0) throw new DAOException("Status should not be NULL"); String sql = super.getFinder("find_num_of_bytes_by_msgid_msgbox_type_statues"); String filter = super.getFilter("find_num_of_bytes_by_msgid_msgbox_type_statues_filter"); String questionToken = buildQuestionToken(statues.size()); filter = filter.replace("?", questionToken); sql += " AND " + filter; ArrayList parameters = new ArrayList(); parameters.add(messageId); parameters.add(messageBox); parameters.add(type); parameters.add(new Timestamp(proceedTime)); parameters.addAll(statues); List results = super.executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) results.get(0); if(resultEntry.get(0) == null) return 0L; return ((Number) resultEntry.get(0)).longValue(); }  }
SFRMMessageSegmentDSDAO extends DataSourceDAO implements
		SFRMMessageSegmentDAO { public long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues( String messageId, String messageBox, String type, long proceedTime, List<String> statues) throws DAOException{ if(statues == null || statues.size() == 0) throw new DAOException("Status should not be NULL"); String sql = super.getFinder("find_num_of_bytes_by_msgid_msgbox_type_statues"); String filter = super.getFilter("find_num_of_bytes_by_msgid_msgbox_type_statues_filter"); String questionToken = buildQuestionToken(statues.size()); filter = filter.replace("?", questionToken); sql += " AND " + filter; ArrayList parameters = new ArrayList(); parameters.add(messageId); parameters.add(messageBox); parameters.add(type); parameters.add(new Timestamp(proceedTime)); parameters.addAll(statues); List results = super.executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) results.get(0); if(resultEntry.get(0) == null) return 0L; return ((Number) resultEntry.get(0)).longValue(); }  DVO createDVO(); SFRMMessageSegmentDVO findMessageSegmentByMessageIdAndBoxAndType(
			String messageId, String messageBox, int segmentNo, String type); SFRMMessageSegmentDVO findLastUpdatedMessageSegmentByMessageIdAndBoxAndType(
			String 	messageId,
			String 	messageBox,
			String	type); List findMessageSegmentsByMessageBoxAndStatus(
			String messageBox, String status, int limit); List findMessageSegmentsByMessageBoxAndStatusAndMessageStatusNotEqualTo(
			String messageBox, String status, String messageStatus, int limit); List findMessageSegmentByMessageBoxAndStatusAndTypeAndMessageStatusNotEqualTo(
			String 	messageBox, 
			String 	status, 
			String  type,
			String 	messageStatus, 
			int 	limit); List findIncompleteSegments(
			String messageBox,
			String status,
			String type,
			int    limit); int findNumOfSegmentByMessageIdAndBoxAndTypeAndStatus(
			String messageId, 
			String messageBox, 
			String type, 
			String status); List findSegmentsByMessageIdAndBoxAndTypeAndStatus(
			String messageId, 
			String messageBox,
			String type, 
			String status); int findMaxSegmentNoByMessageIdAndBoxAndType(
			String messageId,
			String messageBox,
			String type); List findSegmentByMessageIdAndBoxAndTypeAndNos(
			String messageId,
			String messageBox,
			String type,
			List<Integer> segmentNos
			); int updateBatchSegmentsRecoveryStatus(
			String status, 
			String messageId,
			String messageBox,
			String segmentType,
			List<Integer> segNums); int updateBatchSegmentsStatus(
			String status,
			Timestamp completeTime,
			String messageId,
			String messageBox,
			String segmentType,
			List<Integer> segNums); long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues(
			String messageId, 
			String messageBox,
			String type, 
			long proceedTime,
			List<String> statues); }
SFRMMessageSegmentDSDAO extends DataSourceDAO implements
		SFRMMessageSegmentDAO { public long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues( String messageId, String messageBox, String type, long proceedTime, List<String> statues) throws DAOException{ if(statues == null || statues.size() == 0) throw new DAOException("Status should not be NULL"); String sql = super.getFinder("find_num_of_bytes_by_msgid_msgbox_type_statues"); String filter = super.getFilter("find_num_of_bytes_by_msgid_msgbox_type_statues_filter"); String questionToken = buildQuestionToken(statues.size()); filter = filter.replace("?", questionToken); sql += " AND " + filter; ArrayList parameters = new ArrayList(); parameters.add(messageId); parameters.add(messageBox); parameters.add(type); parameters.add(new Timestamp(proceedTime)); parameters.addAll(statues); List results = super.executeRawQuery(sql, parameters.toArray()); List resultEntry = (List) results.get(0); if(resultEntry.get(0) == null) return 0L; return ((Number) resultEntry.get(0)).longValue(); }  DVO createDVO(); SFRMMessageSegmentDVO findMessageSegmentByMessageIdAndBoxAndType(
			String messageId, String messageBox, int segmentNo, String type); SFRMMessageSegmentDVO findLastUpdatedMessageSegmentByMessageIdAndBoxAndType(
			String 	messageId,
			String 	messageBox,
			String	type); List findMessageSegmentsByMessageBoxAndStatus(
			String messageBox, String status, int limit); List findMessageSegmentsByMessageBoxAndStatusAndMessageStatusNotEqualTo(
			String messageBox, String status, String messageStatus, int limit); List findMessageSegmentByMessageBoxAndStatusAndTypeAndMessageStatusNotEqualTo(
			String 	messageBox, 
			String 	status, 
			String  type,
			String 	messageStatus, 
			int 	limit); List findIncompleteSegments(
			String messageBox,
			String status,
			String type,
			int    limit); int findNumOfSegmentByMessageIdAndBoxAndTypeAndStatus(
			String messageId, 
			String messageBox, 
			String type, 
			String status); List findSegmentsByMessageIdAndBoxAndTypeAndStatus(
			String messageId, 
			String messageBox,
			String type, 
			String status); int findMaxSegmentNoByMessageIdAndBoxAndType(
			String messageId,
			String messageBox,
			String type); List findSegmentByMessageIdAndBoxAndTypeAndNos(
			String messageId,
			String messageBox,
			String type,
			List<Integer> segmentNos
			); int updateBatchSegmentsRecoveryStatus(
			String status, 
			String messageId,
			String messageBox,
			String segmentType,
			List<Integer> segNums); int updateBatchSegmentsStatus(
			String status,
			Timestamp completeTime,
			String messageId,
			String messageBox,
			String segmentType,
			List<Integer> segNums); long findNumOfBytesSentByMessageIdAndBoxAndTypeAndStatues(
			String messageId, 
			String messageBox,
			String type, 
			long proceedTime,
			List<String> statues);  }