Search in sources :

Example 46 with ICallerList

use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.

the class HttpCallerManager method setCaller.

public void setCaller(ICaller caller) {
    ICallerList cl = this.getRuntime().getCallerFactory().createCallerList();
    cl.add(caller);
    this.setCaller(cl);
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList)

Example 47 with ICallerList

use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.

the class HttpCallerManager method getCallers.

public ICallerList getCallers(IFilter[] filters, ISearchTerm[] searchTerms) {
    if (!this.isConnected()) {
        this.m_logger.warning("Client is not yet connected with the server.");
        return this.getRuntime().getCallerFactory().createCallerList();
    }
    IRequester r = this.getRequester(new CallerListGetHandler(this.getCallerManager(), filters, searchTerms));
    IHttpResponse resp = r.request();
    String xml = this.getXmlContent(resp);
    this.handleRequester(resp, r);
    ICallerList l = XMLSerializer.toCallerList(xml);
    if (l != null) {
        this.addCallerManagerAttribute(l);
        return l;
    }
    this.m_logger.warning("Callerlist from remote host was empty.");
    return this.getRuntime().getCallerFactory().createCallerList();
}
Also used : CallerListGetHandler(de.janrufmonitor.service.client.request.handler.CallerListGetHandler) ICallerList(de.janrufmonitor.framework.ICallerList) IRequester(de.janrufmonitor.service.commons.http.IRequester) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 48 with ICallerList

use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.

the class HttpCallerManager method updateCaller.

public void updateCaller(ICaller caller) {
    ICallerList cl = this.getRuntime().getCallerFactory().createCallerList();
    cl.add(caller);
    if (!this.isConnected()) {
        this.m_logger.warning("Client is not yet connected with the server.");
        return;
    }
    IRequester r = null;
    IHttpResponse resp = null;
    r = this.getRequester(new CallerListUpdateHandler(cl, this.getCallerManager()));
    resp = r.request();
    this.handleRequester(resp, r);
    ImageCache.getInstance().remove(caller.getPhoneNumber().getTelephoneNumber());
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList) IRequester(de.janrufmonitor.service.commons.http.IRequester) CallerListUpdateHandler(de.janrufmonitor.service.client.request.handler.CallerListUpdateHandler) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Example 49 with ICallerList

use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.

the class OutlookTransformer method createBusinessCallerList.

private ICallerList createBusinessCallerList(Dispatch contact) throws ComFailException {
    ICallerList callerList = getRuntime().getCallerFactory().createCallerList();
    IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
    IAttribute attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, Dispatch.get(contact, "Firstname").toString().trim());
    if (attribute != null)
        m.add(attribute);
    attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, Dispatch.get(contact, "Lastname").toString().trim());
    if (attribute != null)
        m.add(attribute);
    if (m.size() == 0) {
        attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, Dispatch.get(contact, "CompanyName").toString().trim());
        if (attribute != null)
            m.add(attribute);
    } else {
        attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_ADDITIONAL, Dispatch.get(contact, "CompanyName").toString().trim());
        if (attribute != null)
            m.add(attribute);
    }
    // check if business caller exists
    if (m.size() > 0) {
        m.addAll(createBusinessAddressAttributes(contact));
        List phones = new ArrayList(businessPhones.length);
        IPhonenumber phone = getRuntime().getCallerFactory().createPhonenumber(false);
        String number = null;
        for (int i = 0; i < businessPhones.length; i++) {
            number = Dispatch.get(contact, businessPhones[i]).toString().trim();
            if (number != null && number.length() > 0) {
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("OutlookTransformer raw number: " + number);
                }
                phone = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(number);
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("OutlookTransformer identified number: " + phone);
                }
                if (phone != null) {
                    if (phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
                        m.add(getNumberTypeAttribute(businessPhones[i], phone.getTelephoneNumber()));
                        phones.add(phone);
                    }
                }
            }
        }
        if (phones.size() > 0) {
            ICaller outlookCaller = getRuntime().getCallerFactory().createCaller(null, phones, m);
            // outlookCaller.setAttributes(m);
            outlookCaller.setUUID(outlookCaller.getName().getLastname() + "_" + outlookCaller.getName().getFirstname() + "_" + outlookCaller.getPhoneNumber().getTelephoneNumber());
            this.setPictureAttribute(outlookCaller, contact);
            IAttribute cm = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ID);
            outlookCaller.setAttribute(cm);
            this.m_logger.fine("Created Outlook contact: " + outlookCaller.toString());
            callerList.add(outlookCaller);
        }
    }
    return callerList;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) IAttribute(de.janrufmonitor.framework.IAttribute) ArrayList(java.util.ArrayList) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 50 with ICallerList

use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.

the class OutlookTransformer method createPrivateCallerList.

private ICallerList createPrivateCallerList(Dispatch contact) throws ComFailException {
    ICallerList callerList = getRuntime().getCallerFactory().createCallerList();
    IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
    IAttribute attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, Dispatch.get(contact, "Firstname").toString().trim());
    if (attribute != null)
        m.add(attribute);
    attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, Dispatch.get(contact, "Lastname").toString().trim());
    if (attribute != null)
        m.add(attribute);
    // check if private caller exists
    if (m.size() > 0) {
        m.addAll(createPrivateAddressAttributes(contact));
        List phones = new ArrayList(businessPhones.length);
        IPhonenumber phone = getRuntime().getCallerFactory().createPhonenumber(false);
        String number = null;
        for (int i = 0; i < privatePhones.length; i++) {
            number = Dispatch.get(contact, privatePhones[i]).toString().trim();
            if (number != null && number.length() > 0) {
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("OutlookTransformer raw number: " + number);
                }
                phone = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(number);
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("OutlookTransformer identified number: " + phone);
                }
                if (phone != null) {
                    if (phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
                        m.add(getNumberTypeAttribute(privatePhones[i], phone.getTelephoneNumber()));
                        phones.add(phone);
                    }
                }
            }
        }
        if (phones.size() > 0) {
            ICaller outlookCaller = getRuntime().getCallerFactory().createCaller(null, phones, m);
            outlookCaller.setUUID(outlookCaller.getName().getLastname() + "_" + outlookCaller.getName().getFirstname() + "_" + outlookCaller.getPhoneNumber().getTelephoneNumber());
            this.setPictureAttribute(outlookCaller, contact);
            IAttribute cm = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ID);
            outlookCaller.setAttribute(cm);
            this.m_logger.fine("Created Outlook contact: " + outlookCaller.toString());
            callerList.add(outlookCaller);
        }
    }
    return callerList;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) IAttribute(de.janrufmonitor.framework.IAttribute) ArrayList(java.util.ArrayList) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

ICallerList (de.janrufmonitor.framework.ICallerList)81 ICaller (de.janrufmonitor.framework.ICaller)40 List (java.util.List)36 ArrayList (java.util.ArrayList)32 IAttribute (de.janrufmonitor.framework.IAttribute)24 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)24 SQLException (java.sql.SQLException)24 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)18 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)17 IOException (java.io.IOException)15 Message (de.janrufmonitor.exception.Message)14 Iterator (java.util.Iterator)11 Map (java.util.Map)11 File (java.io.File)10 HashMap (java.util.HashMap)10 Viewer (org.eclipse.jface.viewers.Viewer)10 ICallerManager (de.janrufmonitor.repository.ICallerManager)9 ComFailException (com.jacob.com.ComFailException)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)7