| | |
| | | import com.ximple.io.dgn7.Element; |
| | | import com.ximple.io.dgn7.FrammeAttributeData; |
| | | |
| | | |
| | | public class OracleConvertJobContext extends AbstractOracleJobContext |
| | | { |
| | | static Log logger = LogFactory.getLog(OracleConvertJobContext.class); |
| | |
| | | private ElementDispatcher elementDispatcher; |
| | | |
| | | private HashMap featuresContext = new HashMap(); |
| | | private HashMap featuresWriterContext = new HashMap(); |
| | | private PessimisticMapWrapper txFeaturesContext; |
| | | |
| | | private JobExecutionContext executionContext; |
| | |
| | | |
| | | 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."); |
| | | } |
| | | |
| | | if (!featuresContext.isEmpty()) |
| | | { |
| | |
| | | |
| | | public void rollbackTransaction() |
| | | { |
| | | txFeaturesContext.rollbackTransaction(); |
| | | //txFeaturesContext.rollbackTransaction(); |
| | | if (!featuresContext.isEmpty()) |
| | | { |
| | | updateDataStore(); |
| | |
| | | private void updateDataStore() |
| | | { |
| | | // todo: |
| | | Iterator it = featuresContext.keySet().iterator(); |
| | | Iterator it = featuresContext.keySet().iterator(); |
| | | |
| | | try |
| | | { |
| | |
| | | File sfile = new File(_dataPath + "\\" + featureType.getTypeName()); |
| | | logger.debug("Begin Save shapefile:" + sfile.toURI()); |
| | | |
| | | ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL()); |
| | | shapefileDataStore.createSchema(featureType); |
| | | FeatureWriter writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); |
| | | FeatureWriter writer = null; |
| | | if(featuresWriterContext.containsKey( featureType.getTypeName())) |
| | | { |
| | | writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()) ; |
| | | } |
| | | else |
| | | { |
| | | ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL()); |
| | | shapefileDataStore.createSchema(featureType); |
| | | writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT); |
| | | if(this.featuresWriterContext == null) |
| | | { |
| | | this.featuresWriterContext = new HashMap(); |
| | | } |
| | | featuresWriterContext.put(featureType.getTypeName() , writer); |
| | | } |
| | | |
| | | 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(); |
| | | //writer.close(); |
| | | logger.debug("End Save shapefile:" + sfile.toURI()); |
| | | } |
| | | featuresContext.clear(); |
| | |
| | | { |
| | | executionContext = context; |
| | | } |
| | | |
| | | public void closeFeatureWrite() throws IOException { |
| | | Iterator iter = this.featuresWriterContext.values().iterator(); |
| | | |
| | | while(iter.hasNext()) |
| | | { |
| | | FeatureWriter writer = (FeatureWriter) iter.next(); |
| | | writer.close(); |
| | | } |
| | | |
| | | this.featuresWriterContext = null; |
| | | } |
| | | } |