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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations