Search in sources :

Example 56 with ICaller

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

the class OutlookMappingManager method mapToJamCaller.

public ICaller mapToJamCaller(Dispatch oCaller, IOutlookMapping om) {
    if (this.m_logger.isLoggable(Level.INFO)) {
        this.m_logger.info("Applying mapping: " + om.toString());
    }
    IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
    // processing the numbers
    List outlookNumberMappings = om.getSupportedNumbers();
    List phones = new ArrayList(outlookNumberMappings.size());
    String numbertype = null;
    String number = null;
    IPhonenumber phone = null;
    for (int i = 0, j = outlookNumberMappings.size(); i < j; i++) {
        numbertype = (String) outlookNumberMappings.get(i);
        number = Dispatch.get(oCaller, numbertype).toString().trim();
        if (number != null && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(number) && !PhonenumberAnalyzer.getInstance(getRuntime()).isClired(number)) {
            if (this.m_logger.isLoggable(Level.INFO)) {
                this.m_logger.info("OutlookCallerManager raw number: " + number);
            }
            phone = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(number);
            if (this.m_logger.isLoggable(Level.INFO)) {
                this.m_logger.info("OutlookCallerManager identified number: " + phone);
            }
            if (phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
                m.add(getNumberTypeAttribute(numbertype, phone, om));
                m.add(om.createOutlookNumberTypeAttribute(phone, numbertype));
                phones.add(phone);
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("Added phone " + phone.toString());
                }
            }
        } else if (number != null && (number.length() > 0 && PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(number))) {
            // found internal number
            phone = getRuntime().getCallerFactory().createInternalPhonenumber(number);
            if (phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
                m.add(getNumberTypeAttribute(numbertype, phone, om));
                m.add(om.createOutlookNumberTypeAttribute(phone, numbertype));
                phones.add(phone);
                if (this.m_logger.isLoggable(Level.INFO)) {
                    this.m_logger.info("Added internal phone " + phone.toString());
                }
            }
        }
    }
    if (phones.size() > 0) {
        if (phones.size() > 1)
            Collections.sort(phones, new PhonenumberTypeComparator(m, om));
        // process address data
        List outlookContacFieldMappings = om.getSupportedContactFields();
        String field = null;
        String jamField = null;
        IAttribute a = null;
        for (int i = 0, j = outlookContacFieldMappings.size(); i < j; i++) {
            field = (String) outlookContacFieldMappings.get(i);
            jamField = om.mapToJamField(field);
            if (jamField != null) {
                a = createAttribute(jamField, Dispatch.get(oCaller, field).toString().trim());
                if (a != null) {
                    m.add(a);
                    if (this.m_logger.isLoggable(Level.INFO)) {
                        this.m_logger.info("Added attribute " + a.toString());
                    }
                    a = om.createOutlookContactFieldAttribute(field);
                    if (a != null)
                        m.add(a);
                }
            }
        }
        a = createAttribute(IJAMConst.ATTRIBUTE_NAME_CREATION, Long.toString(new OutlookDate(Dispatch.get(oCaller, "CreationTime").getDate()).getTime()));
        if (a != null)
            m.add(a);
        a = createAttribute(IJAMConst.ATTRIBUTE_NAME_MODIFIED, Long.toString(new OutlookDate(Dispatch.get(oCaller, "LastModificationTime").getDate()).getTime()));
        if (a != null)
            m.add(a);
        a = createAttribute("outlook.uuid", Dispatch.get(oCaller, OutlookContactConst.User1).toString());
        if (a != null)
            m.add(a);
        String geodata = null;
        if (om.getSupportedContactFields().contains(OutlookContactConst.User3)) {
            geodata = Dispatch.get(oCaller, OutlookContactConst.User3).toString();
        }
        if (om.getSupportedContactFields().contains(OutlookContactConst.User4)) {
            geodata = Dispatch.get(oCaller, OutlookContactConst.User4).toString();
        }
        if (geodata != null && geodata.trim().length() > 0) {
            if (this.m_logger.isLoggable(Level.INFO)) {
                this.m_logger.info("Found geodata: " + geodata);
            }
            String[] values = geodata.split(",");
            if (values.length == 3) {
                a = createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_ACC, values[0]);
                if (a != null)
                    m.add(a);
                a = createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, values[1]);
                if (a != null)
                    m.add(a);
                a = createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, values[2]);
                if (a != null)
                    m.add(a);
            }
        }
        IAttributeMap additionalMap = om.getSpecialAttributes();
        if (additionalMap != null) {
            if (this.m_logger.isLoggable(Level.INFO)) {
                this.m_logger.info("Adding special attributes: " + additionalMap.toString());
            }
            m.addAll(additionalMap);
        }
        // TODO: 2008/08/13 - Hack - split up street and street no
        IAttribute street = m.get(IJAMConst.ATTRIBUTE_NAME_STREET);
        if (street != null && street.getValue().trim().length() > 0) {
            String[] streetSplit = street.getValue().trim().split(" ");
            if (streetSplit.length > 1) {
                street.setValue("");
                for (int i = 0; i < streetSplit.length - 1; i++) {
                    street.setValue(street.getValue() + " " + streetSplit[i]);
                }
                street.setValue(street.getValue().trim());
                m.add(street);
                IAttribute streetno = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET_NO, streetSplit[streetSplit.length - 1]);
                m.add(streetno);
            }
        }
        ICaller outlookCaller = getRuntime().getCallerFactory().createCaller(null, phones, m);
        String uuid = Dispatch.get(oCaller, OutlookContactConst.User1).toString().trim();
        if (uuid != null && uuid.length() > 0)
            outlookCaller.setUUID(uuid);
        else
            // outlookCaller.setUUID(outlookCaller.getName().getLastname()+"_"+outlookCaller.getName().getFirstname()+"_"+outlookCaller.getPhoneNumber().getTelephoneNumber());
            outlookCaller.setUUID(new UUID().toString());
        this.setPictureAttribute(outlookCaller, oCaller);
        IAttribute cm = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ID);
        outlookCaller.setAttribute(cm);
        if (this.m_logger.isLoggable(Level.INFO)) {
            this.m_logger.info("Created Outlook contact: " + outlookCaller.toString());
        }
        return outlookCaller;
    }
    return null;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ArrayList(java.util.ArrayList) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) List(java.util.List) UUID(de.janrufmonitor.util.uuid.UUID) OutlookDate(de.janrufmonitor.repository.OutlookDate) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 57 with ICaller

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

the class QuickRejectAction method run.

public void run() {
    Viewer v = this.m_app.getApplication().getViewer();
    if (v != null && v instanceof Viewer) {
        final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
        if (!selection.isEmpty()) {
            Iterator i = selection.iterator();
            ICallerList list = this.getRuntime().getCallerFactory().createCallerList(selection.size());
            Object o = null;
            while (i.hasNext()) {
                o = i.next();
                if (o instanceof ICaller) {
                    if (this.isRejectable(((ICaller) o))) {
                        ((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_REJECT, IJAMConst.ATTRIBUTE_VALUE_NO));
                    } else
                        ((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_REJECT, IJAMConst.ATTRIBUTE_VALUE_YES));
                    list.add((ICaller) o);
                }
            }
            if (list.size() > 0) {
                this.m_app.getController().deleteElements(list);
                this.m_app.getController().addElements(list);
            }
            m_app.updateViews(true);
        }
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 58 with ICaller

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

the class Reject method createContents.

protected Control createContents(Composite parent) {
    this.setTitle(this.m_i18n.getString(this.getNamespace(), "title", "label", this.m_language));
    Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(new GridLayout(1, false));
    String label = this.m_i18n.getString(this.getNamespace(), "enabled", "label", this.m_language);
    if (label.length() < 150)
        for (int i = 150; i > label.length(); i--) {
            label += " ";
        }
    this.active = new Button(c, SWT.CHECK);
    this.active.setText(label);
    this.active.setSelection(this.getPreferenceStore().getBoolean(this.getConfigNamespace() + SEPARATOR + "enabled"));
    bfe = new BooleanFieldEditor(this.getConfigNamespace() + SEPARATOR + "allclir", this.m_i18n.getString(this.getNamespace(), "allclir", "label", this.m_language), c);
    bfe.setPreferenceStore(this.getPreferenceStore());
    bfe.doLoad();
    Composite c1 = new Composite(c, SWT.NONE);
    c1.setLayout(new GridLayout(3, false));
    Composite c11 = new Composite(c1, SWT.NONE);
    c11.setLayout(new GridLayout(1, false));
    new Label(c11, SWT.NONE).setText(this.m_i18n.getString(this.getNamespace(), "areacodes", "label", this.m_language));
    tv = new TableViewer(c11);
    tv.setContentProvider(new AcContentProvider());
    tv.setLabelProvider(new AcLabelProvider());
    Table t = tv.getTable();
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL_BOTH;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 150;
    gd.heightHint = 100;
    t.setLayoutData(gd);
    TableColumn tc = new TableColumn(t, SWT.LEFT);
    tc.getText();
    tv.setInput(this.getDataList());
    for (int i = 0, n = t.getColumnCount(); i < n; i++) {
        t.getColumn(i).pack();
        t.getColumn(i).setWidth(140);
    }
    t.setLinesVisible(false);
    Composite c12 = new Composite(c1, SWT.NONE);
    c12.setLayout(new GridLayout(1, false));
    Button add = new Button(c12, SWT.PUSH);
    add.setText(this.m_i18n.getString(this.getNamespace(), "add", "label", this.m_language));
    Button remove = new Button(c12, SWT.PUSH);
    remove.setText(this.m_i18n.getString(this.getNamespace(), "remove", "label", this.m_language));
    Composite c13 = new Composite(c1, SWT.NONE);
    c13.setLayout(new GridLayout(1, false));
    new Label(c13, SWT.NONE).setText(this.m_i18n.getString(this.getNamespace(), "edit", "label", this.m_language));
    final Text ip = new Text(c13, SWT.BORDER);
    gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.widthHint = 100;
    ip.setLayoutData(gd);
    ip.setText("");
    add.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (ip.getText().length() > 0 && !dataList.contains(ip.getText())) {
                ICaller c = Identifier.identifyDefault(getRuntime(), getRuntime().getCallerFactory().createPhonenumber(PhonenumberAnalyzer.getInstance(getRuntime()).normalize(ip.getText())));
                if (c != null) {
                    dataList.add(Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, c.getPhoneNumber()));
                }
                // dataList.add(ip.getText());
                tv.setInput(dataList);
                for (int i = 0, n = tv.getTable().getColumnCount(); i < n; i++) {
                    tv.getTable().getColumn(i).pack();
                }
            }
        }
    });
    remove.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            StructuredSelection s = (StructuredSelection) tv.getSelection();
            if (!s.isEmpty()) {
                String o = (String) s.getFirstElement();
                ip.setText(o);
                dataList.remove(o);
                tv.setInput(dataList);
                for (int i = 0, n = tv.getTable().getColumnCount(); i < n; i++) {
                    tv.getTable().getColumn(i).pack();
                }
            }
        }
    });
    return c;
}
Also used : Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) BooleanFieldEditor(de.janrufmonitor.ui.jface.configuration.controls.BooleanFieldEditor) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) ICaller(de.janrufmonitor.framework.ICaller) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 59 with ICaller

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

the class Reject method getDataList.

private List getDataList() {
    if (this.dataList == null || this.dataList.size() == 0) {
        this.dataList = new ArrayList();
        String allowedList = this.getPreferenceStore().getString(this.getConfigNamespace() + SEPARATOR + "rejectareacodes");
        if (allowedList.trim().length() > 0) {
            StringTokenizer st = new StringTokenizer(allowedList, ",");
            while (st.hasMoreTokens()) {
                String ip = st.nextToken().trim();
                if (ip.length() > 0) {
                    ICaller c = Identifier.identifyDefault(getRuntime(), getRuntime().getCallerFactory().createPhonenumber(ip));
                    if (c != null) {
                        this.dataList.add(Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, c.getPhoneNumber()));
                    }
                }
            }
        }
    }
    return this.dataList;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList)

Example 60 with ICaller

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

the class Reject method getDefaultDataList.

private List getDefaultDataList() {
    if (this.dataList == null || this.dataList.size() == 0) {
        this.dataList = new ArrayList();
        String allowedList = this.getPreferenceStore().getDefaultString(this.getConfigNamespace() + SEPARATOR + "rejectareacodes");
        if (allowedList.trim().length() > 0) {
            StringTokenizer st = new StringTokenizer(allowedList, ",");
            while (st.hasMoreTokens()) {
                String ip = st.nextToken().trim();
                if (ip.length() > 0) {
                    ICaller c = Identifier.identifyDefault(getRuntime(), getRuntime().getCallerFactory().createPhonenumber(ip));
                    if (c != null) {
                        this.dataList.add(Formatter.getInstance(getRuntime()).parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, c.getPhoneNumber()));
                    }
                }
            }
        }
    }
    return this.dataList;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList)

Aggregations

ICaller (de.janrufmonitor.framework.ICaller)144 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)62 ICallerList (de.janrufmonitor.framework.ICallerList)49 List (java.util.List)46 IAttribute (de.janrufmonitor.framework.IAttribute)42 ICall (de.janrufmonitor.framework.ICall)41 ArrayList (java.util.ArrayList)40 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)32 SQLException (java.sql.SQLException)26 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)25 IOException (java.io.IOException)25 Viewer (org.eclipse.jface.viewers.Viewer)24 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 File (java.io.File)20 Date (java.util.Date)17 Iterator (java.util.Iterator)17 Shell (org.eclipse.swt.widgets.Shell)17 IMsn (de.janrufmonitor.framework.IMsn)16 Properties (java.util.Properties)15 ICip (de.janrufmonitor.framework.ICip)14