Search in sources :

Example 1 with DBFReader

use of com.linuxense.javadbf.DBFReader in project janrufmonitor by tbrandt77.

the class FritzXCallImporter method doImport.

public ICallList doImport() {
    long startDate = System.currentTimeMillis();
    try {
        File fritzxfile = new File(m_filename);
        FileInputStream fis = new FileInputStream(fritzxfile);
        DBFReader dbfReader = new DBFReader(fis);
        int size = dbfReader.getRecordCount();
        size = Math.abs(size);
        m_callList = getRuntime().getCallFactory().createCallList(size);
        Object[] rowObjects = null;
        CallCollection cc = null;
        List cc_list = new ArrayList();
        while ((rowObjects = dbfReader.nextRecord()) != null) {
            if (cc != null && cc.getId().equalsIgnoreCase((String) rowObjects[0])) {
                cc.add(rowObjects);
            } else {
                cc = new CallCollection((String) rowObjects[0]);
                cc_list.add(cc);
                cc.add(rowObjects);
            }
        }
        for (int i = 0, j = cc_list.size(); i < j; i++) {
            new MigratorThread(this.m_callList, (CallCollection) cc_list.get(i)).run();
        }
        fis.close();
    } catch (FileNotFoundException ex) {
        this.m_logger.warning("Cannot find call file " + m_filename);
        return this.m_callList;
    } catch (IOException ex) {
        this.m_logger.severe("IOException on file " + m_filename);
        return this.m_callList;
    }
    long endDate = System.currentTimeMillis();
    this.m_logger.info("Successfully imported call file " + m_filename);
    this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + new Float((endDate - startDate) / 1000).toString() + " secs.");
    return m_callList;
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) DBFReader(com.linuxense.javadbf.DBFReader) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 2 with DBFReader

use of com.linuxense.javadbf.DBFReader in project janrufmonitor by tbrandt77.

the class FritzXCallImporter2 method doImport.

public ICallList doImport() {
    long startDate = System.currentTimeMillis();
    try {
        File fritzxfile = new File(m_filename);
        FileInputStream fis = new FileInputStream(fritzxfile);
        DBFReader dbfReader = new DBFReader(fis);
        int size = dbfReader.getRecordCount();
        size = Math.abs(size);
        m_callList = getRuntime().getCallFactory().createCallList(size);
        Object[] rowObjects = null;
        CallCollection cc = null;
        List cc_list = new ArrayList();
        while ((rowObjects = dbfReader.nextRecord()) != null) {
            if (cc != null && cc.getId().equalsIgnoreCase((String) rowObjects[0])) {
                cc.add(rowObjects);
            } else {
                cc = new CallCollection((String) rowObjects[0]);
                cc_list.add(cc);
                cc.add(rowObjects);
            }
        }
        for (int i = 0, j = cc_list.size(); i < j; i++) {
            new MigratorThread(this.m_callList, (CallCollection) cc_list.get(i)).run();
        }
        fis.close();
    } catch (FileNotFoundException ex) {
        this.m_logger.warning("Cannot find call file " + m_filename);
        return this.m_callList;
    } catch (IOException ex) {
        this.m_logger.severe("IOException on file " + m_filename);
        return this.m_callList;
    }
    long endDate = System.currentTimeMillis();
    this.m_logger.info("Successfully imported call file " + m_filename);
    this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + new Float((endDate - startDate) / 1000).toString() + " secs.");
    return m_callList;
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) DBFReader(com.linuxense.javadbf.DBFReader) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Aggregations

DBFReader (com.linuxense.javadbf.DBFReader)2 ICallList (de.janrufmonitor.framework.ICallList)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2