}
//start writing features
// @todo ability to collect transformation errors for use in a dry-run (auto-rollback)
ProgressMonitor monitor = task.progress();
// @todo need better way to communicate to client
int skipped = 0;
int cnt = 0;
// metrics
long startTime = System.currentTimeMillis();
task.clearMessages();
task.setTotalToProcess(format.getFeatureCount(task.getData(), task));
LOGGER.info("begining import");
try {
writer = dataStore.getFeatureWriterAppend(uniquifiedFeatureTypeName, transaction);
while(reader.hasNext()) {
if (monitor.isCanceled()){
break;
}
SimpleFeature feature = (SimpleFeature) reader.next();
SimpleFeature next = (SimpleFeature) writer.next();
//(JD) TODO: some formats will rearrange the geometry type (like shapefile) which
// makes the goemetry the first attribute reagardless, so blindly copying over
// attributes won't work unless the source type also has the geometry as the
// first attribute in the schema
featureDataConverter.convert(feature, next);
// @hack #45678 - mask empty geometry or postgis will complain
Geometry geom = (Geometry) next.getDefaultGeometry();
if (geom != null && geom.isEmpty()) {
next.setDefaultGeometry(null);
}
//apply the feature transform
next = tx.inline(task, dataStore, feature, next);
if (next == null) {
skipped++;
} else {
writer.write();
}
task.setNumberProcessed(++cnt);
}
transaction.commit();
if (skipped > 0) {
task.addMessage(Level.WARNING,skipped + " features were skipped.");
}
LOGGER.info("load to target took " + (System.currentTimeMillis() - startTime));
}
catch (Exception e) {
error = e;
}
// no finally block, there is too much to do
if (error != null || monitor.isCanceled()) {
// all sub exceptions in this catch block should be logged, not thrown
// as the triggering exception will be thrown
//failure, rollback transaction
try {