Search in sources :

Example 31 with IAttribute

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

the class EabFileCallerExporter method doExport.

public boolean doExport() {
    File db = new File(m_filename);
    try {
        Properties addressbook = new Properties();
        FileOutputStream fo = new FileOutputStream(db);
        ICaller c = null;
        addressbook.setProperty("total", Integer.toString(this.m_callerList.size()));
        for (int i = 0; i < this.m_callerList.size(); i++) {
            c = this.m_callerList.get(i);
            if (c instanceof IMultiPhoneCaller) {
                List phones = ((IMultiPhoneCaller) c).getPhonenumbers();
                addressbook.setProperty((i + 1) + ".phonecount", Integer.toString(phones.size()));
                for (int a = 0, b = phones.size(); a < b; a++) {
                    addressbook.setProperty((i + 1) + ".intarea." + a, ((IPhonenumber) phones.get(a)).getIntAreaCode());
                    addressbook.setProperty((i + 1) + ".area." + a, ((IPhonenumber) phones.get(a)).getAreaCode());
                    addressbook.setProperty((i + 1) + ".phone." + a, ((IPhonenumber) phones.get(a)).getCallNumber());
                }
            } else {
                addressbook.setProperty((i + 1) + ".intarea", c.getPhoneNumber().getIntAreaCode());
                addressbook.setProperty((i + 1) + ".area", c.getPhoneNumber().getAreaCode());
                addressbook.setProperty((i + 1) + ".phone", c.getPhoneNumber().getCallNumber());
            }
            IAttributeMap attributes = c.getAttributes();
            Iterator iter = attributes.iterator();
            IAttribute a = null;
            while (iter.hasNext()) {
                a = (IAttribute) iter.next();
                addressbook.setProperty((i + 1) + "." + a.getName(), a.getValue());
            }
        }
        addressbook.store(fo, "");
        fo.close();
    } catch (FileNotFoundException ex) {
        this.m_logger.severe("File not found: " + m_filename);
        return false;
    } catch (IOException ex) {
        this.m_logger.severe("IOException on file " + m_filename);
        return false;
    }
    return true;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) FileOutputStream(java.io.FileOutputStream) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) FileNotFoundException(java.io.FileNotFoundException) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) List(java.util.List) ICallerList(de.janrufmonitor.framework.ICallerList) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File)

Example 32 with IAttribute

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

the class OldDatFileCallImporter method parseState.

private IAttribute parseState(String state) {
    IAttribute att = PIMRuntime.getInstance().getCallFactory().createAttribute("", "");
    if (state.equalsIgnoreCase("1")) {
        att.setName(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS);
        att.setValue(IJAMConst.ATTRIBUTE_VALUE_REJECTED);
    } else if (state.equalsIgnoreCase("2")) {
        att.setName(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS);
        att.setValue(IJAMConst.ATTRIBUTE_VALUE_ACCEPTED);
    } else {
        att.setName(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS);
        att.setValue(IJAMConst.ATTRIBUTE_VALUE_MISSED);
    }
    return att;
}
Also used : IAttribute(de.janrufmonitor.framework.IAttribute)

Example 33 with IAttribute

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

the class MultiPhoneCaller method clone.

public Object clone() throws CloneNotSupportedException {
    Name cloneName = new Name(this.getName().getFirstname(), this.getName().getLastname(), this.getName().getAdditional());
    List clonePhones = new ArrayList(m_phones.size());
    Phonenumber pn = null;
    for (int i = 0, j = m_phones.size(); i < j; i++) {
        pn = new Phonenumber(((IPhonenumber) m_phones.get(i)).getTelephoneNumber());
        pn.setAreaCode(((IPhonenumber) m_phones.get(i)).getAreaCode());
        pn.setCallNumber(((IPhonenumber) m_phones.get(i)).getCallNumber());
        pn.setIntAreaCode(((IPhonenumber) m_phones.get(i)).getIntAreaCode());
        pn.setClired(((IPhonenumber) m_phones.get(i)).isClired());
        clonePhones.add(pn);
    }
    AttributeMap cloneAttribs = new AttributeMap(this.getAttributes().size());
    Iterator i = this.getAttributes().iterator();
    IAttribute att = null;
    while (i.hasNext()) {
        att = (IAttribute) i.next();
        Attribute cloneAttrib = new Attribute(att.getName(), att.getValue());
        cloneAttribs.add(cloneAttrib);
    }
    if (clonePhones.size() == 0)
        clonePhones.add(this.getPhoneNumber());
    MultiPhoneCaller cloneCaller = new MultiPhoneCaller(this.getUUID(), cloneName, clonePhones, cloneAttribs);
    if (clonePhones.size() > 0)
        cloneCaller.setPhoneNumber((IPhonenumber) clonePhones.get(0));
    return cloneCaller;
}
Also used : IAttributeMap(de.janrufmonitor.framework.IAttributeMap) IMultiPhoneCaller(de.janrufmonitor.framework.IMultiPhoneCaller) IAttribute(de.janrufmonitor.framework.IAttribute) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) List(java.util.List) ArrayList(java.util.ArrayList) IPhonenumber(de.janrufmonitor.framework.IPhonenumber) IName(de.janrufmonitor.framework.IName) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 34 with IAttribute

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

the class DatFileCallImporter method migrateStatus.

private void migrateStatus(ICall c) {
    if (c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS) != null)
        return;
    IAttribute a = c.getAttribute(IJAMConst.ATTRIBUTE_VALUE_ACCEPTED);
    if (a != null) {
        c.getAttributes().remove(a);
        a.setName(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS);
        a.setValue((a.getValue().equals(IJAMConst.ATTRIBUTE_VALUE_YES) ? IJAMConst.ATTRIBUTE_VALUE_ACCEPTED : IJAMConst.ATTRIBUTE_VALUE_MISSED));
        c.setAttribute(a);
        return;
    }
    a = c.getAttribute(IJAMConst.ATTRIBUTE_VALUE_REJECTED);
    if (a != null) {
        c.getAttributes().remove(a);
        a.setName(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS);
        a.setValue((a.getValue().equals(IJAMConst.ATTRIBUTE_VALUE_YES) ? IJAMConst.ATTRIBUTE_VALUE_REJECTED : IJAMConst.ATTRIBUTE_VALUE_MISSED));
        c.setAttribute(a);
        return;
    }
    a = c.getAttribute(IJAMConst.ATTRIBUTE_VALUE_OUTGOING);
    if (a != null) {
        c.getAttributes().remove(a);
        a.setName(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS);
        a.setValue((a.getValue().equals(IJAMConst.ATTRIBUTE_VALUE_YES) ? IJAMConst.ATTRIBUTE_VALUE_OUTGOING : IJAMConst.ATTRIBUTE_VALUE_MISSED));
        c.setAttribute(a);
        return;
    }
    c.setAttribute(PIMRuntime.getInstance().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
}
Also used : IAttribute(de.janrufmonitor.framework.IAttribute)

Example 35 with IAttribute

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

the class Call method clone.

public Object clone() throws CloneNotSupportedException {
    Caller cloneCaller = (Caller) ((Caller) this.m_caller).clone();
    String cloneUuid = this.m_uuid;
    Date cloneDate = this.m_date;
    AttributeMap cloneAttribs = new AttributeMap();
    Iterator i = this.m_attributeMap.iterator();
    IAttribute att = null;
    while (i.hasNext()) {
        att = (IAttribute) i.next();
        Attribute cloneAttrib = new Attribute(att.getName(), att.getValue());
        cloneAttribs.add(cloneAttrib);
    }
    Cip cloneCip = new Cip(this.m_cip.getCIP(), this.m_cip.getAdditional());
    Msn cloneMsn = new Msn(this.m_msn.getMSN(), this.m_msn.getAdditional());
    return new Call(cloneUuid, cloneCaller, cloneMsn, cloneCip, cloneDate, cloneAttribs);
}
Also used : ICall(de.janrufmonitor.framework.ICall) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ICaller(de.janrufmonitor.framework.ICaller) IAttribute(de.janrufmonitor.framework.IAttribute) Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute) IMsn(de.janrufmonitor.framework.IMsn) ICip(de.janrufmonitor.framework.ICip) Date(java.util.Date)

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