use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class CallingStatsAction method getStatisticItems.
public List getStatisticItems() {
final List items = new ArrayList();
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
isCalculating = true;
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "calculating", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
final Properties stat = new Properties();
if (m_cl != null) {
ICaller caller = null;
Formatter formatter = Formatter.getInstance(getRuntime());
ICall c = null;
for (int i = 0; i < m_cl.size(); i++) {
c = m_cl.get(i);
if (isOutgoingCall(c)) {
caller = c.getCaller();
String displayName = formatter.parse("%a:ln%, %a:fn% (%a:add%)", caller);
if (displayName.trim().length() == 0)
displayName = formatter.parse("%a:city%", caller);
String number = formatter.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, caller);
String key = number;
// remove CRLF
displayName = StringUtils.replaceString(displayName, IJAMConst.CRLF, " ");
if (displayName.length() > 32)
displayName = displayName.substring(0, 29) + "...";
String value = stat.getProperty(key, "");
if (value.length() == 0) {
stat.setProperty(key.trim(), "1");
stat.setProperty(key + ".name", displayName);
stat.setProperty(key + ".number", number);
} else {
int val = new Integer(value).intValue();
val++;
stat.setProperty(key.trim(), new Integer(val).toString());
m_maxcount = Math.max(m_maxcount, val);
}
}
}
}
progressMonitor.worked(1);
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "createstatistic", "label", getLanguage()));
Iterator iter = stat.keySet().iterator();
String key = null;
String count = null;
while (iter.hasNext()) {
key = (String) iter.next();
if (!(key.endsWith(".name") || key.endsWith(".number"))) {
count = stat.getProperty(key, "");
items.add(new String[] { stat.getProperty(key + ".name"), stat.getProperty(key + ".number"), count });
}
}
stat.clear();
Collections.sort(items, new StatisticComparator());
progressMonitor.done();
isCalculating = false;
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
isCalculating = false;
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
isCalculating = false;
}
while (isCalculating) try {
Thread.sleep(250);
} catch (InterruptedException e) {
}
return items;
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class ImagePreviewBig method renderAsImageID.
public String renderAsImageID() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
if (ImageHandler.getInstance().hasImage((ICaller) this.m_o)) {
String path = ImageHandler.getInstance().getImagePath((ICaller) this.m_o);
if (new File(path).exists())
return path;
String newPath = PathResolver.getInstance().getTempDirectory() + File.separator + ((ICaller) this.m_o).getUUID() + ".jpg";
try {
FileOutputStream fos = new FileOutputStream(newPath);
InputStream imgin = ImageHandler.getInstance().getImageStream((ICaller) this.m_o);
Stream.copy(imgin, fos, true);
return newPath;
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class GeoCoding method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
IAttributeMap m = ((ICaller) (this.m_o)).getAttributes();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_GEO_LAT) && m.contains(IJAMConst.ATTRIBUTE_NAME_GEO_LNG)) {
StringBuffer co = new StringBuffer();
co.append(getLatitute(m.get(IJAMConst.ATTRIBUTE_NAME_GEO_LAT).getValue()));
co.append(", ");
co.append(getLongitute(m.get(IJAMConst.ATTRIBUTE_NAME_GEO_LNG).getValue()));
return co.toString();
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class ImageBase64 method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
if (ImageHandler.getInstance().hasImage((ICaller) this.m_o)) {
try {
InputStream fim = ImageHandler.getInstance().getImageStream((ICaller) this.m_o);
ByteArrayOutputStream encodedOut = new ByteArrayOutputStream();
Base64Encoder b64 = new Base64Encoder(encodedOut);
Stream.copy(fim, b64);
b64.flush();
b64.close();
return new String(encodedOut.toByteArray());
} catch (IOException e) {
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class CallSimulator method sendEvent.
protected void sendEvent(String number, String msn, String cip) {
if (number != null && number.length() > 0)
number = PhonenumberAnalyzer.getInstance(this.getRuntime()).toCallable(number);
if (!number.startsWith("0") && isRaw) {
number = "0" + number;
}
IEventBroker evtBroker = this.getRuntime().getEventBroker();
evtBroker.register(this);
evtBroker.register(this, evtBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
IPhonenumber phone = PhonenumberAnalyzer.getInstance(this.getRuntime()).toClirPhonenumber(number);
if (phone == null)
phone = PhonenumberAnalyzer.getInstance(this.getRuntime()).toInternalPhonenumber(number, msn);
if (phone == null)
phone = PhonenumberAnalyzer.getInstance(this.getRuntime()).toPhonenumber(number, msn);
IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
ICaller aCaller = PIMRuntime.getInstance().getCallerFactory().createCaller(name, phone);
ICip ocip = PIMRuntime.getInstance().getCallFactory().createCip(cip, "");
IMsn omsn = PIMRuntime.getInstance().getCallFactory().createMsn(msn, "");
ICall currentCall = PIMRuntime.getInstance().getCallFactory().createCall(aCaller, omsn, ocip);
currentCall.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
IEvent ev = evtBroker.createEvent(IEventConst.EVENT_TYPE_INCOMINGCALL, currentCall);
evtBroker.send(this, ev);
evtBroker.unregister(this);
}
Aggregations