forked from geodmms/xdgnjobs

?? ?
2008-05-16 5c0e9634ef20452c9fc66bb14a469e0a05369899
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java
@@ -44,6 +44,8 @@
    static final String SHPOUTPATH = "shpout";
    private OracleElementLogging elmLogger = null;
    static
    {
        try
@@ -68,6 +70,8 @@
    private String dataOut = null;
    private String _convertDB = null;
    private String _convertFile = null;
    private String currentSchema = null;
    private boolean schemaChanged = false;
    public OracleConvertJobContext(String filterConfig)
    {
@@ -97,7 +101,7 @@
            {
                // config = new File("conf/DefaultConvertShpFilter.xml");
                filterURL = this.getClass().getResource("/conf/DefaultConvertShpFilter.xml");
               // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
                // filterURL = this.getClass().getResource("/conf/ConvertShpFilterForLevel.xml");
            }
            assert filterURL != null;
            return (ElementDispatcher) digester.parse(filterURL);
@@ -133,6 +137,7 @@
                    ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" +
                    (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID())));
            getElementLogging().logElement(element, getCurrentSchema());
            return;
        }
@@ -146,15 +151,15 @@
    public void startTransaction()
    {
       //txFeaturesContext.startTransaction();
        //txFeaturesContext.startTransaction();
    }
    public void commitTransaction()
    {
       if (!txFeaturesContext.isEmpty())
       {
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
           //txFeaturesContext.commitTransaction();
            //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
@@ -164,11 +169,14 @@
        {
            updateDataStore();
        }
        if (this.getElementLogging() != null)
            this.getElementLogging().flashLogging();
    }
    public void rollbackTransaction()
    {
       //txFeaturesContext.rollbackTransaction();
        //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
@@ -188,16 +196,15 @@
                logger.debug("Begin Save shapefile:" + sfile.toURI());
                FeatureWriter writer = null;
                if(featuresWriterContext.containsKey(featureType.getTypeName()))
                if (featuresWriterContext.containsKey(featureType.getTypeName()))
                {
                    writer = featuresWriterContext.get(featureType.getTypeName()) ;
                }
                else
                    writer = featuresWriterContext.get(featureType.getTypeName());
                } else
                {
                  ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL());
                  shapefileDataStore.createSchema(featureType);
                  writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                  featuresWriterContext.put(featureType.getTypeName() , writer);
                    ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL());
                    shapefileDataStore.createSchema(featureType);
                    writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                    featuresWriterContext.put(featureType.getTypeName(), writer);
                }
                ArrayList features = (ArrayList) featuresContext.get(featureType);
@@ -236,9 +243,11 @@
    /**
     * Ãö³¬³]³Æ¼g¤J¾¹
     *
     * @throws IOException IOµo¥Í¿ù»~
     */
    public void closeFeatureWriter() throws IOException {
    public void closeFeatureWriter() throws IOException
    {
        for (FeatureWriter featureWriter : this.featuresWriterContext.values())
        {
@@ -250,6 +259,7 @@
    /**
     * ¨ú±o¸ê®Æ¿é¥X¸ô®|
     *
     * @return ¸ô®|ªº¦r¦ê
     */
    public String getDataOutPath()
@@ -278,4 +288,25 @@
    {
        _convertFile = convertFile;
    }
    private OracleElementLogging getElementLogging()
    {
        if (elmLogger == null)
        {
            elmLogger = new OracleElementLogging(getOracleConnection());
            elmLogger.setDataPath(this.getDataPath());
        }
        return elmLogger;
    }
    public String getCurrentSchema()
    {
        return currentSchema;
    }
    public void setCurrentSchema(String querySchema)
    {
        this.currentSchema = querySchema;
        this.schemaChanged = true;
    }
}