Search in sources :

Example 1 with CipFilter

use of de.janrufmonitor.repository.filter.CipFilter 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 2 with CipFilter

use of de.janrufmonitor.repository.filter.CipFilter 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)

Aggregations

IAttributeMap (de.janrufmonitor.framework.IAttributeMap)2 IMsn (de.janrufmonitor.framework.IMsn)2 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)2 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)2 CipFilter (de.janrufmonitor.repository.filter.CipFilter)2 ItemCountFilter (de.janrufmonitor.repository.filter.ItemCountFilter)2 MsnFilter (de.janrufmonitor.repository.filter.MsnFilter)2 Date (java.util.Date)2 IAttribute (de.janrufmonitor.framework.IAttribute)1 ICaller (de.janrufmonitor.framework.ICaller)1 ICip (de.janrufmonitor.framework.ICip)1 CharacterFilter (de.janrufmonitor.repository.filter.CharacterFilter)1 DateFilter (de.janrufmonitor.repository.filter.DateFilter)1 IFilter (de.janrufmonitor.repository.filter.IFilter)1 MonthYearFilter (de.janrufmonitor.repository.filter.MonthYearFilter)1 PhonenumberFilter (de.janrufmonitor.repository.filter.PhonenumberFilter)1 IFilterManager (de.janrufmonitor.ui.jface.application.IFilterManager)1 JournalFilterManager (de.janrufmonitor.ui.jface.application.journal.JournalFilterManager)1 FilterCallTypePage (de.janrufmonitor.ui.jface.wizards.pages.FilterCallTypePage)1 FilterCipPage (de.janrufmonitor.ui.jface.wizards.pages.FilterCipPage)1