use of com.google.gdata.data.extensions.StructuredPostalAddress 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 com.google.gdata.data.extensions.StructuredPostalAddress in project janrufmonitor by tbrandt77.
the class GoogleContactsProxy method createPostalAddress.
private StructuredPostalAddress createPostalAddress(IAttributeMap m) {
StructuredPostalAddress pa = new StructuredPostalAddress();
StringBuffer tmp = new StringBuffer(256);
if (m.contains(IJAMConst.ATTRIBUTE_NAME_STREET)) {
tmp.append(m.get(IJAMConst.ATTRIBUTE_NAME_STREET).getValue());
if (m.contains(IJAMConst.ATTRIBUTE_NAME_STREET_NO)) {
tmp.append(" ");
tmp.append(m.get(IJAMConst.ATTRIBUTE_NAME_STREET_NO).getValue());
}
tmp.append("\n");
}
if (m.contains(IJAMConst.ATTRIBUTE_NAME_CITY)) {
if (m.contains(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE)) {
tmp.append(m.get(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE).getValue());
tmp.append(" ");
}
tmp.append(m.get(IJAMConst.ATTRIBUTE_NAME_CITY).getValue());
}
if (m.contains(IJAMConst.ATTRIBUTE_NAME_COUNTRY)) {
tmp.append("\n");
tmp.append(m.get(IJAMConst.ATTRIBUTE_NAME_COUNTRY).getValue());
}
if (tmp.length() == 0)
tmp.append(" ");
pa.setFormattedAddress(new FormattedAddress(tmp.toString()));
pa.setRel(PostalAddress.Rel.HOME);
pa.setPrimary(Boolean.TRUE);
return pa;
}
Aggregations