package com.ximple.eofms.jobs.context.mysql; import java.io.IOException; import java.sql.Connection; import org.geotools.data.DataStore; import org.geotools.data.SchemaNotFoundException; import org.geotools.data.Transaction; import org.geotools.data.mysql.MySQLDataStore; import org.geotools.feature.FeatureType; import com.ximple.eofms.jobs.context.AbstractOracleJobContext; public abstract class AbstractOracleToMySQLJobContext extends AbstractOracleJobContext { protected MySQLDataStore targetDataStore; public AbstractOracleToMySQLJobContext(String dataPath, DataStore targetDataStore, boolean profileMode, boolean useTransform, boolean useEPSG3826) { super(profileMode, useTransform, useEPSG3826); if ((targetDataStore != null) && (targetDataStore instanceof MySQLDataStore)) { this.targetDataStore = (MySQLDataStore) targetDataStore; } else { getLogger().info("targetDataStore has wrong."); } setDataPath(dataPath); } public MySQLDataStore getTargetDataStore() { return targetDataStore; } public void setTargetDataStore(MySQLDataStore targetDataStore) { this.targetDataStore = targetDataStore; } public Connection getConnection() { if (targetDataStore != null) { try { return targetDataStore.getConnection(Transaction.AUTO_COMMIT); } catch (IOException e) { getLogger().warn(e.getMessage(), e); } } return null; } protected boolean isExistFeature(FeatureType featureType) { try { FeatureType existFeatureType = targetDataStore.getSchema(featureType.getTypeName()); return existFeatureType != null && existFeatureType.equals(featureType); } catch (SchemaNotFoundException e) { return false; } catch (IOException e) { getLogger().info(e.getMessage(), e); return false; } } }