Search in sources :

Example 21 with ICallerList

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

the class ThunderbirdCallerImporter method doImport.

public ICallerList doImport() {
    ICallerList cl = PIMRuntime.getInstance().getCallerFactory().createCallerList();
    ;
    tbt = new ThunderbirdTransformer(this.m_filename, false);
    cl.add(tbt.getCallers());
    return cl;
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList) ThunderbirdTransformer(de.janrufmonitor.repository.ThunderbirdTransformer)

Example 22 with ICallerList

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

the class FritzBoxMappingManager method toCallerList.

public ICallerList toCallerList(List l) {
    ICallerList cl = getRuntime().getCallerFactory().createCallerList(l.size());
    ICaller c = null;
    for (int i = 0; i < l.size(); i++) {
        try {
            c = this.mapFritzBoxCallerToJam((IPhonebookEntry) l.get(i));
            if (c != null)
                cl.add(c);
        } catch (IOException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return cl;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IOException(java.io.IOException)

Example 23 with ICallerList

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

the class FritzBoxMappingManager method toFritzBoxCallerList.

public List toFritzBoxCallerList(ICallerList l) {
    List cl = new ArrayList(l.size());
    IPhonebookEntry pe = null;
    for (int i = 0; i < l.size(); i++) {
        try {
            pe = this.mapJamCallerToFritzBox((ICaller) l.get(i));
            if (pe != null)
                cl.add(pe);
        } catch (IOException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return cl;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IPhonebookEntry(de.janrufmonitor.fritzbox.IPhonebookEntry) IOException(java.io.IOException)

Example 24 with ICallerList

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

the class HsqldbCallerDatabaseHandler method buildCallerList.

protected ICallerList buildCallerList(IFilter[] filters) throws SQLException {
    ICallerList cl = this.getRuntime().getCallerFactory().createCallerList();
    if (!isConnected())
        return cl;
    StringBuffer sql = new StringBuffer();
    Statement stmt = m_con.createStatement();
    // build SQL statement
    sql.append("SELECT content FROM callers");
    if (hasAttributeFilter(filters))
        sql.append(", attributes");
    if (filters != null && filters.length > 0 && filters[0] != null) {
        IFilter f = null;
        sql.append(" WHERE ");
        for (int i = 0; i < filters.length; i++) {
            f = filters[i];
            if (i > 0)
                sql.append(" AND ");
            if (f.getType() == FilterType.PHONENUMBER) {
                IPhonenumber pn = (IPhonenumber) f.getFilterObject();
                sql.append("country='" + pn.getIntAreaCode() + "' AND areacode='" + pn.getAreaCode() + "'");
            }
            if (f.getType() == FilterType.ATTRIBUTE) {
                IAttributeMap m = ((AttributeFilter) f).getAttributeMap();
                if (m != null && m.size() > 0) {
                    sql.append("(");
                    sql.append("callers.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 (f.getType() == FilterType.CHARACTER) {
                sql.append("(");
                sql.append("callers.uuid=attributes.ref AND (");
                sql.append("attributes.name='");
                sql.append(((CharacterFilter) f).getAttributeName());
                sql.append("'");
                sql.append(" AND ");
                sql.append("(attributes.value like '");
                sql.append(((CharacterFilter) f).getCharacter().toUpperCase());
                sql.append("%'");
                sql.append(" OR attributes.value like '");
                sql.append(((CharacterFilter) f).getCharacter().toLowerCase());
                sql.append("%'");
                sql.append(")))");
            }
        }
    }
    sql.append(";");
    ResultSet rs = stmt.executeQuery(sql.toString());
    while (rs.next()) {
        try {
            cl.add(Serializer.toCaller(rs.getString("content").getBytes(), this.getRuntime()));
        } catch (SerializerException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return cl;
}
Also used : CharacterFilter(de.janrufmonitor.repository.filter.CharacterFilter) Statement(java.sql.Statement) SerializerException(de.janrufmonitor.util.io.SerializerException) ICallerList(de.janrufmonitor.framework.ICallerList) IFilter(de.janrufmonitor.repository.filter.IFilter) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) ResultSet(java.sql.ResultSet) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 25 with ICallerList

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

the class HsqldbMultiPhoneCallerDatabaseHandler method buildCallerList.

protected ICallerList buildCallerList(IFilter[] filters, ISearchTerm[] searchTerms) throws SQLException {
    ICallerList cl = this.getRuntime().getCallerFactory().createCallerList();
    if (!isConnected())
        return cl;
    StringBuffer sql = new StringBuffer();
    Statement stmt = m_con.createStatement();
    // build SQL statement
    sql.append("SELECT content FROM callers");
    if (hasAttributeFilter(filters))
        sql.append(", attributes");
    if (filters != null && filters.length > 0 && filters[0] != null) {
        IFilter f = null;
        sql.append(" WHERE ");
        for (int i = 0; i < filters.length; i++) {
            f = filters[i];
            if (i > 0)
                sql.append(" AND ");
            if (f.getType() == FilterType.PHONENUMBER) {
                IPhonenumber pn = (IPhonenumber) f.getFilterObject();
                // sql.append("country='"+pn.getIntAreaCode()+"' AND areacode='"+pn.getAreaCode()+"'");
                ResultSet rs = stmt.executeQuery("SELECT ref FROM phones WHERE country='" + pn.getIntAreaCode() + "' AND areacode='" + pn.getAreaCode() + "';");
                if (rs.next()) {
                    sql.append("uuid='");
                    sql.append(rs.getString(1));
                    sql.append("'");
                    while (rs.next()) {
                        sql.append(" OR uuid='");
                        sql.append(rs.getString(1));
                        sql.append("'");
                    }
                }
            }
            if (f.getType() == FilterType.ATTRIBUTE) {
                IAttributeMap m = ((AttributeFilter) f).getAttributeMap();
                if (m != null && m.size() > 0) {
                    sql.append("(");
                    sql.append("callers.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 (f.getType() == FilterType.CHARACTER) {
                sql.append("(");
                sql.append("callers.uuid=attributes.ref AND (");
                sql.append("attributes.name='");
                sql.append(((CharacterFilter) f).getAttributeName());
                sql.append("'");
                sql.append(" AND ");
                sql.append("(attributes.value like '");
                sql.append(((CharacterFilter) f).getCharacter().toUpperCase());
                sql.append("%'");
                sql.append(" OR attributes.value like '");
                sql.append(((CharacterFilter) f).getCharacter().toLowerCase());
                sql.append("%'");
                sql.append(")))");
            }
        }
        if (searchTerms != null && searchTerms.length > 0) {
            sql.append(" AND");
            sql.append(createSearchTerm(searchTerms));
        }
    } else {
        if (searchTerms != null && searchTerms.length > 0) {
            sql.append(" WHERE");
            sql.append(createSearchTerm(searchTerms));
        }
    }
    sql.append(";");
    if (this.m_logger.isLoggable(Level.INFO))
        this.m_logger.info(sql.toString());
    ResultSet rs = stmt.executeQuery(sql.toString());
    while (rs.next()) {
        try {
            cl.add(Serializer.toCaller(rs.getString("content").getBytes(), this.getRuntime()));
        } catch (SerializerException e) {
            this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }
    return cl;
}
Also used : CharacterFilter(de.janrufmonitor.repository.filter.CharacterFilter) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) SerializerException(de.janrufmonitor.util.io.SerializerException) ICallerList(de.janrufmonitor.framework.ICallerList) IFilter(de.janrufmonitor.repository.filter.IFilter) ResultSet(java.sql.ResultSet) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

ICallerList (de.janrufmonitor.framework.ICallerList)81 ICaller (de.janrufmonitor.framework.ICaller)40 List (java.util.List)36 ArrayList (java.util.ArrayList)32 IAttribute (de.janrufmonitor.framework.IAttribute)24 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)24 SQLException (java.sql.SQLException)24 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)18 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)17 IOException (java.io.IOException)15 Message (de.janrufmonitor.exception.Message)14 Iterator (java.util.Iterator)11 Map (java.util.Map)11 File (java.io.File)10 HashMap (java.util.HashMap)10 Viewer (org.eclipse.jface.viewers.Viewer)10 ICallerManager (de.janrufmonitor.repository.ICallerManager)9 ComFailException (com.jacob.com.ComFailException)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)7