Search in sources :

Example 1 with PhonenumberFilter

use of de.janrufmonitor.repository.filter.PhonenumberFilter in project janrufmonitor by tbrandt77.

the class LastCalled method renderAsText.

public String renderAsText() {
    if (this.m_o != null) {
        if (this.m_o instanceof ICaller) {
            this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
        }
        if (this.m_o instanceof ITreeItemCallerData) {
            IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
            List cms = PIMRuntime.getInstance().getCallManagerFactory().getTypedCallManagers(IReadCallRepository.class);
            if (cms.size() > 0) {
                ICallManager cm = null;
                for (int i = 0, j = cms.size(); i < j; i++) {
                    cm = (ICallManager) cms.get(i);
                    if (cm.isActive() && cm.isSupported(IReadCallRepository.class)) {
                        IFilter[] filters = new IFilter[] { new PhonenumberFilter(pn), new ItemCountFilter(1) };
                        ICallList cl = ((IReadCallRepository) cm).getCalls(filters, 1, 0);
                        cl.sort(0, false);
                        if (cl.size() > 0) {
                            ICall c = cl.get(0);
                            return getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, c.getDate());
                        }
                    }
                }
            }
        }
    }
    return "";
}
Also used : IReadCallRepository(de.janrufmonitor.repository.types.IReadCallRepository) ICall(de.janrufmonitor.framework.ICall) ICallManager(de.janrufmonitor.repository.ICallManager) ICaller(de.janrufmonitor.framework.ICaller) IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) ICallList(de.janrufmonitor.framework.ICallList) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) ICallList(de.janrufmonitor.framework.ICallList) List(java.util.List) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) ITreeItemCallerData(de.janrufmonitor.ui.jface.application.ITreeItemCallerData) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 2 with PhonenumberFilter

use of de.janrufmonitor.repository.filter.PhonenumberFilter in project janrufmonitor by tbrandt77.

the class AbstractConfigurableCallerManager method applyFilters.

protected void applyFilters(ICallerList cl, IFilter[] filters) {
    if (cl == null)
        return;
    if (filters == null)
        return;
    IFilter f = null;
    for (int i = 0; i < filters.length; i++) {
        f = filters[i];
        if (f.getType() == FilterType.CHARACTER) {
            CharacterFilter cf = ((CharacterFilter) f);
            ICaller c = null;
            for (int j = cl.size() - 1; j >= 0; j--) {
                c = cl.get(j);
                if (!c.getAttributes().contains(cf.getAttributeName())) {
                    cl.remove(c);
                } else if (c.getAttributes().contains(cf.getAttributeName())) {
                    if (!c.getAttribute(cf.getAttributeName()).getValue().startsWith(cf.getCharacter())) {
                        cl.remove(c);
                    }
                }
            }
        }
        if (f.getType() == FilterType.PHONENUMBER) {
            PhonenumberFilter cf = ((PhonenumberFilter) f);
            ICaller c = null;
            for (int j = cl.size() - 1; j >= 0; j--) {
                c = cl.get(j);
                if (!c.getPhoneNumber().getIntAreaCode().equalsIgnoreCase(cf.getPhonenumber().getIntAreaCode())) {
                    cl.remove(c);
                } else if (!c.getPhoneNumber().getAreaCode().equalsIgnoreCase(cf.getPhonenumber().getAreaCode())) {
                    cl.remove(c);
                }
            }
        }
        if (f.getType() == FilterType.ATTRIBUTE) {
            AttributeFilter cf = ((AttributeFilter) f);
            ICaller c = null;
            for (int j = cl.size() - 1; j >= 0; j--) {
                c = cl.get(j);
                IAttributeMap atts = cf.getAttributeMap();
                Iterator iter = atts.iterator();
                IAttribute a = null;
                while (iter.hasNext()) {
                    a = (IAttribute) iter.next();
                    if (!c.getAttributes().contains(a)) {
                        cl.remove(c);
                    } else if (c.getAttributes().contains(a) && !c.getAttribute(a.getName()).getValue().equalsIgnoreCase(a.getValue())) {
                        cl.remove(c);
                    }
                }
            }
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) CharacterFilter(de.janrufmonitor.repository.filter.CharacterFilter) IFilter(de.janrufmonitor.repository.filter.IFilter) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Example 3 with PhonenumberFilter

use of de.janrufmonitor.repository.filter.PhonenumberFilter in project janrufmonitor by tbrandt77.

the class AbstractFilterManager method getFiltersToLabelText.

public String getFiltersToLabelText(IFilter[] f, int shorten) {
    if (f != null && f.length > 0) {
        boolean processedCaller = false;
        StringBuffer sb = new StringBuffer();
        sb.append(this.getI18nManager().getString(this.getNamespace(), "view_limit", "label", this.getLanguage()));
        for (int i = 0; i < f.length; i++) {
            IFilter f1 = f[i];
            if (f1.getType().equals(FilterType.CIP)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_cip", "label", this.getLanguage()));
                sb.append(this.getRuntime().getCipManager().getCipLabel(((CipFilter) f1).getCip(), this.getLanguage()));
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.MSN)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_msn", "label", this.getLanguage()));
                IMsn[] m = ((MsnFilter) f1).getMsn();
                for (int k = 0, l = m.length; k < l; k++) {
                    sb.append(m[k].getMSN());
                    m[k].setAdditional(this.getRuntime().getMsnManager().getMsnLabel(m[k]));
                    if (m[k].getAdditional().length() > 0) {
                        sb.append(" (" + m[k].getAdditional() + ")");
                    }
                    if ((k + 1) < l)
                        sb.append(", ");
                }
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.DATE)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
                if (((DateFilter) f1).getTimeframe() == -1) {
                    Date d1 = ((DateFilter) f1).getDateFrom();
                    Date d2 = ((DateFilter) f1).getDateTo();
                    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
                    sb.append("[");
                    sb.append(sdf.format(d2));
                    sb.append(" - ");
                    if (d1 != null)
                        sb.append(sdf.format(d1));
                    else {
                        sb.append(this.getI18nManager().getString(this.getNamespace(), "today", "label", this.getLanguage()));
                    }
                    sb.append("]");
                    if ((i + 1) < f.length)
                        sb.append(", ");
                } else {
                    sb.append("[");
                    sb.append(this.getI18nManager().getString(this.getNamespace(), Long.toString(((DateFilter) f1).getTimeframe()), "label", this.getLanguage()));
                    sb.append("]");
                    if ((i + 1) < f.length)
                        sb.append(", ");
                }
            }
            if (f1.getType().equals(FilterType.YEAR)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
                sb.append("[");
                sb.append(((YearFilter) f1).getYear());
                sb.append("]");
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.MONTH_YEAR)) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
                sb.append("[");
                sb.append(((MonthYearFilter) f1).getYear());
                sb.append(".");
                sb.append((((MonthYearFilter) f1).getMonth() > 9 ? ((MonthYearFilter) f1).getMonth() : "0" + ((MonthYearFilter) f1).getMonth()));
                sb.append("]");
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.CALLER) && !processedCaller) {
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_caller", "label", this.getLanguage()));
                if ((i + 1) < f.length && !processedCaller)
                    sb.append(", ");
                processedCaller = true;
            }
            if (f1.getType().equals(FilterType.PHONENUMBER)) {
                PhonenumberFilter cf = ((PhonenumberFilter) f1);
                IPhonenumber pnc = getRuntime().getCallerFactory().createPhonenumber(cf.getPhonenumber().getIntAreaCode(), cf.getPhonenumber().getAreaCode(), "0000000000");
                ICaller c = Identifier.identifyDefault(getRuntime(), pnc);
                if (c != null) {
                    IAttribute city = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY);
                    if (city != null && city.getValue().trim().length() > 0) {
                        sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()).substring(2));
                        sb.append(city.getValue().trim());
                        sb.append(" (0");
                        sb.append(cf.getPhonenumber().getAreaCode());
                        sb.append(")");
                        if ((i + 1) < f.length)
                            sb.append(", ");
                        continue;
                    }
                }
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_intarea", "label", this.getLanguage()));
                sb.append("00" + cf.getPhonenumber().getIntAreaCode());
                if (cf.getPhonenumber().getAreaCode().trim().length() > 0) {
                    sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()));
                    sb.append("0" + cf.getPhonenumber().getAreaCode().trim());
                }
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.ITEMCOUNT)) {
                ItemCountFilter cf = ((ItemCountFilter) f1);
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_itemcount", "label", this.getLanguage()));
                sb.append(cf.getLimit());
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.ATTRIBUTE)) {
                AttributeFilter cf = ((AttributeFilter) f1);
                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_CALLSTATUS)) {
                            sb.append(this.getI18nManager().getString(this.getNamespace(), a.getValue(), "label", this.getLanguage()));
                        } else if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
                            sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
                            sb.append(a.getValue());
                        } else {
                            sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
                        }
                        if (it.hasNext())
                            sb.append(", ");
                    }
                }
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
            if (f1.getType().equals(FilterType.CHARACTER)) {
                CharacterFilter cf = ((CharacterFilter) f1);
                sb.append(this.getI18nManager().getString(this.getNamespace(), "view_" + cf.getAttributeName(), "label", this.getLanguage()));
                sb.append("[");
                sb.append(cf.getCharacter().toUpperCase());
                sb.append("...]");
                if ((i + 1) < f.length)
                    sb.append(", ");
            }
        }
        String s = sb.toString();
        if (s.trim().endsWith(","))
            s = s.trim().substring(0, s.trim().length() - 1);
        if (shorten > -1 && shorten < s.length()) {
            return s.substring(0, Math.min(shorten, s.length())) + "...";
        }
        if (s.trim().length() > 0)
            return s;
    }
    return this.getI18nManager().getString(this.getNamespace(), "view_all", "label", this.getLanguage());
}
Also used : CharacterFilter(de.janrufmonitor.repository.filter.CharacterFilter) CipFilter(de.janrufmonitor.repository.filter.CipFilter) Date(java.util.Date) ICaller(de.janrufmonitor.framework.ICaller) IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) MsnFilter(de.janrufmonitor.repository.filter.MsnFilter) IAttribute(de.janrufmonitor.framework.IAttribute) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMsn(de.janrufmonitor.framework.IMsn) DateFilter(de.janrufmonitor.repository.filter.DateFilter) SimpleDateFormat(java.text.SimpleDateFormat) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 4 with PhonenumberFilter

use of de.janrufmonitor.repository.filter.PhonenumberFilter in project janrufmonitor by tbrandt77.

the class History method getConfiguration.

public Properties getConfiguration() {
    Properties saved = super.getConfiguration();
    Properties journalConfig = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(Journal.NAMESPACE);
    if (journalConfig != null && journalConfig.size() > 0) {
        saved.setProperty(JournalConfigConst.CFG_REPOSITORY, journalConfig.getProperty(JournalConfigConst.CFG_REPOSITORY));
    }
    IFilter[] filters = null;
    if (this.m_caller instanceof IMultiPhoneCaller) {
        filters = new IFilter[((IMultiPhoneCaller) this.m_caller).getPhonenumbers().size()];
        for (int i = 0, j = ((IMultiPhoneCaller) this.m_caller).getPhonenumbers().size(); i < j; i++) {
            filters[i] = new PhonenumberFilter((IPhonenumber) ((IMultiPhoneCaller) this.m_caller).getPhonenumbers().get(i));
        }
    } else {
        filters = new IFilter[1];
        if (this.m_caller != null)
            filters[0] = new PhonenumberFilter(this.m_caller.getPhoneNumber());
    }
    saved.setProperty("filter", new JournalFilterManager().getFiltersToString(filters));
    return saved;
}
Also used : IFilter(de.janrufmonitor.repository.filter.IFilter) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) JournalFilterManager(de.janrufmonitor.ui.jface.application.journal.JournalFilterManager) Properties(java.util.Properties) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 5 with PhonenumberFilter

use of de.janrufmonitor.repository.filter.PhonenumberFilter in project janrufmonitor by tbrandt77.

the class EditorFilterWizard method performFinish.

public boolean performFinish() {
    if (this.m_pages[0].isPageComplete()) {
        List filterList = new ArrayList();
        IPhonenumber phones = ((EditorFilterPhonePage) this.m_pages[0]).getResult();
        if (phones != null) {
            filterList.add(new PhonenumberFilter(phones));
        }
        this.m_filters = new IFilter[filterList.size()];
        for (int i = 0; i < filterList.size(); i++) {
            this.m_filters[i] = (IFilter) filterList.get(i);
        }
        return true;
    }
    this.m_filters = null;
    return false;
}
Also used : ArrayList(java.util.ArrayList) EditorFilterPhonePage(de.janrufmonitor.ui.jface.wizards.pages.EditorFilterPhonePage) PhonenumberFilter(de.janrufmonitor.repository.filter.PhonenumberFilter) List(java.util.List) ArrayList(java.util.ArrayList) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

PhonenumberFilter (de.janrufmonitor.repository.filter.PhonenumberFilter)5 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)4 IFilter (de.janrufmonitor.repository.filter.IFilter)4 ICaller (de.janrufmonitor.framework.ICaller)3 IAttribute (de.janrufmonitor.framework.IAttribute)2 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)2 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)2 CharacterFilter (de.janrufmonitor.repository.filter.CharacterFilter)2 ItemCountFilter (de.janrufmonitor.repository.filter.ItemCountFilter)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ICall (de.janrufmonitor.framework.ICall)1 ICallList (de.janrufmonitor.framework.ICallList)1 IMsn (de.janrufmonitor.framework.IMsn)1 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)1 ICallManager (de.janrufmonitor.repository.ICallManager)1 CipFilter (de.janrufmonitor.repository.filter.CipFilter)1 DateFilter (de.janrufmonitor.repository.filter.DateFilter)1 MonthYearFilter (de.janrufmonitor.repository.filter.MonthYearFilter)1 MsnFilter (de.janrufmonitor.repository.filter.MsnFilter)1