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 com.ximple.eofms.jobs.context.AbstractDgnFileJobContext; import org.opengis.feature.simple.SimpleFeatureType; public abstract class AbstractDgnToMySQLJobContext extends AbstractDgnFileJobContext { protected MySQLDataStore targetDataStore; public AbstractDgnToMySQLJobContext(String dataPath, DataStore targetDataStore, boolean profileMode, boolean useTransform) { super(dataPath, profileMode, useTransform); this.targetDataStore = (MySQLDataStore) targetDataStore; } 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(SimpleFeatureType featureType) { try { SimpleFeatureType 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; } } }