| | |
| | | package com.ximple.eofms.jobs; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.MalformedURLException; |
| | | import java.sql.DriverManager; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.Properties; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | |
| | | import org.apache.commons.transaction.memory.PessimisticMapWrapper; |
| | | import org.apache.commons.transaction.util.CommonsLoggingLogger; |
| | | import org.apache.commons.transaction.util.LoggerFacade; |
| | | import org.geotools.data.FeatureWriter; |
| | | import org.geotools.data.Transaction; |
| | | import org.geotools.data.shapefile.ShapefileDataStore; |
| | | import org.geotools.feature.Feature; |
| | | import org.geotools.feature.FeatureType; |
| | | import org.geotools.feature.IllegalAttributeException; |
| | | import org.geotools.feature.SimpleFeature; |
| | | |
| | | import com.vividsolutions.jts.util.Assert; |
| | | |
| | |
| | | private String _oracleHost; |
| | | private String _oracleInstance; |
| | | private String _oraclePort; |
| | | private String _dataPath; |
| | | |
| | | private OracleConnection oracleConnection = null; |
| | | private Properties properties; |
| | |
| | | { |
| | | properties.put(PROPUsrKey, userName); |
| | | properties.put(PROPPassKey, password); |
| | | } |
| | | |
| | | public void setShapeData(String dataPath) |
| | | { |
| | | _dataPath = dataPath; |
| | | } |
| | | |
| | | public OracleConnection getOracleConnection() |
| | |
| | | private void updateDataStore() |
| | | { |
| | | // todo: |
| | | Iterator it = featuresContext.keySet().iterator(); |
| | | |
| | | try |
| | | { |
| | | while (it.hasNext()) |
| | | { |
| | | FeatureType featureType = (FeatureType) it.next(); |
| | | File sfile = new File(_dataPath + "\\" + featureType.getTypeName()); |
| | | ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURL()); |
| | | shapefileDataStore.createSchema(featureType); |
| | | FeatureWriter writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); |
| | | ArrayList features = (ArrayList) featuresContext.get(featureType); |
| | | Iterator itFeature = features.iterator(); |
| | | while (itFeature.hasNext()) |
| | | { |
| | | Feature feature = (Feature) itFeature.next(); |
| | | ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null)); |
| | | } |
| | | writer.close(); |
| | | } |
| | | featuresContext.clear(); |
| | | } catch (MalformedURLException e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IllegalAttributeException e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } catch (IOException e) |
| | | { |
| | | logger.error(e.getMessage(), e); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |