Search in sources :

Example 66 with IAttribute

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

the class XMLCallHandler method startElement.

public void startElement(String uri, String name, String qname, Attributes attributes) throws SAXException {
    if (this.m_multi && qname.equalsIgnoreCase(TAG_CALLLIST)) {
        this.m_calllist = this.getRuntime().getCallFactory().createCallList();
    }
    if (qname.equalsIgnoreCase(TAG_CALL)) {
        this.m_call = this.getRuntime().getCallFactory().createCall(null, this.getRuntime().getCallFactory().createMsn("", ""), this.getRuntime().getCallFactory().createCip("", ""));
    }
    if (qname.equalsIgnoreCase(TAG_CALLER)) {
        this.m_iscaller = true;
    }
    if (this.m_iscaller) {
        super.startElement(uri, name, qname, attributes);
        return;
    }
    if (qname.equalsIgnoreCase(TAG_UUID)) {
        this.m_call.setUUID(attributes.getValue(ATTRIBUTE_VALUE));
    }
    if (qname.equalsIgnoreCase(TAG_DATE)) {
        this.m_call.setDate(new Date(Long.parseLong(attributes.getValue(ATTRIBUTE_VALUE))));
    }
    if (qname.equalsIgnoreCase(TAG_CIP)) {
        ICip cip = this.m_call.getCIP();
        cip.setCIP(attributes.getValue(ATTRIBUTE_VALUE));
        cip.setAdditional(this.getRuntime().getCipManager().getCipLabel(cip, this.getLanguage()));
        this.m_call.setCIP(cip);
    }
    if (qname.equalsIgnoreCase(TAG_MSN)) {
        IMsn msn = this.m_call.getMSN();
        msn.setMSN(attributes.getValue(ATTRIBUTE_VALUE));
        msn.setAdditional(decode(attributes.getValue(ATTRIBUTE_ADDITIONAL)));
        this.m_call.setMSN(msn);
    }
    if (qname.equalsIgnoreCase(TAG_ATTRIBUTE)) {
        IAttribute att = this.getRuntime().getCallerFactory().createAttribute(attributes.getValue(ATTRIBUTE_NAME), decode(attributes.getValue(ATTRIBUTE_VALUE)));
        this.m_call.setAttribute(att);
    }
}
Also used : ICip(de.janrufmonitor.framework.ICip) IAttribute(de.janrufmonitor.framework.IAttribute) IMsn(de.janrufmonitor.framework.IMsn) Date(java.util.Date)

Example 67 with IAttribute

use of de.janrufmonitor.framework.IAttribute 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 68 with IAttribute

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

the class OutlookTransformer method createPrivateAddressAttributes.

private IAttributeMap createPrivateAddressAttributes(Dispatch contact) throws ComFailException {
    IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
    IAttribute attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, Dispatch.get(contact, "HomeAddressCity").toString().trim());
    if (attribute != null)
        m.add(attribute);
    attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, Dispatch.get(contact, "HomeAddressPostalCode").toString().trim());
    if (attribute != null)
        m.add(attribute);
    attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, Dispatch.get(contact, "HomeAddressStreet").toString().trim());
    if (attribute != null)
        m.add(attribute);
    attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, Dispatch.get(contact, "HomeAddressCountry").toString().trim());
    if (attribute != null)
        m.add(attribute);
    return m;
}
Also used : IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Example 69 with IAttribute

use of de.janrufmonitor.framework.IAttribute 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)

Example 70 with IAttribute

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

the class OutlookTransformer method setPictureAttribute.

private void setPictureAttribute(ICaller outlookCaller, Dispatch contact) {
    try {
        if (Dispatch.get(contact, "HasPicture").getBoolean()) {
            String imagepath = MSO_IMAGE_CACHE_PATH + outlookCaller.getUUID() + ".jpg";
            if (!new File(imagepath).exists()) {
                Dispatch items = Dispatch.get(contact, "Attachments").toDispatch();
                int count = Integer.valueOf(Dispatch.get(items, "Count").toString()).intValue();
                if (count > 1)
                    this.m_logger.info("Found " + count + " attachments for outlook contact " + outlookCaller.toString());
                for (int i = 1; i <= count; i++) {
                    Dispatch item = Dispatch.call(items, "Item", new Integer(i)).toDispatch();
                    int type = Integer.valueOf(Dispatch.get(item, "Type").toString()).intValue();
                    // type 1 olAttachmentType = olByValue
                    if (type == 1) {
                        try {
                            String outlookFilename = Dispatch.get(item, "FileName").toString();
                            if (outlookFilename != null && (outlookFilename.startsWith("ContactPicture") || outlookFilename.startsWith("ContactPhoto"))) {
                                // imagepath = imagepath.substring(0, imagepath.length()-4) + (i>1? Integer.toString(i) : "") + ".jpg";
                                Dispatch.call(item, "SaveAsFile", new String(imagepath));
                            }
                        } catch (ComFailException ex) {
                            this.m_logger.warning("Could not get FileName attribute: " + ex.getMessage() + ", " + ex.getSource());
                        }
                    }
                }
            }
            IAttribute img = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(imagepath));
            outlookCaller.setAttribute(img);
        }
    } catch (ComFailException ex) {
        this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
    }
}
Also used : IAttribute(de.janrufmonitor.framework.IAttribute) Dispatch(com.jacob.com.Dispatch) File(java.io.File) ComFailException(com.jacob.com.ComFailException)

Aggregations

IAttribute (de.janrufmonitor.framework.IAttribute)111 ICaller (de.janrufmonitor.framework.ICaller)44 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)40 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)39 List (java.util.List)34 ICallerList (de.janrufmonitor.framework.ICallerList)31 ArrayList (java.util.ArrayList)29 Iterator (java.util.Iterator)25 ICall (de.janrufmonitor.framework.ICall)19 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)15 SQLException (java.sql.SQLException)15 File (java.io.File)14 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)12 IOException (java.io.IOException)12 Message (de.janrufmonitor.exception.Message)11 ComFailException (com.jacob.com.ComFailException)10 Date (java.util.Date)10 IMsn (de.janrufmonitor.framework.IMsn)9 Dispatch (com.jacob.com.Dispatch)8 UUID (de.janrufmonitor.util.uuid.UUID)8