Search in sources :

Example 41 with ICaller

use of de.janrufmonitor.framework.ICaller 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 42 with ICaller

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

the class AbstractFilterSerializer method getFilterFromString.

/**
 * Transforms a String representation of a filter into an IFilter object.
 * @param fstring string representation of the filter
 * @return a valid IFilter object or null, if string is invalid.
 */
public IFilter getFilterFromString(String fstring) {
    // IFilter filter = null;
    if (fstring.length() > 0) {
        StringTokenizer st = new StringTokenizer(fstring, ",");
        String token = null;
        if (st.countTokens() > 0) {
            token = st.nextToken().trim();
            FilterType ft = new FilterType(Integer.parseInt(token));
            if (ft.equals(FilterType.DATE)) {
                Date d1 = null;
                long dl1 = Long.parseLong(st.nextToken());
                if (dl1 > 0)
                    d1 = new Date(dl1);
                Date d2 = new Date(Long.parseLong(st.nextToken()));
                long frame = -1;
                if (st.hasMoreTokens())
                    frame = Long.parseLong(st.nextToken());
                // calculate today
                if (frame == -100) {
                    Calendar c = Calendar.getInstance();
                    c.set(Calendar.HOUR_OF_DAY, 0);
                    c.set(Calendar.MINUTE, 0);
                    c.set(Calendar.SECOND, 0);
                    d2 = c.getTime();
                    c.set(Calendar.HOUR_OF_DAY, 23);
                    c.set(Calendar.MINUTE, 59);
                    c.set(Calendar.SECOND, 0);
                    d1 = c.getTime();
                    return new DateFilter(d1, d2, frame);
                }
                if (frame == -101) {
                    Calendar c = Calendar.getInstance();
                    c.setFirstDayOfWeek(Calendar.MONDAY);
                    c.set(Calendar.DAY_OF_WEEK, c.get(Calendar.DAY_OF_WEEK) - 1);
                    // 2008/03/25: fixed sunday switch bug
                    if (c.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                        c.add(Calendar.WEEK_OF_MONTH, -1);
                        c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
                    }
                    c.set(Calendar.HOUR_OF_DAY, 0);
                    c.set(Calendar.MINUTE, 0);
                    c.set(Calendar.SECOND, 0);
                    d2 = c.getTime();
                    c.set(Calendar.HOUR_OF_DAY, 23);
                    c.set(Calendar.MINUTE, 59);
                    c.set(Calendar.SECOND, 0);
                    d1 = c.getTime();
                    return new DateFilter(d1, d2, frame);
                }
                if (frame == -107) {
                    Calendar c = Calendar.getInstance();
                    c.set(Calendar.HOUR_OF_DAY, 23);
                    c.set(Calendar.MINUTE, 59);
                    c.set(Calendar.SECOND, 0);
                    d1 = c.getTime();
                    c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
                    c.set(Calendar.HOUR_OF_DAY, 0);
                    c.set(Calendar.MINUTE, 0);
                    c.set(Calendar.SECOND, 0);
                    d2 = c.getTime();
                    return new DateFilter(d1, d2, frame);
                }
                if (frame == -108) {
                    Calendar c = Calendar.getInstance();
                    c.add(Calendar.WEEK_OF_MONTH, -1);
                    c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
                    c.set(Calendar.HOUR_OF_DAY, 23);
                    c.set(Calendar.MINUTE, 59);
                    c.set(Calendar.SECOND, 0);
                    d1 = c.getTime();
                    c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
                    c.set(Calendar.HOUR_OF_DAY, 0);
                    c.set(Calendar.MINUTE, 0);
                    c.set(Calendar.SECOND, 0);
                    d2 = c.getTime();
                    return new DateFilter(d1, d2, frame);
                }
                if (frame == -130) {
                    Calendar c = Calendar.getInstance();
                    c.set(Calendar.HOUR_OF_DAY, 23);
                    c.set(Calendar.MINUTE, 59);
                    c.set(Calendar.SECOND, 0);
                    d1 = c.getTime();
                    c.set(Calendar.DAY_OF_MONTH, 1);
                    c.set(Calendar.HOUR_OF_DAY, 0);
                    c.set(Calendar.MINUTE, 0);
                    c.set(Calendar.SECOND, 0);
                    d2 = c.getTime();
                    return new DateFilter(d1, d2, frame);
                }
                if (frame == -131) {
                    Calendar c = Calendar.getInstance();
                    c.add(Calendar.MONTH, -1);
                    c.set(Calendar.HOUR_OF_DAY, 23);
                    c.set(Calendar.MINUTE, 59);
                    c.set(Calendar.SECOND, 0);
                    c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
                    d1 = c.getTime();
                    c.set(Calendar.DAY_OF_MONTH, 1);
                    c.set(Calendar.HOUR_OF_DAY, 0);
                    c.set(Calendar.MINUTE, 0);
                    c.set(Calendar.SECOND, 0);
                    d2 = c.getTime();
                    return new DateFilter(d1, d2, frame);
                }
                if (frame > -1)
                    return new DateFilter(frame);
                return new DateFilter(d1, d2);
            }
            if (ft.equals(FilterType.YEAR)) {
                String y = st.nextToken();
                return new YearFilter(Integer.parseInt(y));
            }
            if (ft.equals(FilterType.MONTH_YEAR)) {
                String y = st.nextToken();
                String m = st.nextToken();
                return new MonthYearFilter(Integer.parseInt(y), Integer.parseInt(m));
            }
            if (ft.equals(FilterType.MSN)) {
                IMsn[] msns = new IMsn[st.countTokens()];
                int i = 0;
                while (st.hasMoreTokens()) {
                    msns[i] = this.getRuntime().getCallFactory().createMsn(st.nextToken(), "");
                    i++;
                }
                return new MsnFilter(msns);
            }
            if (ft.equals(FilterType.CIP)) {
                String cip = st.nextToken();
                return new CipFilter(this.getRuntime().getCallFactory().createCip(cip, ""));
            }
            if (ft.equals(FilterType.CALLER)) {
                String caller = st.nextToken();
                if (caller.equalsIgnoreCase("clired")) {
                    IPhonenumber pn = getRuntime().getCallerFactory().createPhonenumber(true);
                    ICaller c = getRuntime().getCallerFactory().createCaller(getRuntime().getCallerFactory().createName("", ""), pn);
                    return new CallerFilter(c);
                }
                if (caller.equalsIgnoreCase(IJAMConst.INTERNAL_CALL)) {
                    IPhonenumber pn = getRuntime().getCallerFactory().createPhonenumber(caller, "", st.nextToken());
                    ICaller c = getRuntime().getCallerFactory().createCaller(getRuntime().getCallerFactory().createName("", ""), pn);
                    return new CallerFilter(c);
                } else {
                    IPhonenumber pn = getRuntime().getCallerFactory().createPhonenumber(caller, st.nextToken(), st.nextToken());
                    ICaller c = getRuntime().getCallerFactory().createCaller(getRuntime().getCallerFactory().createName("", ""), pn);
                    return new CallerFilter(c);
                }
            }
            if (ft.equals(FilterType.PHONENUMBER)) {
                String intarea = st.nextToken();
                String area = "";
                String number = "";
                if (st.hasMoreTokens())
                    area = st.nextToken().trim();
                if (area.equalsIgnoreCase("+"))
                    area = "";
                if (st.hasMoreTokens())
                    number = st.nextToken().trim();
                if (number.equalsIgnoreCase("+"))
                    number = "";
                IPhonenumber pn = this.getRuntime().getCallerFactory().createPhonenumber(intarea, area, number);
                return new PhonenumberFilter(pn);
            }
            if (ft.equals(FilterType.ITEMCOUNT)) {
                String limit = st.nextToken().trim();
                return new ItemCountFilter(Integer.parseInt(limit));
            }
            if (ft.equals(FilterType.ATTRIBUTE)) {
                IAttributeMap m = getRuntime().getCallFactory().createAttributeMap();
                // return new AttributeFilter(m);
                String[] t = null;
                while (st.hasMoreTokens()) {
                    t = st.nextToken().split("=");
                    m.add(getRuntime().getCallFactory().createAttribute(t[0], t[1]));
                }
                return new AttributeFilter(m);
            }
            if (ft.equals(FilterType.CHARACTER)) {
                String[] t = st.nextToken().split("=");
                return new CharacterFilter(t[1].trim(), t[0].trim());
            }
            if (ft.equals(FilterType.UUID)) {
                String[] uuids = st.nextToken().split(";");
                return new UUIDFilter(uuids);
            }
        // TODO: more filters to be added here
        }
    }
    return null;
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) ICaller(de.janrufmonitor.framework.ICaller) StringTokenizer(java.util.StringTokenizer) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMsn(de.janrufmonitor.framework.IMsn) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 43 with ICaller

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

the class AbstractPhonesPage method getCallers.

private List getCallers() {
    if (this.m_selectedCallers == null || this.m_selectedCallers.size() == 0) {
        this.m_selectedCallers = new ArrayList();
        if (this.m_phones != null && this.m_phones.length > 0) {
            List managers = this.getActiveCallerManagers();
            ICaller c = null;
            for (int i = 0; i < this.m_phones.length; i++) {
                c = this.getCaller(this.m_phones[i], managers);
                if (c != null && !this.m_selectedCallers.contains(c))
                    this.m_selectedCallers.add(c);
            }
        }
    }
    return this.m_selectedCallers;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 44 with ICaller

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

the class AbstractPhonesPage method getResult.

public IPhonenumber[] getResult() {
    if (all != null && all.getSelection())
        return null;
    if (this.m_selectedCallers != null && this.m_selectedCallers.size() > 0) {
        List phoneList = new ArrayList();
        ICaller c = null;
        for (int i = 0, j = this.m_selectedCallers.size(); i < j; i++) {
            c = ((ICaller) this.m_selectedCallers.get(i));
            if (c instanceof IMultiPhoneCaller) {
                phoneList.addAll(((IMultiPhoneCaller) c).getPhonenumbers());
            } else {
                phoneList.add(c.getPhoneNumber());
            }
        }
        if (phoneList.size() > 0) {
            this.m_phones = new IPhonenumber[phoneList.size()];
            for (int i = 0, j = phoneList.size(); i < j; i++) {
                this.m_phones[i] = (IPhonenumber) phoneList.get(i);
            }
        }
    }
    if (this.m_phones != null && this.m_phones.length == 0)
        this.m_phones = null;
    return this.m_phones;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller)

Example 45 with ICaller

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

the class AbstractCallerDatabaseHandler method insertOrUpdateCallerList.

/**
 * Insert the callers in the list or update the callers if it already exists.
 *
 * @param cl
 * @throws SQLException
 */
public void insertOrUpdateCallerList(ICallerList cl) throws SQLException {
    if (!isConnected())
        try {
            this.connect();
        } catch (ClassNotFoundException e) {
            throw new SQLException(e.getMessage());
        }
    PreparedStatement insert_caller = this.getStatement("INSERT_CALLER");
    PreparedStatement insert_attributes = this.getStatement("INSERT_ATTRIBUTE");
    PreparedStatement update_caller = this.getStatement("UPDATE_CALLER");
    PreparedStatement update_caller_phone = this.getStatement("UPDATE_CALLER_PHONE");
    PreparedStatement update_attributes = this.getStatement("UPDATE_ATTRIBUTE");
    insert_caller.clearBatch();
    insert_attributes.clearBatch();
    update_caller.clearBatch();
    update_caller_phone.clearBatch();
    update_attributes.clearBatch();
    List uuid_check = new ArrayList(cl.size());
    ICaller c = null;
    IPhonenumber pn = null;
    String uuid = null;
    for (int i = 0, j = cl.size(); i < j; i++) {
        c = cl.get(i);
        if (this.m_logger.isLoggable(Level.INFO) && c != null)
            this.m_logger.info("Adding to database: " + c.toString());
        // check if redundant uuid could occure
        uuid = c.getUUID();
        if (uuid_check.contains(uuid)) {
            this.m_logger.warning("Found duplicated UUID: " + c.toString());
            c.setUUID(new UUID().toString());
            uuid = c.getUUID();
        }
        uuid_check.add(uuid);
        pn = c.getPhoneNumber();
        if (this.existsCaller(c)) {
            // do an update
            try {
                this.updateCaller(update_caller, c.getUUID(), pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber(), pn.getTelephoneNumber(), Serializer.toByteArray(c));
                this.updateAttributes(update_attributes, c.getUUID(), c.getAttributes());
            } catch (SerializerException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        } else if (this.existsCaller(pn)) {
            try {
                this.updateCallerPhone(update_caller_phone, c.getUUID(), pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber(), pn.getTelephoneNumber(), Serializer.toByteArray(c));
                this.createAttributes(insert_attributes, c.getUUID(), c.getAttributes());
            } catch (SerializerException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        } else {
            // do an insert
            try {
                this.createCaller(insert_caller, c.getUUID(), pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber(), pn.getTelephoneNumber(), Serializer.toByteArray(c));
                this.createAttributes(insert_attributes, c.getUUID(), c.getAttributes());
            } catch (SerializerException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        if (i % this.commit_count == 0) {
            try {
                insert_caller.executeBatch();
                insert_caller.clearBatch();
                insert_attributes.executeBatch();
                insert_attributes.clearBatch();
                update_caller.executeBatch();
                update_caller.clearBatch();
                update_caller_phone.executeBatch();
                update_caller_phone.clearBatch();
                update_attributes.executeBatch();
                update_attributes.clearBatch();
                this.m_logger.info("-------------------> executed Batch");
            } catch (SQLException e) {
                this.m_logger.log(Level.SEVERE, e.getMessage() + c.toString(), e);
            // throw new SQLException("Batch execution failed: ");
            }
        }
    }
    // execute the rest batch content
    insert_caller.executeBatch();
    insert_attributes.executeBatch();
    update_caller.executeBatch();
    update_caller_phone.executeBatch();
    update_attributes.executeBatch();
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) ArrayList(java.util.ArrayList) List(java.util.List) ICallerList(de.janrufmonitor.framework.ICallerList) UUID(de.janrufmonitor.util.uuid.UUID) SerializerException(de.janrufmonitor.util.io.SerializerException) 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