|
|
|
|
@ -46,7 +46,7 @@ public class CallHistoryServiceImpl
|
|
|
|
|
new String[] { "accountUID", "callStart", "callEnd", "dir",
|
|
|
|
|
"callParticipantIDs", "callParticipantStart",
|
|
|
|
|
"callParticipantEnd", "callParticipantStates", "callEndReason",
|
|
|
|
|
"callParticipantNames"};
|
|
|
|
|
"callParticipantNames", "secondaryCallParticipantIDs"};
|
|
|
|
|
|
|
|
|
|
private static HistoryRecordStructure recordStructure =
|
|
|
|
|
new HistoryRecordStructure(STRUCTURE_NAMES);
|
|
|
|
|
@ -75,6 +75,9 @@ public class CallHistoryServiceImpl
|
|
|
|
|
|
|
|
|
|
private HistoryReader historyReader;
|
|
|
|
|
|
|
|
|
|
private List<CallHistoryPeerRecordListener> callHistoryRecordlisteners
|
|
|
|
|
= new LinkedList<CallHistoryPeerRecordListener>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the underlying history service.
|
|
|
|
|
* @return the underlying history service
|
|
|
|
|
@ -685,6 +688,7 @@ private void writeCall( CallRecordImpl callRecord,
|
|
|
|
|
StringBuffer callPeerStartTime = new StringBuffer();
|
|
|
|
|
StringBuffer callPeerEndTime = new StringBuffer();
|
|
|
|
|
StringBuffer callPeerStates = new StringBuffer();
|
|
|
|
|
StringBuffer callPeerSecondaryIDs = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
for (CallPeerRecord item : callRecord
|
|
|
|
|
.getPeerRecords())
|
|
|
|
|
@ -696,6 +700,7 @@ private void writeCall( CallRecordImpl callRecord,
|
|
|
|
|
callPeerStartTime.append(DELIM);
|
|
|
|
|
callPeerEndTime.append(DELIM);
|
|
|
|
|
callPeerStates.append(DELIM);
|
|
|
|
|
callPeerSecondaryIDs.append(DELIM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
callPeerIDs.append(item.getPeerAddress());
|
|
|
|
|
@ -703,6 +708,10 @@ private void writeCall( CallRecordImpl callRecord,
|
|
|
|
|
callPeerStartTime.append(sdf.format(item.getStartTime()));
|
|
|
|
|
callPeerEndTime.append(sdf.format(item.getEndTime()));
|
|
|
|
|
callPeerStates.append(item.getState().getStateString());
|
|
|
|
|
callPeerSecondaryIDs.append(
|
|
|
|
|
item.getPeerSecondaryAddress() == null?
|
|
|
|
|
"" : item.getPeerSecondaryAddress());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
historyWriter.addRecord(new String[] {
|
|
|
|
|
@ -716,7 +725,8 @@ private void writeCall( CallRecordImpl callRecord,
|
|
|
|
|
callPeerEndTime.toString(),
|
|
|
|
|
callPeerStates.toString(),
|
|
|
|
|
String.valueOf(callRecord.getEndReason()),
|
|
|
|
|
callPeerNames.toString()},
|
|
|
|
|
callPeerNames.toString(),
|
|
|
|
|
callPeerSecondaryIDs.toString()},
|
|
|
|
|
new Date()); // this date is when the history
|
|
|
|
|
// record is written
|
|
|
|
|
}
|
|
|
|
|
@ -871,6 +881,54 @@ public void removeSearchProgressListener(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adding <tt>CallHistoryRecordListener</tt> listener to the list.
|
|
|
|
|
*
|
|
|
|
|
* @param listener CallHistoryRecordListener
|
|
|
|
|
*/
|
|
|
|
|
public void addCallHistoryRecordListener(CallHistoryPeerRecordListener
|
|
|
|
|
listener)
|
|
|
|
|
{
|
|
|
|
|
synchronized (callHistoryRecordlisteners)
|
|
|
|
|
{
|
|
|
|
|
callHistoryRecordlisteners.add(listener);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removing <tt>CallHistoryRecordListener</tt> listener
|
|
|
|
|
*
|
|
|
|
|
* @param listener CallHistoryRecordListener
|
|
|
|
|
*/
|
|
|
|
|
public void removeCallHistoryRecordListener(
|
|
|
|
|
CallHistoryPeerRecordListener listener)
|
|
|
|
|
{
|
|
|
|
|
synchronized(callHistoryRecordlisteners){
|
|
|
|
|
callHistoryRecordlisteners.remove(listener);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fires the given event to all <tt>CallHistoryRecordListener</tt> listeners
|
|
|
|
|
* @param event the <tt>CallHistoryRecordReceivedEvent</tt> event to be
|
|
|
|
|
* fired
|
|
|
|
|
*/
|
|
|
|
|
private void fireCallHistoryRecordReceivedEvent(
|
|
|
|
|
CallHistoryPeerRecordEvent event)
|
|
|
|
|
{
|
|
|
|
|
List<CallHistoryPeerRecordListener> tmpListeners;
|
|
|
|
|
synchronized (callHistoryRecordlisteners)
|
|
|
|
|
{
|
|
|
|
|
tmpListeners = new LinkedList<CallHistoryPeerRecordListener>(
|
|
|
|
|
callHistoryRecordlisteners);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(CallHistoryPeerRecordListener listener : tmpListeners)
|
|
|
|
|
{
|
|
|
|
|
listener.callPeerRecordReceived(event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add the registered CallHistorySearchProgressListeners to the given
|
|
|
|
|
* HistoryReader
|
|
|
|
|
@ -990,6 +1048,8 @@ public void peerStateChanged(CallPeerChangeEvent evt)
|
|
|
|
|
newRec.setDisplayName(callPeer.getDisplayName());
|
|
|
|
|
|
|
|
|
|
callRecord.getPeerRecords().add(newRec);
|
|
|
|
|
fireCallHistoryRecordReceivedEvent(new CallHistoryPeerRecordEvent(
|
|
|
|
|
callPeer.getAddress(), startDate));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -1025,6 +1085,152 @@ private void handlePeerRemoved( CallPeer callPeer,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the secondary address field of call record.
|
|
|
|
|
* @param date the start date of the record which will be updated.
|
|
|
|
|
* @param peer the peer of the record which will be updated.
|
|
|
|
|
* @param address the value of the secondary address .
|
|
|
|
|
*/
|
|
|
|
|
public void updateCallRecordPeerSecondaryAddress(final Date date,
|
|
|
|
|
final CallPeer peer,
|
|
|
|
|
final String address)
|
|
|
|
|
{
|
|
|
|
|
CallRecord record = findCallRecord(peer.getCall());
|
|
|
|
|
if(record != null)
|
|
|
|
|
{
|
|
|
|
|
for(CallPeerRecord peerRecord : record.getPeerRecords())
|
|
|
|
|
{
|
|
|
|
|
if(peerRecord.getPeerAddress().equals(peer.getAddress()))
|
|
|
|
|
{
|
|
|
|
|
peerRecord.setPeerSecondaryAddress(address);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
History history;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
history = this.getHistory(null, null);
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e)
|
|
|
|
|
{
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
HistoryWriter historyWriter = history.getWriter();
|
|
|
|
|
|
|
|
|
|
HistoryWriter.HistoryRecordUpdater updater = new HistoryWriter.HistoryRecordUpdater()
|
|
|
|
|
{
|
|
|
|
|
private HistoryRecord record;
|
|
|
|
|
|
|
|
|
|
private int dateIndex;
|
|
|
|
|
|
|
|
|
|
private int peerIDIndex;
|
|
|
|
|
|
|
|
|
|
private int peerSecondaryIDIndex;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setHistoryRecord(HistoryRecord historyRecord)
|
|
|
|
|
{
|
|
|
|
|
record = historyRecord;
|
|
|
|
|
String propertyNames[] = record.getPropertyNames();
|
|
|
|
|
for(int i = 0; i < propertyNames.length; i++)
|
|
|
|
|
{
|
|
|
|
|
if(propertyNames[i].equals(STRUCTURE_NAMES[5]))
|
|
|
|
|
{
|
|
|
|
|
dateIndex = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(propertyNames[i].equals(STRUCTURE_NAMES[4]))
|
|
|
|
|
{
|
|
|
|
|
peerIDIndex = i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(propertyNames[i].equals(STRUCTURE_NAMES[10]))
|
|
|
|
|
{
|
|
|
|
|
peerSecondaryIDIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isMatching()
|
|
|
|
|
{
|
|
|
|
|
String[] propertyVlaues = record.getPropertyValues();
|
|
|
|
|
List<String> peerIDs
|
|
|
|
|
= getCSVs(propertyVlaues[peerIDIndex]);
|
|
|
|
|
|
|
|
|
|
int i = peerIDs.indexOf(peer.getAddress());
|
|
|
|
|
if(i == -1)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String dateString = getCSVs(propertyVlaues[dateIndex]).get(i);
|
|
|
|
|
SimpleDateFormat sdf
|
|
|
|
|
= new SimpleDateFormat(HistoryService.DATE_FORMAT);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if(!sdf.parse(dateString).equals(date))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
catch (ParseException e)
|
|
|
|
|
{
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String secondaryID
|
|
|
|
|
= getCSVs(propertyVlaues[peerSecondaryIDIndex]).get(i);
|
|
|
|
|
if(secondaryID != null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, String> getUpdateChanges()
|
|
|
|
|
{
|
|
|
|
|
String[] propertyVlaues = record.getPropertyValues();
|
|
|
|
|
List<String> peerIDs
|
|
|
|
|
= getCSVs(propertyVlaues[peerIDIndex]);
|
|
|
|
|
|
|
|
|
|
int i = peerIDs.indexOf(peer.getAddress());
|
|
|
|
|
if(i == -1)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
List<String> secondaryID
|
|
|
|
|
= getCSVs(record.getPropertyValues()[peerSecondaryIDIndex]);
|
|
|
|
|
secondaryID.set(i, peer.getAddress());
|
|
|
|
|
String res = "";
|
|
|
|
|
int j = 0;
|
|
|
|
|
for(String id : secondaryID)
|
|
|
|
|
{
|
|
|
|
|
if(j++ != 0)
|
|
|
|
|
res += DELIM;
|
|
|
|
|
res += id;
|
|
|
|
|
}
|
|
|
|
|
Map<String, String> changesMap = new HashMap<String, String>();
|
|
|
|
|
changesMap.put(STRUCTURE_NAMES[10], res);
|
|
|
|
|
return changesMap;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
historyWriter.updateRecord(updater);
|
|
|
|
|
}
|
|
|
|
|
catch (IOException e)
|
|
|
|
|
{
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Finding a CallRecord for the given call
|
|
|
|
|
*
|
|
|
|
|
@ -1083,6 +1289,7 @@ private void handleNewCall(Call sourceCall, String direction)
|
|
|
|
|
|
|
|
|
|
currentCallRecords.add(newRecord);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if has already perticipants Dispatch them
|
|
|
|
|
Iterator<? extends CallPeer> iter = sourceCall.getCallPeers();
|
|
|
|
|
while (iter.hasNext())
|
|
|
|
|
|