Improve CallHistory result objects

cusax-fix
Damian Minkov 20 years ago
parent 023e382a41
commit c239edb6cc

@ -73,7 +73,8 @@ public HistoryService getHistoryService()
* Returns all the calls made by all the contacts
* in the supplied metacontact after the given date
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param startDate Date the start date of the calls
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
@ -91,7 +92,7 @@ public Collection findByStartDate(MetaContact contact, Date startDate)
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
public Collection findByStartDate(Date startDate) throws RuntimeException
public Collection findByStartDate(Date startDate)
{
TreeSet result = new TreeSet(new CallRecordComparator());
try
@ -120,7 +121,8 @@ public Collection findByStartDate(Date startDate) throws RuntimeException
* Returns all the calls made by all the contacts
* in the supplied metacontact before the given date
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param endDate Date the end date of the calls
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
@ -217,7 +219,8 @@ public Collection findByPeriod(Date startDate, Date endDate) throws
* Returns the supplied number of calls by all the contacts
* in the supplied metacontact
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param count calls count
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
@ -257,6 +260,40 @@ public Collection findLast(int count) throws RuntimeException
return result;
}
/**
* Find the calls made by the supplied participant address
* @param address String the address of the participant
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
public Collection findByParticipant(String address)
throws RuntimeException
{
TreeSet result = new TreeSet(new CallRecordComparator());
try
{
// the default ones
History history = this.getHistory(null, null);
HistoryReader reader = history.getReader();
addHistorySearchProgressListeners(reader, 1);
QueryResultSet rs =
reader.findByKeyword(address, "callParticipantIDs");
while (rs.hasNext())
{
HistoryRecord hr = (HistoryRecord) rs.next();
result.add(convertHistoryRecordToCallRecord(hr));
}
removeHistorySearchProgressListeners(reader);
}
catch (IOException ex)
{
logger.error("Could not read history", ex);
}
return result;
}
/**
* Returns the history by specified local and remote contact
* if one of them is null the default is used
@ -298,7 +335,7 @@ private History getHistory(Contact localContact, Contact remoteContact)
*/
private Object convertHistoryRecordToCallRecord(HistoryRecord hr)
{
CallRecord result = new CallRecord();
CallRecordImpl result = new CallRecordImpl();
LinkedList callParticipantIDs = null;
LinkedList callParticipantStart = null;
@ -694,7 +731,7 @@ public void callEnded(CallEvent event)
logger.info("callEnded");
Date endTime = new Date();
CallRecord callRecord = findCallRecord(event.getSourceCall());
CallRecordImpl callRecord = findCallRecord(event.getSourceCall());
// no such call
if (callRecord == null)
@ -738,8 +775,8 @@ private void handleParticipantRemoved(CallParticipant callParticipant,
CallRecord callRecord = findCallRecord(srcCall);
String pAddress = callParticipant.getAddress();
CallParticipantRecord cpRecord =
callRecord.findParticipantRecord(pAddress);
CallParticipantRecordImpl cpRecord =
(CallParticipantRecordImpl)callRecord.findParticipantRecord(pAddress);
// no such participant
if(cpRecord == null)
@ -753,12 +790,12 @@ private void handleParticipantRemoved(CallParticipant callParticipant,
* @param call Call
* @return CallRecord
*/
private CallRecord findCallRecord(Call call)
private CallRecordImpl findCallRecord(Call call)
{
Iterator iter = currentCallRecords.iterator();
while (iter.hasNext())
{
CallRecord item = (CallRecord) iter.next();
CallRecordImpl item = (CallRecordImpl) iter.next();
if(item.getSourceCall().equals(call))
return item;
}
@ -777,11 +814,11 @@ private void handleNewCall(Call sourceCall, String direction)
if(currentCallRecords.contains(sourceCall))
return;
CallRecord newRecord = new CallRecord(
sourceCall,
CallRecordImpl newRecord = new CallRecordImpl(
direction,
new Date(),
null);
newRecord.setSourceCall(sourceCall);
sourceCall.addCallChangeListener(historyCallChangeListener);
@ -862,8 +899,6 @@ void clear()
}
}
/**
* Used to compare CallRecords
* and to be ordered in TreeSet according their timestamp
@ -873,8 +908,8 @@ private class CallRecordComparator
{
public int compare(Object o1, Object o2)
{
return ((CallRecord)o1).getStartTime().
compareTo(((CallRecord)o2).getStartTime());
return ((CallRecord)o2).getStartTime().
compareTo(((CallRecord)o1).getStartTime());
}
}

@ -0,0 +1,54 @@
package net.java.sip.communicator.impl.callhistory;
import java.util.*;
import net.java.sip.communicator.service.callhistory.*;
/**
* Added some setters to CallParticipantRecord
* @author Damian Minkov
*/
public class CallParticipantRecordImpl
extends CallParticipantRecord
{
/**
* Creates CallParticipantRecord
* @param participantAddress String
* @param startTime Date
* @param endTime Date
*/
public CallParticipantRecordImpl(
String participantAddress,
Date startTime,
Date endTime)
{
super(participantAddress, startTime, endTime);
}
/**
* Sets the time the participant joined the call
* @param startTime Date
*/
public void setStartTime(Date startTime)
{
this.startTime = startTime;
}
/**
* Sets the particiapnts address
* @param participantAddress String
*/
public void setParticipantAddress(String participantAddress)
{
this.participantAddress = participantAddress;
}
/**
* Sets the time participant leaves the call
* @param endTime Date
*/
public void setEndTime(Date endTime)
{
this.endTime = endTime;
}
}

@ -0,0 +1,93 @@
package net.java.sip.communicator.impl.callhistory;
import java.util.*;
import net.java.sip.communicator.service.callhistory.*;
import net.java.sip.communicator.service.protocol.*;
/**
* Add Source call to the CallRecord
* @author Damian Minkov
*/
public class CallRecordImpl
extends CallRecord
{
private Call sourceCall = null;
/**
* Creates CallRecord
*/
public CallRecordImpl()
{
super();
}
/**
* Creates Call Record
* @param direction String
* @param startTime Date
* @param endTime Date
*/
public CallRecordImpl(
String direction,
Date startTime,
Date endTime)
{
super(direction, startTime, endTime);
}
/**
* The Call source of this record
* @return Call
*/
public Call getSourceCall()
{
return sourceCall;
}
/**
* Set the time when the call finishes
* If some participant has no end Time set we set it also
* @param endTime Date
*/
public void setEndTime(Date endTime)
{
this.endTime = endTime;
Iterator iter = participantRecords.iterator();
while (iter.hasNext())
{
CallParticipantRecordImpl item = (CallParticipantRecordImpl) iter.next();
if(item.getEndTime() == null)
item.setEndTime(endTime);
}
}
/**
* Sets the time when the call begins
* @param startTime Date
*/
public void setStartTime(Date startTime)
{
this.startTime = startTime;
}
/**
* The source call which this record servers
* @param sourceCall Call
*/
public void setSourceCall(Call sourceCall)
{
this.sourceCall = sourceCall;
}
/**
* Sets the direction of the call
* IN or OUT
* @param direction String
*/
public void setDirection(String direction)
{
this.direction = direction;
}
}

@ -23,37 +23,40 @@ public interface CallHistoryService
* Returns all the calls made by all the contacts
* in the supplied metacontact after the given date
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param startDate Date the start date of the calls
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findByStartDate(MetaContact contact, Date startDate)
public Collection findByStartDate(MetaContact contact, Date startDate)
throws RuntimeException;
/**
* Returns all the calls made by all the contacts
* in the supplied metacontact before the given date
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param endDate Date the end date of the calls
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findByEndDate(MetaContact contact, Date endDate)
public Collection findByEndDate(MetaContact contact, Date endDate)
throws RuntimeException;
/**
* Returns all the calls made by all the contacts
* in the supplied metacontact between the given dates
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param startDate Date the start date of the calls
* @param endDate Date the end date of the calls
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findByPeriod(MetaContact contact, Date startDate, Date endDate)
public Collection findByPeriod(MetaContact contact, Date startDate, Date endDate)
throws RuntimeException;
@ -61,20 +64,20 @@ Collection findByPeriod(MetaContact contact, Date startDate, Date endDate)
* Returns all the calls made after the given date
*
* @param startDate Date the start date of the calls
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findByStartDate(Date startDate)
public Collection findByStartDate(Date startDate)
throws RuntimeException;
/**
* Returns all the calls made before the given date
*
* @param endDate Date the end date of the calls
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findByEndDate(Date endDate)
public Collection findByEndDate(Date endDate)
throws RuntimeException;
/**
@ -82,22 +85,23 @@ Collection findByEndDate(Date endDate)
*
* @param startDate Date the start date of the calls
* @param endDate Date the end date of the calls
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findByPeriod(Date startDate, Date endDate)
public Collection findByPeriod(Date startDate, Date endDate)
throws RuntimeException;
/**
* Returns the supplied number of recent calls made by all the contacts
* in the supplied metacontact
*
* @param contact MetaContact
* @param contact MetaContact which contacts participate in
* the returned calls
* @param count calls count
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findLast(MetaContact contact, int count)
public Collection findLast(MetaContact contact, int count)
throws RuntimeException;
/**
@ -105,24 +109,32 @@ Collection findLast(MetaContact contact, int count)
* in the supplied metacontact
*
* @param count calls count
* @return Collection of CallReceivedEvent
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
Collection findLast(int count)
public Collection findLast(int count)
throws RuntimeException;
/**
* Find the calls made by the supplied participant address
* @param address String the address of the participant
* @return Collection of CallRecords with CallParticipantRecord
* @throws RuntimeException
*/
public Collection findByParticipant(String address)
throws RuntimeException;
/**
* Adding progress listener for monitoring progress of search process
*
* @param listener HistorySearchProgressListener
*/
void addSearchProgressListener(CallHistorySearchProgressListener listener);
public void addSearchProgressListener(CallHistorySearchProgressListener listener);
/**
* Removing progress listener
*
* @param listener HistorySearchProgressListener
*/
void removeSearchProgressListener(CallHistorySearchProgressListener listener);
public void removeSearchProgressListener(CallHistorySearchProgressListener listener);
}

@ -11,9 +11,9 @@
*/
public class CallParticipantRecord
{
private String participantAddress = null;
private Date startTime = null;
private Date endTime = null;
protected String participantAddress = null;
protected Date startTime = null;
protected Date endTime = null;
/**
* Creates CallParticipantRecord
@ -58,31 +58,4 @@ public Date getStartTime()
{
return startTime;
}
/**
* Sets the time the participant joined the call
* @param startTime Date
*/
public void setStartTime(Date startTime)
{
this.startTime = startTime;
}
/**
* Sets the particiapnts address
* @param participantAddress String
*/
public void setParticipantAddress(String participantAddress)
{
this.participantAddress = participantAddress;
}
/**
* Sets the time participant leaves the call
* @param endTime Date
*/
public void setEndTime(Date endTime)
{
this.endTime = endTime;
}
}

@ -2,8 +2,6 @@
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
/**
* Structure used for encapsulating data when writing or reading
* Call History Data. Also These records are uesd for returning data
@ -19,11 +17,10 @@ public class CallRecord
public final static String OUT = "out";
public final static String IN = "in";
private Call sourceCall = null;
private String direction = null;
private Vector participantRecords = new Vector();
private Date startTime = null;
private Date endTime = null;
protected String direction = null;
protected Vector participantRecords = new Vector();
protected Date startTime = null;
protected Date endTime = null;
/**
* Creates CallRecord
@ -34,18 +31,15 @@ public CallRecord()
/**
* Creates Call Record
* @param sourceCall Call
* @param direction String
* @param startTime Date
* @param endTime Date
*/
public CallRecord(
Call sourceCall,
String direction,
Date startTime,
Date endTime)
{
this.sourceCall = sourceCall;
this.direction = direction;
this.startTime = startTime;
this.endTime = endTime;
@ -69,52 +63,6 @@ public CallParticipantRecord findParticipantRecord(String address)
return null;
}
/**
* Set the time when the call finishes
* If some participant has no end Time set we set it also
* @param endTime Date
*/
public void setEndTime(Date endTime)
{
this.endTime = endTime;
Iterator iter = participantRecords.iterator();
while (iter.hasNext())
{
CallParticipantRecord item = (CallParticipantRecord) iter.next();
if(item.getEndTime() == null)
item.setEndTime(endTime);
}
}
/**
* Sets the time when the call begins
* @param startTime Date
*/
public void setStartTime(Date startTime)
{
this.startTime = startTime;
}
/**
* The source call which this record servers
* @param sourceCall Call
*/
public void setSourceCall(Call sourceCall)
{
this.sourceCall = sourceCall;
}
/**
* Sets the direction of the call
* IN or OUT
* @param direction String
*/
public void setDirection(String direction)
{
this.direction = direction;
}
/**
* Returns the direction of the call
* IN or OUT
@ -143,15 +91,6 @@ public Vector getParticipantRecords()
return participantRecords;
}
/**
* The Call source of this record
* @return Call
*/
public Call getSourceCall()
{
return sourceCall;
}
/**
* The time when the call has began
* @return Date

Loading…
Cancel
Save