Search in sources :

Example 1 with Organization

use of com.google.gdata.data.extensions.Organization 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;
}
Also used : Organization(com.google.gdata.data.extensions.Organization) IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Aggregations

Organization (com.google.gdata.data.extensions.Organization)1 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)1