use of de.janrufmonitor.framework.IAttributeMap 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.IAttributeMap in project janrufmonitor by tbrandt77.
the class GoogleContactsProxy method parseName.
private IAttributeMap parseName(ContactEntry e) {
IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
if (e.getName() != null && e.getName().getFamilyName() != null && e.getName().getGivenName() != null) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, e.getName().getFamilyName().getValue()));
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, e.getName().getGivenName().getValue()));
return m;
}
String name = e.getTitle().getPlainText();
// test name splitting
String[] tmp = name.split(" ");
if (tmp.length == 1 || tmp.length > 2) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, name));
}
// case: Brandt, Thilo
if (tmp.length == 2) {
if (tmp[0].length() < 3 || tmp[1].length() < 3) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, name));
} else {
if (tmp[0].endsWith(",")) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, tmp[0].substring(0, tmp[0].length() - 1)));
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, tmp[1]));
} else {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, tmp[1]));
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, tmp[0]));
}
}
}
if (e.getOrganizations().size() > 0) {
Organization o = (Organization) e.getOrganizations().get(0);
if (o != null && o.getOrgName() != null) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_ADDITIONAL, ((Organization) e.getOrganizations().get(0)).getOrgName().getValue()));
}
}
return m;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class GoogleContactsProxy method parseAddress.
/**
* Parsing the address field
*
* Street no.1 12345 city
*
* @param pa
* @return
*/
private IAttributeMap parseAddress(StructuredPostalAddress pa) {
IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
if (pa == null)
return m;
if (pa.hasCity()) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, pa.getCity().getValue()));
}
if (pa.hasPostcode()) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, pa.getPostcode().getValue()));
}
if (pa.hasStreet()) {
String[] street = splitStreet(pa.getStreet().getValue());
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, street[0]));
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET_NO, street[1]));
}
if (pa.hasCountry()) {
m.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, pa.getCountry().getValue()));
}
return m;
}
use of de.janrufmonitor.framework.IAttributeMap 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.IAttributeMap in project janrufmonitor by tbrandt77.
the class LdapMappingManager method mapAttributes.
private IAttributeMap mapAttributes(LDAPEntry entry) {
IAttributeMap attributes = getRuntime().getCallerFactory().createAttributeMap();
LDAPAttributeSet attributeSet = entry.getAttributeSet();
Iterator allAttributes = attributeSet.iterator();
while (allAttributes.hasNext()) {
LDAPAttribute attribute = (LDAPAttribute) allAttributes.next();
if (m_attributeMappings.values().contains(attribute.getName())) {
String value = attribute.getStringValue();
if (m_logger.isLoggable(Level.INFO)) {
m_logger.info("Adding LDAP attribute: " + attribute.getName() + ", value: " + value);
}
if (!m_inversAttributeMappings.getProperty(attribute.getName()).equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH)) {
attributes.add(getRuntime().getCallerFactory().createAttribute(m_inversAttributeMappings.getProperty(attribute.getName()), value));
} else {
try {
addImage(attributes, attribute.getByteValue(), entry);
} catch (IOException e) {
m_logger.log(Level.SEVERE, e.toString(), e);
}
}
}
}
return attributes;
}
Aggregations