Search in sources :

Example 31 with IAttributeMap

use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.

the class BussinessOutlookMapping method getSpecialAttributes.

public IAttributeMap getSpecialAttributes() {
    IAttributeMap m = PIMRuntime.getInstance().getCallerFactory().createAttributeMap();
    m.add(PIMRuntime.getInstance().getCallerFactory().createAttribute("outlook.business", "true"));
    return m;
}
Also used : IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Example 32 with IAttributeMap

use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.

the class OutlookImportAction method run.

public void run() {
    String filter = this.m_app.getApplication().getConfiguration().getProperty("filter", "");
    EditorFilterManager efm = new EditorFilterManager();
    final IAttribute category = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, "");
    if (filter.length() > 0) {
        String cat = null;
        IFilter[] filters = efm.getFiltersFromString(filter);
        for (int z = 0; z < filters.length; z++) {
            if (filters[z].getType().equals(FilterType.ATTRIBUTE)) {
                AttributeFilter cf = ((AttributeFilter) filters[z]);
                IAttributeMap m = cf.getAttributeMap();
                if (m != null && m.size() > 0) {
                    Iterator it = m.iterator();
                    IAttribute a = null;
                    while (it.hasNext()) {
                        a = (IAttribute) it.next();
                        if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
                            cat = a.getValue();
                        }
                    }
                }
            }
        }
        if (cat != null) {
            int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
            MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
            String text = this.getI18nManager().getString("ui.jface.application.editor.action.ImportAction", "assigncategoryconfirm", "label", this.getLanguage());
            text = StringUtils.replaceString(text, "{%1}", cat);
            messageBox.setMessage(text);
            if (messageBox.open() == SWT.YES) {
                category.setValue(cat);
            }
        }
    }
    // determine subfolders
    OutlookTransformer ot = new OutlookTransformer();
    List folders = ot.getAllContactFolders();
    if (folders.size() > 0) {
        int itemCount = 0;
        String folder = null;
        for (int i = 0, j = folders.size(); i < j; i++) {
            folder = (String) folders.get(i);
            itemCount = ot.getContactCount(folder);
            if (itemCount > 0) {
                getRuntime().getConfigManagerFactory().getConfigManager().setProperty(OutlookContactManager.NAMESPACE, "subfolder_" + folder, "true");
            }
        }
        getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
    }
    ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
    try {
        IRunnableWithProgress r = new IRunnableWithProgress() {

            public void run(IProgressMonitor progressMonitor) {
                progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "importprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
                progressMonitor.worked(1);
                OutlookTransformer otf = new OutlookTransformer();
                ICallerList callers = otf.getCallerListFromAllContacts();
                progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "reduce", "label", getLanguage()));
                otf.removeCallerManagerID(callers);
                // determine duplicates
                String currentCallerManagerID = m_app.getApplication().getConfiguration().getProperty(CFG_REPOSITORY);
                if (currentCallerManagerID != null && currentCallerManagerID.trim().length() > 0) {
                    ICallerManager currentCallerManager = getRuntime().getCallerManagerFactory().getCallerManager(currentCallerManagerID);
                    if (currentCallerManager != null && currentCallerManager.isSupported(IWriteCallerRepository.class) && currentCallerManager.isSupported(IIdentifyCallerRepository.class)) {
                        ICallerList addCallers = getRuntime().getCallerFactory().createCallerList();
                        // ICallerList removeCallers = getRuntime().getCallerFactory().createCallerList();
                        ICaller currentCaller = null;
                        String text = null;
                        for (int i = 0, j = callers.size(); i < j; i++) {
                            // ICaller testCaller = null;
                            currentCaller = callers.get(i);
                            text = getI18nManager().getString(getNamespace(), "check", "label", getLanguage());
                            text = StringUtils.replaceString(text, "{%1}", Formatter.getInstance(getRuntime()).parse("%a:ln%, %a:fn%", currentCaller));
                            progressMonitor.setTaskName(text);
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e1) {
                            }
                            try {
                                // testCaller = ((IIdentifyCallerRepository)currentCallerManager).getCaller(currentCaller.getPhoneNumber());
                                ((IIdentifyCallerRepository) currentCallerManager).getCaller(currentCaller.getPhoneNumber());
                            } catch (CallerNotFoundException e) {
                                if (category != null && category.getValue().length() > 0)
                                    currentCaller.setAttribute(category);
                                addCallers.add(currentCaller);
                            }
                        // if (testCaller!=null) {
                        // removeCallers.add(testCaller);
                        // }
                        }
                        progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "add", "label", getLanguage()));
                        try {
                            Thread.sleep(1250);
                        } catch (InterruptedException e1) {
                        }
                        // if (removeCallers.size()>0)
                        // m_app.getController().deleteElements(removeCallers);
                        m_app.getController().addElements(addCallers);
                    }
                } else {
                    progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "add", "label", getLanguage()));
                    m_app.getController().addElements(callers);
                }
                progressMonitor.done();
            }
        };
        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);
    } catch (InvocationTargetException e) {
        m_logger.log(Level.SEVERE, e.getMessage(), e);
    }
    m_app.updateViews(true);
    return;
}
Also used : EditorFilterManager(de.janrufmonitor.ui.jface.application.editor.EditorFilterManager) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) OutlookTransformer(de.janrufmonitor.repository.OutlookTransformer) IIdentifyCallerRepository(de.janrufmonitor.repository.types.IIdentifyCallerRepository) ICallerManager(de.janrufmonitor.repository.ICallerManager) InvocationTargetException(java.lang.reflect.InvocationTargetException) MessageBox(org.eclipse.swt.widgets.MessageBox) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ICaller(de.janrufmonitor.framework.ICaller) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ICallerList(de.janrufmonitor.framework.ICallerList) IFilter(de.janrufmonitor.repository.filter.IFilter) IAttribute(de.janrufmonitor.framework.IAttribute) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) CallerNotFoundException(de.janrufmonitor.repository.CallerNotFoundException) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List)

Example 33 with IAttributeMap

use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.

the class GeoCoding method performOk.

public boolean performOk() {
    boolean ok = super.performOk();
    IAttributeMap address = getRuntime().getCallerFactory().createAttributeMap();
    if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_street").trim().length() > 0) {
        address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_street").trim()));
    }
    if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_streetno").trim().length() > 0) {
        address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET_NO, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_streetno").trim()));
    }
    if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_pcode").trim().length() > 0) {
        address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_pcode").trim()));
    }
    if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_city").trim().length() > 0) {
        address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_city").trim()));
    }
    if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_country").trim().length() > 0) {
        address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_country").trim()));
    }
    // String address = getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "address");
    if (address != null && address.size() > 0) {
        Point loc = GeoCoder.getInstance().getCoordinates(address);
        if (loc != null) {
            getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local-geo-lng", Double.toString(loc.getLongitude()));
            getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local-geo-lat", Double.toString(loc.getLatitude()));
            getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local-geo-acc", Integer.toString(loc.getAccurance()));
        }
        GeoCoder.invalidate();
    }
    return ok;
}
Also used : IAttributeMap(de.janrufmonitor.framework.IAttributeMap) Point(de.janrufmonitor.util.math.Point)

Example 34 with IAttributeMap

use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.

the class FilterWizard method performFinish.

public boolean performFinish() {
    if (this.m_pages[0].isPageComplete() && this.m_pages[1].isPageComplete() && this.m_pages[2].isPageComplete() && this.m_pages[3].isPageComplete() && this.m_pages[4].isPageComplete() && this.m_pages[5].isPageComplete() && this.m_pages[6].isPageComplete()) {
        List filterList = new ArrayList();
        IPhonenumber[] phones = ((FilterPhonesPage) this.m_pages[3]).getResult();
        if (phones != null) {
            filterList.addAll(this.getCallerFilters(phones));
        }
        Date[] dates = ((FilterDatePage) this.m_pages[2]).getResult();
        if (dates != null && dates.length > 0) {
            filterList.add(this.getDateFilter(dates));
        }
        IMsn msn = ((FilterMsnPage) this.m_pages[0]).getResult();
        if (msn != null) {
            if (!msn.getMSN().equalsIgnoreCase("*"))
                filterList.add(new MsnFilter(new IMsn[] { msn }));
        }
        int limit = ((FilterItemCountPage) this.m_pages[4]).getResult();
        if (limit > 0) {
            filterList.add(new ItemCountFilter(limit));
        }
        IAttributeMap m = ((FilterCallTypePage) this.m_pages[5]).getResult();
        if (m != null && m.size() > 0) {
            filterList.add(new AttributeFilter(m));
        }
        ICip cip = ((FilterCipPage) this.m_pages[1]).getResult();
        if (cip != null)
            if (!cip.getCIP().equalsIgnoreCase("*"))
                filterList.add(new CipFilter(cip));
        this.m_filters = new IFilter[filterList.size()];
        for (int i = 0; i < filterList.size(); i++) {
            this.m_filters[i] = (IFilter) filterList.get(i);
        }
        String name = ((FilterNamePage) this.m_pages[6]).getResult();
        IFilterManager fm = new JournalFilterManager();
        if (name != null && name.trim().length() > 0) {
            this.getRuntime().getConfigManagerFactory().getConfigManager().setProperty(Journal.NAMESPACE, "filtername_" + fm.getFiltersToString(getResult()), name);
            this.getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
        } else {
            this.getRuntime().getConfigManagerFactory().getConfigManager().removeProperty(Journal.NAMESPACE, "filtername_" + fm.getFiltersToString(getResult()));
            this.getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
        }
        return true;
    }
    this.m_filters = null;
    return false;
}
Also used : ICip(de.janrufmonitor.framework.ICip) FilterNamePage(de.janrufmonitor.ui.jface.wizards.pages.FilterNamePage) ArrayList(java.util.ArrayList) FilterDatePage(de.janrufmonitor.ui.jface.wizards.pages.FilterDatePage) JournalFilterManager(de.janrufmonitor.ui.jface.application.journal.JournalFilterManager) Date(java.util.Date) CipFilter(de.janrufmonitor.repository.filter.CipFilter) FilterPhonesPage(de.janrufmonitor.ui.jface.wizards.pages.FilterPhonesPage) FilterItemCountPage(de.janrufmonitor.ui.jface.wizards.pages.FilterItemCountPage) FilterMsnPage(de.janrufmonitor.ui.jface.wizards.pages.FilterMsnPage) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) IFilterManager(de.janrufmonitor.ui.jface.application.IFilterManager) FilterCipPage(de.janrufmonitor.ui.jface.wizards.pages.FilterCipPage) MsnFilter(de.janrufmonitor.repository.filter.MsnFilter) FilterCallTypePage(de.janrufmonitor.ui.jface.wizards.pages.FilterCallTypePage) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) List(java.util.List) IMsn(de.janrufmonitor.framework.IMsn) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 35 with IAttributeMap

use of de.janrufmonitor.framework.IAttributeMap 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)

Aggregations

IAttributeMap (de.janrufmonitor.framework.IAttributeMap)64 IAttribute (de.janrufmonitor.framework.IAttribute)37 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)36 ICaller (de.janrufmonitor.framework.ICaller)31 List (java.util.List)24 ICallerList (de.janrufmonitor.framework.ICallerList)23 ArrayList (java.util.ArrayList)21 Iterator (java.util.Iterator)17 IOException (java.io.IOException)14 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)13 Date (java.util.Date)12 IMsn (de.janrufmonitor.framework.IMsn)11 File (java.io.File)10 ICip (de.janrufmonitor.framework.ICip)8 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)8 Message (de.janrufmonitor.exception.Message)6 ICall (de.janrufmonitor.framework.ICall)6 SimpleDateFormat (java.text.SimpleDateFormat)6 StringTokenizer (java.util.StringTokenizer)6 IFilter (de.janrufmonitor.repository.filter.IFilter)5