fix two new methods and change their names

cusax-fix
Damian Minkov 19 years ago
parent 956a627bed
commit 5a8efd5b8e

@ -311,7 +311,7 @@ public synchronized QueryResultSet findByPeriod(Date startDate, Date endDate,
* @return QueryResultSet the found records
* @throws RuntimeException
*/
public QueryResultSet getFirstRecordsAfter(Date date, int count) throws
public QueryResultSet findFirstRecordsAfter(Date date, int count) throws
RuntimeException
{
TreeSet result = new TreeSet(new HistoryRecordComparator());
@ -404,7 +404,7 @@ public QueryResultSet getFirstRecordsAfter(Date date, int count) throws
* @return QueryResultSet the found records
* @throws RuntimeException
*/
public QueryResultSet getLastRecordsBefore(Date date, int count) throws
public QueryResultSet findLastRecordsBefore(Date date, int count) throws
RuntimeException
{
// the files are supposed to be ordered from oldest to newest
@ -413,6 +413,7 @@ public QueryResultSet getLastRecordsBefore(Date date, int count) throws
TreeSet result = new TreeSet(new HistoryRecordComparator());
int leftCount = count;
int currentFile = filelist.size() - 1;
while(leftCount > 0 && currentFile >= 0)
@ -429,7 +430,7 @@ public QueryResultSet getLastRecordsBefore(Date date, int count) throws
NodeList nodes = doc.getElementsByTagName("record");
Node node;
for (int i = 0; i < nodes.getLength() && leftCount > 0; i++)
for (int i = nodes.getLength() - 1; i >= 0 && leftCount > 0; i--)
{
node = nodes.item(i);
NodeList propertyNodes = node.getChildNodes();
@ -686,8 +687,6 @@ private boolean matchKeyword(String value, String[] keywords,
* Used to limit the files if any starting or ending date exist
* So only few files to be searched.
*
* Start or end date must not be equals to null
*
* @param filelist Iterator
* @param startDate Date
* @param endDate Date
@ -716,7 +715,7 @@ private Vector filterFilesByDate(
new Long(filename.substring(0, filename.length() - 4)));
}
Vector resultAsLong = new Vector();
TreeSet resultAsLong = new TreeSet();
// if there is no startDate limit only to end date
if(startDate == null)
@ -725,6 +724,7 @@ private Vector filterFilesByDate(
files.add(endLong);
resultAsLong.addAll(files.subSet(files.first(), endLong));
resultAsLong.remove(endLong);
}
else if(endDate == null)
@ -732,13 +732,12 @@ else if(endDate == null)
// end date is null get all the inclusive the one record before the startdate
Long startLong = new Long(startDate.getTime());
files.add(startLong);
resultAsLong.addAll(files.subSet(startLong, files.last()));
resultAsLong.addAll(files.subSet(startLong, files.last()));
resultAsLong.add(files.last());
// here we must get and the element before startLong
resultAsLong.add(files.subSet(files.first(), startLong).last());
resultAsLong.remove(startLong);
}
else

@ -304,7 +304,7 @@ public Collection findLast(MetaContact contact, int count)
* @return Collection of MessageReceivedEvents or MessageDeliveredEvents
* @throws RuntimeException
*/
public Collection getFirstMessagesAfter(MetaContact contact, Date date,
public Collection findFirstMessagesAfter(MetaContact contact, Date date,
int count) throws RuntimeException
{
TreeSet result = new TreeSet(new MessageEventComparator());
@ -319,7 +319,7 @@ public Collection getFirstMessagesAfter(MetaContact contact, Date date,
History history = this.getHistory(null, item);
HistoryReader reader = history.getReader();
Iterator recs = reader.getFirstRecordsAfter(date, count);
Iterator recs = reader.findFirstRecordsAfter(date, count);
while (recs.hasNext())
{
result.add(
@ -354,7 +354,7 @@ public Collection getFirstMessagesAfter(MetaContact contact, Date date,
* @return Collection of MessageReceivedEvents or MessageDeliveredEvents
* @throws RuntimeException
*/
public Collection getLastMessagesBefore(MetaContact contact, Date date,
public Collection findLastMessagesBefore(MetaContact contact, Date date,
int count) throws RuntimeException
{
TreeSet result = new TreeSet(new MessageEventComparator());
@ -369,7 +369,7 @@ public Collection getLastMessagesBefore(MetaContact contact, Date date,
History history = this.getHistory(null, item);
HistoryReader reader = history.getReader();
Iterator recs = reader.getLastRecordsBefore(date, count);
Iterator recs = reader.findLastRecordsBefore(date, count);
while (recs.hasNext())
{
result.add(

@ -159,7 +159,7 @@ public QueryResultSet findByPeriod(Date startDate, Date endDate,
* @return QueryResultSet the found records
* @throws RuntimeException
*/
public QueryResultSet getFirstRecordsAfter(Date date, int count) throws RuntimeException;
public QueryResultSet findFirstRecordsAfter(Date date, int count) throws RuntimeException;
/**
* Returns the supplied number of recent messages before the given date
@ -169,7 +169,7 @@ public QueryResultSet findByPeriod(Date startDate, Date endDate,
* @return QueryResultSet the found records
* @throws RuntimeException
*/
public QueryResultSet getLastRecordsBefore(Date date, int count) throws RuntimeException;
public QueryResultSet findLastRecordsBefore(Date date, int count) throws RuntimeException;
/**
* Adding progress listener for monitoring progress of search process

@ -160,7 +160,7 @@ public Collection findLast(MetaContact contact, int count)
* @return Collection of MessageReceivedEvents or MessageDeliveredEvents
* @throws RuntimeException
*/
public Collection getFirstMessagesAfter(MetaContact contact, Date date, int count)
public Collection findFirstMessagesAfter(MetaContact contact, Date date, int count)
throws RuntimeException;
/**
@ -173,7 +173,7 @@ public Collection getFirstMessagesAfter(MetaContact contact, Date date, int coun
* @return Collection of MessageReceivedEvents or MessageDeliveredEvents
* @throws RuntimeException
*/
public Collection getLastMessagesBefore(MetaContact contact, Date date, int count)
public Collection findLastMessagesBefore(MetaContact contact, Date date, int count)
throws RuntimeException;
/**

@ -156,11 +156,11 @@ public void setupContact()
messagesToSend = new Message[]
{
mockBImOpSet.createMessage("test message word1"),
mockBImOpSet.createMessage("test message word2"),
mockBImOpSet.createMessage("test message word3"),
mockBImOpSet.createMessage("test message word4"),
mockBImOpSet.createMessage("test message word5")
mockBImOpSet.createMessage("test message word1-" + Math.random()),
mockBImOpSet.createMessage("test message word2" + Math.random()),
mockBImOpSet.createMessage("test message word3" + Math.random()),
mockBImOpSet.createMessage("test message word4" + Math.random()),
mockBImOpSet.createMessage("test message word5" + Math.random())
};
}
@ -340,7 +340,7 @@ public void readRecords()
/**
* Must return exactly the 3 messages after controlDate1
*/
rs = msgHistoryService.getFirstMessagesAfter(testMetaContact, controlDate1, 3);
rs = msgHistoryService.findFirstMessagesAfter(testMetaContact, controlDate1, 3);
assertTrue("Nothing found 9", !rs.isEmpty());
msgs = getMessages(rs);
@ -355,7 +355,7 @@ public void readRecords()
/**
* Must return exactly the 3 messages before controlDate2
*/
rs = msgHistoryService.getLastMessagesBefore(testMetaContact, controlDate2, 3);
rs = msgHistoryService.findLastMessagesBefore(testMetaContact, controlDate2, 3);
assertTrue("Nothing found 10", !rs.isEmpty());
msgs = getMessages(rs);

Loading…
Cancel
Save