forked from geodmms/xdgnjobs

?? ?
2008-03-17 7315f507c6dae697f11c4c36d17b159959163148
update for EOFM-20
2 files modified
61 ■■■■ changed files
ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java 51 ●●●● patch | view | raw | blame | history
ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java 10 ●●●●● patch | view | raw | blame | history
ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/AbstractOracleDatabaseJob.java
@@ -1,11 +1,12 @@
package com.ximple.eofms.jobs;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.sql.SQLException;
import org.apache.commons.logging.Log;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
@@ -25,6 +26,7 @@
    private static final String ORAPORT = "ORAPORT";
    private static final String ORAUSER = "ORAUSER";
    private static final String ORAPASS = "ORAPASS";
    private static final String TESTMODE = "TESTMODE";
    protected String _dataPath;
    protected String _oracleHost;
@@ -33,8 +35,11 @@
    protected String _username;
    protected String _password;
    protected String _orgSchema;
    protected boolean _testMode = false;
    public abstract void execute(JobExecutionContext context) throws JobExecutionException;
    public Log getLogger() { return null; }
    protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException
    {
@@ -47,10 +52,16 @@
        _username = dataMap.getString(ORAUSER);
        _password = dataMap.getString(ORAPASS);
        _orgSchema = dataMap.getString(SPATAILSCHEMA);
        _testMode = dataMap.getBooleanFromString(TESTMODE);
        // Validate the required input
        if (_dataPath == null)
        {
            Log logger = getLogger();
            if (logger != null)
            {
                logger.warn("Cannot found data directory in configarion.");
            }
            throw new JobExecutionException("Directory not configured");
        }
@@ -58,7 +69,33 @@
        File dir = new File(_dataPath);
        if (!dir.exists())
        {
            Log logger = getLogger();
            if (logger != null)
            {
                logger.warn("Cannot found data directory in file system.[" + _dataPath + "]");
            }
            throw new JobExecutionException("Invalid Dir " + _dataPath);
        }
        if (_oracleHost == null)
        {
            throw new JobExecutionException("Unknown Oracle Host.");
        }
        if (_oracleInstance == null)
        {
            throw new JobExecutionException("Unknown Oracle Instance.");
        }
        if (_username == null)
        {
            throw new JobExecutionException("Unknown Oracle Username.");
        }
        if (_password == null)
        {
            throw new JobExecutionException("Unknown Oracle Password.");
        }
        if (_orgSchema == null)
        {
            throw new JobExecutionException("Unknown Spatial Database Schema.");
        }
    }
@@ -72,11 +109,11 @@
        byte[] raw = null;
        // BLOB        blob        = (BLOB) rs.getBlob(1);
        int         optimalSize = blob.getChunkSize();
        byte[]      chunk       = new byte[optimalSize];
        InputStream is          = blob.getBinaryStream(0);
        ByteBuffer buffer      = null;    // ByteBuffer.allocate(optimalSize);
        int         len         = 0;
        int optimalSize = blob.getChunkSize();
        byte[] chunk = new byte[optimalSize];
        InputStream is = blob.getBinaryStream(0);
        ByteBuffer buffer = null;    // ByteBuffer.allocate(optimalSize);
        int len = 0;
        try
        {
@@ -104,5 +141,5 @@
        return raw;
    }
}
ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
@@ -74,6 +74,11 @@
        }
    }
    public Log getLogger()
    {
        return logger;
    }
    public void execute(JobExecutionContext context) throws JobExecutionException
    {
        // Every job has its own job detail
@@ -95,6 +100,7 @@
            exetcuteConvert(jobContext, _orgSchema, _dataPath);
        } catch (SQLException e)
        {
            logger.warn(e.getMessage(), e);
            throw new JobExecutionException("Database error.", e);
        }
@@ -115,9 +121,12 @@
            String tableSrc = (String) pair.first;
            logger.info("begin convert:[" + order + "]-" + tableSrc);
            queryIgsetElement(jobContext, querySchema, tableSrc);
            order++;
            if (_testMode) break;
            if ((order % COMMITSIZE) == 0)
            {
@@ -127,6 +136,7 @@
            }
        }
        logger.info("end convert job:[" + order + "]");
        System.gc();
    }