Search in sources :

Example 71 with ICaller

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;
}
Also used : ICall(de.janrufmonitor.framework.ICall) Formatter(de.janrufmonitor.util.formatter.Formatter) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) Properties(java.util.Properties) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List)

Example 72 with ICaller

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 "";
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File)

Example 73 with ICaller

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 "";
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Example 74 with ICaller

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 "";
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICall(de.janrufmonitor.framework.ICall) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Base64Encoder(de.janrufmonitor.util.io.Base64Encoder)

Example 75 with ICaller

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);
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICip(de.janrufmonitor.framework.ICip) ICall(de.janrufmonitor.framework.ICall) IEvent(de.janrufmonitor.framework.event.IEvent) IName(de.janrufmonitor.framework.IName) IMsn(de.janrufmonitor.framework.IMsn) IEventBroker(de.janrufmonitor.framework.event.IEventBroker) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

ICaller (de.janrufmonitor.framework.ICaller)144 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)62 ICallerList (de.janrufmonitor.framework.ICallerList)49 List (java.util.List)46 IAttribute (de.janrufmonitor.framework.IAttribute)42 ICall (de.janrufmonitor.framework.ICall)41 ArrayList (java.util.ArrayList)40 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)32 SQLException (java.sql.SQLException)26 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)25 IOException (java.io.IOException)25 Viewer (org.eclipse.jface.viewers.Viewer)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 File (java.io.File)20 Date (java.util.Date)17 Iterator (java.util.Iterator)17 Shell (org.eclipse.swt.widgets.Shell)17 IMsn (de.janrufmonitor.framework.IMsn)16 Properties (java.util.Properties)15 ICip (de.janrufmonitor.framework.ICip)14