Package org.geoserver.importer.job

Examples of org.geoserver.importer.job.ProgressMonitor


    /**
     * Runs any initial checks against the data preparing for import.
     */
    public final void prepare() throws IOException {
        prepare(new ProgressMonitor());
    }
View Full Code Here


                               target.addComponent(feedbackPanel);
                           }
                           return;
                       }

                       ProgressMonitor m = t.getMonitor();
                       String msg = m.getTask() != null ? m.getTask().toString() : "Working";

                       statusLabel.setDefaultModelObject(msg);
                       target.addComponent(statusLabel);
                   };
                });
View Full Code Here

            }
           
            //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 {
View Full Code Here

        }
    }

    public ProgressMonitor progress() {
        if (progress == null) {
            progress = new ProgressMonitor();
        }
        return progress;
    }
View Full Code Here

TOP

Related Classes of org.geoserver.importer.job.ProgressMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.