Search in sources :

Example 1 with MonthYearFilter

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

the class HsqldbCallDatabaseHandler method prepareStatement.

private String prepareStatement(IFilter[] filters, int count, int offset, boolean isCounter, ISearchTerm[] searchTerms) {
    StringBuffer sql = new StringBuffer();
    // build SQL statement
    sql.append("SELECT");
    if (filters.length == 1 && filters[0] == null)
        filters = null;
    // 2008/11/28: optimized attribute filter call
    if (filters != null && filters.length > 0 && hasOnlyAttributeFilter(filters)) {
        if (isCounter) {
            sql.append(" COUNT(calls.uuid) ");
        } else {
            sql.append(" content ");
        }
        sql.append("FROM attributes LEFT JOIN calls ON calls.uuid=attributes.ref AND ");
        IFilter f = null;
        for (int i = 0; i < filters.length; i++) {
            f = filters[i];
            if (f.getType() == FilterType.ATTRIBUTE) {
                IAttributeMap m = ((AttributeFilter) f).getAttributeMap();
                if (m != null && m.size() > 0) {
                    sql.append("(");
                    sql.append("(");
                    Iterator iter = m.iterator();
                    IAttribute a = null;
                    while (iter.hasNext()) {
                        a = (IAttribute) iter.next();
                        sql.append("attributes.name='");
                        sql.append(a.getName());
                        sql.append("'");
                        sql.append(" AND ");
                        sql.append("attributes.value='");
                        sql.append(a.getValue());
                        sql.append("'");
                        if (iter.hasNext())
                            sql.append(" OR ");
                    }
                    sql.append("))");
                }
            }
        }
        if (searchTerms != null && searchTerms.length > 0) {
            sql.append(" AND");
            sql.append(createSearchTerm(searchTerms));
        }
    } else if (filters != null && filters.length > 0) {
        int limit = -1;
        for (int i = 0; i < filters.length; i++) {
            if (filters[i] != null && filters[i].getType() == FilterType.ITEMCOUNT) {
                limit = ((ItemCountFilter) filters[i]).getLimit();
                if (!isCounter) {
                    // 2008/05/19: to be done since offset was introduced !!
                    count = limit;
                    offset = 0;
                }
            }
        }
        if (isCounter) {
            sql.append(" COUNT(calls.uuid) ");
        } else {
            sql.append(" content ");
        }
        sql.append("FROM calls");
        if (hasAttributeFilter(filters))
            sql.append(", attributes");
        if (filters.length == 1 && filters[0] != null && filters[0].getType() == FilterType.ITEMCOUNT)
            sql.append("");
        else
            sql.append(" WHERE ");
        IFilter f = null;
        boolean isCallerFilter = false;
        boolean isMsnFilter = false;
        for (int i = 0; i < filters.length; i++) {
            if (filters[i] != null && filters[i].getType() == FilterType.ITEMCOUNT) {
                // limit=((ItemCountFilter)filters[i]).getLimit();
                continue;
            }
            f = filters[i];
            if (f == null)
                continue;
            if (isCallerFilter && (f.getType() == FilterType.CALLER || f.getType() == FilterType.PHONENUMBER)) {
                if (i > 0)
                    sql.append(" OR ");
            } else if (isMsnFilter && f.getType() == FilterType.MSN) {
                if (i > 0)
                    sql.append(" OR ");
            } else {
                if (i > 0 && filters[i - 1].getType() != FilterType.ITEMCOUNT)
                    sql.append(" AND ");
            }
            if (f.getType() == FilterType.DATE) {
                DateFilter df = (DateFilter) f;
                sql.append("(calls.cdate>");
                sql.append((df.getDateTo() == null ? new Date().getTime() : df.getDateTo().getTime()));
                sql.append(" AND calls.cdate<");
                sql.append((df.getDateFrom() == null ? new Date().getTime() : df.getDateFrom().getTime()));
                sql.append(")");
            }
            if (f.getType() == FilterType.YEAR) {
                YearFilter df = (YearFilter) f;
                sql.append("(calls.cdate>");
                sql.append((df.getDateFrom() == null ? new Date().getTime() : df.getDateFrom().getTime()));
                sql.append(" AND calls.cdate<");
                sql.append((df.getDateTo() == null ? new Date().getTime() : df.getDateTo().getTime()));
                sql.append(")");
            }
            if (f.getType() == FilterType.MONTH_YEAR) {
                MonthYearFilter df = (MonthYearFilter) f;
                sql.append("(calls.cdate>");
                sql.append((df.getDateFrom() == null ? new Date().getTime() : df.getDateFrom().getTime()));
                sql.append(" AND calls.cdate<");
                sql.append((df.getDateTo() == null ? new Date().getTime() : df.getDateTo().getTime()));
                sql.append(")");
            }
            if (f.getType() == FilterType.CALLER) {
                if (!isCallerFilter)
                    sql.append("(");
                isCallerFilter = true;
                ICaller c = (ICaller) f.getFilterObject();
                IPhonenumber pn = c.getPhoneNumber();
                sql.append("(calls.country='");
                sql.append(pn.getIntAreaCode());
                sql.append("' AND calls.areacode='");
                sql.append(pn.getAreaCode());
                sql.append("' AND calls.number='");
                sql.append(pn.getCallNumber());
                sql.append("')");
                if (isCallerFilter && ((i + 1) >= filters.length || (filters[i + 1] != null && (filters[i + 1].getType() != FilterType.CALLER))))
                    sql.append(")");
            }
            if (f.getType() == FilterType.PHONENUMBER) {
                if (!isCallerFilter)
                    sql.append("(");
                isCallerFilter = true;
                IPhonenumber pn = (IPhonenumber) f.getFilterObject();
                sql.append("(calls.country='");
                sql.append(pn.getIntAreaCode());
                sql.append("' AND calls.areacode='");
                sql.append(pn.getAreaCode());
                sql.append("' AND calls.number='");
                sql.append(pn.getCallNumber());
                sql.append("')");
                if (isCallerFilter && ((i + 1) >= filters.length || (filters[i + 1] != null && (filters[i + 1].getType() != FilterType.PHONENUMBER))))
                    sql.append(")");
            }
            if (f.getType() == FilterType.CIP) {
                ICip cip = (ICip) f.getFilterObject();
                sql.append("calls.cip='");
                sql.append(cip.getCIP());
                sql.append("'");
            }
            if (f.getType() == FilterType.MSN) {
                IMsn[] msn = (IMsn[]) f.getFilterObject();
                if (msn != null && msn.length > 0) {
                    if (!isMsnFilter)
                        sql.append("(");
                    isMsnFilter = true;
                    sql.append("(");
                    for (int j = 0; j < msn.length; j++) {
                        if (j > 0)
                            sql.append(" OR ");
                        sql.append("calls.msn='");
                        sql.append(msn[j].getMSN());
                        sql.append("'");
                    }
                    sql.append(")");
                    if (isMsnFilter && ((i + 1) >= filters.length || (filters[i + 1] != null && (filters[i + 1].getType() != FilterType.MSN))))
                        sql.append(")");
                }
            }
            if (f.getType() == FilterType.UUID) {
                String[] uuids = (String[]) f.getFilterObject();
                if (uuids != null && uuids.length > 0) {
                    sql.append("(");
                    for (int j = 0; j < uuids.length; j++) {
                        if (j > 0)
                            sql.append(" OR ");
                        sql.append("calls.uuid='");
                        sql.append(uuids[i]);
                        sql.append("'");
                    }
                    sql.append(")");
                }
            }
            if (f.getType() == FilterType.ATTRIBUTE) {
                IAttributeMap m = ((AttributeFilter) f).getAttributeMap();
                if (m != null && m.size() > 0) {
                    sql.append("(");
                    sql.append("calls.uuid=attributes.ref AND (");
                    Iterator iter = m.iterator();
                    IAttribute a = null;
                    while (iter.hasNext()) {
                        a = (IAttribute) iter.next();
                        sql.append("attributes.name='");
                        sql.append(a.getName());
                        sql.append("'");
                        sql.append(" AND ");
                        sql.append("attributes.value='");
                        sql.append(a.getValue());
                        sql.append("'");
                        if (iter.hasNext())
                            sql.append(" OR ");
                    }
                    sql.append("))");
                }
            }
        }
        if (searchTerms != null && searchTerms.length > 0) {
            if (filters.length == 1 && filters[0] != null && filters[0].getType() == FilterType.ITEMCOUNT)
                sql.append(" WHERE");
            else
                sql.append(" AND");
            sql.append(createSearchTerm(searchTerms));
        }
        if (limit > 0 && !isCounter) {
            sql.append(" ORDER BY cdate DESC");
        }
    } else {
        if (isCounter) {
            sql.append(" COUNT(calls.uuid) ");
        } else {
            sql.append(" content ");
        }
        sql.append("FROM calls");
        if (count > 0 && offset >= 0) {
            sql.append(" AS rtable");
        }
        if (searchTerms != null && searchTerms.length > 0) {
            sql.append(" WHERE");
            sql.append(createSearchTerm(searchTerms));
        }
    }
    if (count > 0 && offset >= 0) {
        sql.append(" LIMIT ");
        sql.append(count);
        sql.append(" OFFSET ");
        sql.append(offset);
    }
    sql.append(";");
    if (this.m_logger.isLoggable(Level.INFO))
        this.m_logger.info(sql.toString());
    return sql.toString();
}
Also used : ICip(de.janrufmonitor.framework.ICip) Date(java.util.Date) ICaller(de.janrufmonitor.framework.ICaller) IFilter(de.janrufmonitor.repository.filter.IFilter) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) YearFilter(de.janrufmonitor.repository.filter.YearFilter) DateFilter(de.janrufmonitor.repository.filter.DateFilter) IMsn(de.janrufmonitor.framework.IMsn) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 2 with MonthYearFilter

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

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

the class AbstractFilterCallManager method filterCalls.

protected ICallList filterCalls(IFilter filter, ICallList cl) {
    if (cl == null) {
        cl = this.getInitialCallList(filter);
    }
    long start = System.currentTimeMillis();
    this.m_logger.info("Start filtering with filter: " + filter);
    this.m_logger.info("CallList size before filtering: " + cl.size());
    ICall c = null;
    if (filter != null) {
        if (filter.getType().equals(FilterType.DATE) || filter.getType().equals(FilterType.YEAR) || filter.getType().equals(FilterType.MONTH_YEAR)) {
            long from = 0;
            long to = 0;
            if (filter instanceof DateFilter) {
                DateFilter df = (DateFilter) filter;
                to = (df.getDateFrom() == null ? 0 : df.getDateFrom().getTime());
                from = df.getDateTo().getTime();
            }
            if (filter instanceof YearFilter) {
                YearFilter df = (YearFilter) filter;
                from = (df.getDateFrom() == null ? 0 : df.getDateFrom().getTime());
                to = df.getDateTo().getTime();
            }
            if (filter instanceof MonthYearFilter) {
                MonthYearFilter df = (MonthYearFilter) filter;
                from = (df.getDateFrom() == null ? 0 : df.getDateFrom().getTime());
                to = df.getDateTo().getTime();
            }
            long cdate = 0;
            for (int i = cl.size() - 1; i >= 0; i--) {
                c = cl.get(i);
                cdate = c.getDate().getTime();
                if (to > 0) {
                    if (cdate < from || cdate > to)
                        cl.remove(c);
                } else {
                    if (cdate < from)
                        cl.remove(c);
                }
            }
        }
        if (filter.getType().equals(FilterType.CALLER)) {
            ICaller cfilter = (ICaller) filter.getFilterObject();
            IPhonenumber pn = cfilter.getPhoneNumber();
            for (int i = cl.size() - 1; i >= 0; i--) {
                c = cl.get(i);
                if (!c.getCaller().getPhoneNumber().equals(pn))
                    cl.remove(c);
            }
        }
        if (filter.getType().equals(FilterType.PHONENUMBER)) {
            IPhonenumber pn = (IPhonenumber) filter.getFilterObject();
            for (int i = cl.size() - 1; i >= 0; i--) {
                c = cl.get(i);
                if (!c.getCaller().getPhoneNumber().equals(pn))
                    cl.remove(c);
            }
        }
        if (filter.getType().equals(FilterType.CIP)) {
            ICip cip = (ICip) filter.getFilterObject();
            for (int i = cl.size() - 1; i >= 0; i--) {
                c = cl.get(i);
                if (!c.getCIP().equals(cip))
                    cl.remove(c);
            }
        }
        if (filter.getType().equals(FilterType.MSN)) {
            IMsn msn = (IMsn) filter.getFilterObject();
            for (int i = cl.size() - 1; i >= 0; i--) {
                c = cl.get(i);
                if (!c.getMSN().equals(msn))
                    cl.remove(c);
            }
        }
        if (filter.getType().equals(FilterType.UUID)) {
            String[] uuids = (String[]) filter.getFilterObject();
            for (int i = cl.size() - 1; i >= 0; i--) {
                c = cl.get(i);
                boolean hasUUID = false;
                for (int j = 0; j < uuids.length; j++) {
                    if (c.getUUID().equalsIgnoreCase(uuids[j]))
                        hasUUID = true;
                }
                if (!hasUUID)
                    cl.remove(c);
            }
        }
        if (filter.getType().equals(FilterType.ATTRIBUTE)) {
            IAttributeMap m = ((AttributeFilter) filter).getAttributeMap();
            if (m != null && m.size() > 0) {
                Iterator iter = m.iterator();
                IAttribute a = null;
                while (iter.hasNext()) {
                    a = (IAttribute) iter.next();
                    IAttribute ua = null;
                    for (int i = cl.size() - 1; i >= 0; i--) {
                        c = cl.get(i);
                        ua = c.getAttribute(a.getName());
                        if (ua == null || !ua.getValue().equalsIgnoreCase(a.getValue())) {
                            cl.remove(c);
                        }
                    }
                }
            }
        }
        if (filter.getType().equals(FilterType.ITEMCOUNT)) {
            int itemcount = ((ItemCountFilter) filter).getLimit();
            if (itemcount > 0) {
                ICallList tmpCl = this.getRuntime().getCallFactory().createCallList(itemcount);
                // added: 2006/04/20: just a work-a-round
                cl.sort(0, false);
                for (int i = 0, j = Math.min(cl.size(), itemcount); i < j; i++) {
                    tmpCl.add(cl.get(i));
                }
                cl.clear();
                cl.add(tmpCl);
            }
        }
    }
    this.m_logger.info("CallList size after filtering: " + cl.size());
    this.m_logger.info("Finished filtering with filter <" + filter + "> in " + Long.toString(System.currentTimeMillis() - start) + " msec.");
    return cl;
}
Also used : ICall(de.janrufmonitor.framework.ICall) ICip(de.janrufmonitor.framework.ICip) ICaller(de.janrufmonitor.framework.ICaller) ItemCountFilter(de.janrufmonitor.repository.filter.ItemCountFilter) ICallList(de.janrufmonitor.framework.ICallList) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) YearFilter(de.janrufmonitor.repository.filter.YearFilter) DateFilter(de.janrufmonitor.repository.filter.DateFilter) IMsn(de.janrufmonitor.framework.IMsn) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 4 with MonthYearFilter

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

the class JournalFilterManager method getRuntimeFilters.

@Override
public IFilter[][] getRuntimeFilters() {
    String cfg = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(Journal.NAMESPACE, "rt_filters_years");
    int years = 1;
    if (cfg != null && cfg.length() > 0) {
        years = Integer.parseInt(cfg);
    }
    if (years < 0)
        return new IFilter[][] {};
    int c_y = Calendar.getInstance().get(Calendar.YEAR);
    int c_m = Calendar.getInstance().get(Calendar.MONTH);
    List filters = new ArrayList(years * 12 + years);
    for (int y = c_y - years; y <= c_y; y++) {
        filters.add(new YearFilter(y));
        int max_month = 12;
        if (y == c_y)
            max_month = c_m + 1;
        for (int m = 1; m <= max_month; m++) {
            filters.add(new MonthYearFilter(y, m));
        }
    }
    IFilter[][] filters2 = new IFilter[filters.size()][1];
    for (int i = 0; i < filters2.length; i++) filters2[i][0] = (IFilter) filters.get(i);
    return filters2;
}
Also used : IFilter(de.janrufmonitor.repository.filter.IFilter) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) YearFilter(de.janrufmonitor.repository.filter.YearFilter) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter) MonthYearFilter(de.janrufmonitor.repository.filter.MonthYearFilter)

Aggregations

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