diff --git a/app/controllers/helper/ShapefilesCreatorHelper.java b/app/controllers/helper/ShapefilesCreatorHelper.java index 2c24657eab..921c40bf5a 100644 --- a/app/controllers/helper/ShapefilesCreatorHelper.java +++ b/app/controllers/helper/ShapefilesCreatorHelper.java @@ -66,28 +66,25 @@ public static void createGeneralShapeFile(String outputFile, SimpleFeatureType T * * Each data store has different limitations so check the resulting SimpleFeatureType. */ -// // Implementing Batch processing to send features in batchsize of 20k - final int batchSize = 20000; - if (featureSource instanceof SimpleFeatureStore) { - SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource; - try { - - for (int i = 0; i < features.size(); i += batchSize) { - int endIdx = Math.min(i + batchSize, features.size()); - List batchFeatures = features.subList(i, endIdx); - - SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, batchFeatures); - featureStore.setTransaction(transaction); - featureStore.addFeatures(collection); - } - transaction.commit(); - } catch (Exception problem) { - problem.printStackTrace(); - transaction.rollback(); - } finally { - transaction.close(); - } + if (featureSource instanceof SimpleFeatureStore) { + SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource; + /* + * SimpleFeatureStore has a method to add features from a + * SimpleFeatureCollection object, so we use the ListFeatureCollection + * class to wrap our list of features. + */ + SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, features); + featureStore.setTransaction(transaction); + try { + featureStore.addFeatures(collection); + transaction.commit(); + } catch (Exception problem) { + problem.printStackTrace(); + transaction.rollback(); + } finally { + transaction.close(); } + } } public static void createAttributeShapeFile(String outputFile, List attributes) throws Exception {