use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class GoogleContactsCallerManager method getCallers.
public ICallerList getCallers(IFilter filter) {
try {
if (filter != null && filter.getType().equals(FilterType.ATTRIBUTE)) {
IAttributeMap m = ((AttributeFilter) filter).getAttributeMap();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
IAttribute a = m.get(IJAMConst.ATTRIBUTE_NAME_CATEGORY);
return getProxy().getContacts(a.getValue());
}
}
if (filter != null && filter.getType().equals(FilterType.CHARACTER)) {
ICallerList cl = getProxy().getContacts(null);
this.applyFilters(cl, new IFilter[] { filter });
return cl;
}
return getProxy().getContacts(null);
} catch (GoogleContactsException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "loginerror", e));
}
return getRuntime().getCallerFactory().createCallerList();
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class GoogleContactsProxy method identify.
public synchronized ICaller identify(IPhonenumber pn) throws GoogleContactsException {
ICaller c = Identifier.identifyDefault(getRuntime(), pn);
if (c != null) {
pn = c.getPhoneNumber();
try {
List uuids = this.m_dbh.select(pn.getIntAreaCode(), pn.getAreaCode(), pn.getCallNumber());
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("List of found UUIDs: " + uuids);
}
if (uuids.size() > 0) {
String uuid = null;
ICaller contact = null;
for (int k = 0; k < uuids.size(); k++) {
uuid = (String) uuids.get(k);
try {
contact = this.identifyByUUID(uuid);
if (contact != null) {
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("Google contact found for UUID: " + uuid);
}
contact.setUUID(new UUID().toString());
if (contact instanceof IMultiPhoneCaller) {
((IMultiPhoneCaller) contact).getPhonenumbers().clear();
}
contact.setPhoneNumber(pn);
contact.setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CENTRAL_NUMBER_OF_EXTENSION, pn.getTelephoneNumber()));
return contact;
}
} catch (GoogleContactsException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
} else {
Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(GoogleContactsCallerManager.NAMESPACE);
if (config.getProperty(CFG_GOOGLE_KEEPEXT, "false").equalsIgnoreCase("true")) {
// iterate down
String callnumber = pn.getCallNumber();
if (callnumber.length() > 1) {
pn.setCallNumber(callnumber.substring(0, callnumber.length() - 1));
ICaller ca = this.identify(pn);
if (ca != null) {
pn.setCallNumber(callnumber);
if (ca instanceof IMultiPhoneCaller) {
((IMultiPhoneCaller) ca).getPhonenumbers().clear();
}
ca.setPhoneNumber(pn);
// set extension
if (ca.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_CENTRAL_NUMBER_OF_EXTENSION)) {
String centralnumber = ca.getAttribute(IJAMConst.ATTRIBUTE_NAME_CENTRAL_NUMBER_OF_EXTENSION).getValue();
if (pn.getTelephoneNumber().length() > centralnumber.length()) {
IAttribute att = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_EXTENSION, pn.getTelephoneNumber().substring(centralnumber.length()));
ca.setAttribute(att);
}
}
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("Caller match by central number: " + ca.toString());
}
return ca;
}
}
}
}
} catch (SQLException e) {
this.m_logger.log(Level.SEVERE, e.toString(), e);
}
}
this.m_logger.info("Caller not identified: " + pn.getTelephoneNumber());
return null;
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class GoogleContactsProxy method parse.
private synchronized ICaller parse(ContactsService cs, ContactEntry e) {
if (e == null)
return null;
if (e.getPhoneNumbers().size() == 0)
return null;
String uuid = parseUUID(e);
IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
m.addAll(parseName(e));
if (e.hasStructuredPostalAddresses()) {
StructuredPostalAddress pa = (StructuredPostalAddress) e.getStructuredPostalAddresses().get(0);
m.addAll(parseAddress(pa));
}
// 2012/10/20: added email support
if (e.hasEmailAddresses()) {
List emaillist = e.getEmailAddresses();
if (emaillist.size() > 0) {
Email email = (Email) emaillist.get(0);
m.add(parseEmail(email));
}
}
List gphones = e.getPhoneNumbers();
List pl = new ArrayList(gphones.size());
PhoneNumber p = null;
IPhonenumber pn = null;
for (int i = 0, j = gphones.size(); i < j; i++) {
p = (PhoneNumber) gphones.get(i);
pn = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(p.getPhoneNumber());
if (pn != null) {
pl.add(pn);
m.add(parseNumberType(pn, p));
}
}
if (pl.size() == 0)
return null;
if (e.getExtendedProperties() != null) {
ExtendedProperty exp = null;
for (int i = 0, j = e.getExtendedProperties().size(); i < j; i++) {
exp = (ExtendedProperty) e.getExtendedProperties().get(i);
if (exp.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_GEO_ACC) && exp.getValue().length() > 0) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_ACC, exp.getValue()));
}
if (exp.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_GEO_LNG) && exp.getValue().length() > 0) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, exp.getValue()));
}
if (exp.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_GEO_LAT) && exp.getValue().length() > 0) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, exp.getValue()));
}
}
}
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, GoogleContactsCallerManager.ID));
m.add(getRuntime().getCallerFactory().createAttribute("entryUrl", e.getSelfLink().getHref()));
IAttribute a = parseCategory(e);
if (a != null)
m.add(a);
try {
a = parseImage(cs, e);
if (a != null) {
m.add(a);
}
} catch (GoogleContactsException ex) {
this.m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
return getRuntime().getCallerFactory().createCaller(uuid, null, pl, m);
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class HttpCallerManager method addCallerManagerAttribute.
private void addCallerManagerAttribute(ICallerList l) {
// add caller manager attribute to callers
for (int i = 0; i < l.size(); i++) {
ICaller c = (ICaller) l.get(i);
if (c != null) {
IAttribute cm = this.getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, this.getID());
c.setAttribute(cm);
}
}
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class GoogleMapsLocalize method buildRequestParameters.
private String buildRequestParameters(ICaller c) {
StringBuffer params = new StringBuffer();
IAttribute att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_STREET);
if (att != null) {
params.append("+");
params.append(encode(att.getValue()));
}
att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_STREET_NO);
if (att != null) {
params.append("+");
params.append(encode(att.getValue()));
}
att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE);
if (att != null) {
params.append("+");
params.append(encode(att.getValue()));
}
att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY);
if (att != null) {
params.append("+");
params.append(encode(att.getValue()));
}
att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY);
if (att != null) {
params.append("+");
params.append(encode(att.getValue()));
}
return params.toString();
}
Aggregations