Package org.geoserver.importer

Examples of org.geoserver.importer.Importer


    @Test
    public void testImportFile() throws Exception {
        Catalog catalog = getCatalog();
        assertNull(catalog.getLayerByName("gs:point"));

        Importer importer =
            GeoServerExtensions.bean(Importer.class, applicationContext);
        ImportController ctrl = new ImportController(getGeoServer(), importer);

        MockHttpServletRequest request = new MockHttpServletRequest();
        request.setContextPath("/geoserver");
View Full Code Here


                }

                cancel.setDefaultModelObject(jobid);
                this.add(new AbstractAjaxTimerBehavior(Duration.seconds(3)) {
                   protected void onTimer(AjaxRequestTarget target) {
                       Importer importer = ImporterWebUtils.importer();
                       Task<ImportContext> t = importer.getTask(jobid);

                       if (t.isDone()) {
                           try {
                               if (t.getError() != null) {
                                   error(t.getError());
                               }
                               else if (t.isCancelled()) {
                                   //do nothing
                               }
                               else {
                                   ImportContext imp = t.get();
                                  
                                   //check the import for actual things to do
                                   boolean proceed = !imp.getTasks().isEmpty();
                                 
                                   if (proceed) {
                                       imp.setArchive(false);
                                       importer.changed(imp);
          
                                       PageParameters pp = new PageParameters();
                                       pp.put("id", imp.getId());
          
                                       setResponsePage(ImportPage.class, pp);
                                   }
                                   else {
                                       info("No data to import was found");
                                       importer.delete(imp);
                                   }
                               }
                           }
                           catch(Exception e) {
                               error(e);
                               LOGGER.log(Level.WARNING, "", e);
                           }
                           finally {
                               stop();
                              
                               //update the button back to original state
                               resetButtons(form, target);

                               target.addComponent(feedbackPanel);
                           }
                           return;
                       }

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

                       statusLabel.setDefaultModelObject(msg);
                       target.addComponent(statusLabel);
                   };
                });
            }
        });
       
        form.add(new AjaxLink<Long>("cancel", new Model<Long>()) {
            protected void disableLink(ComponentTag tag) {
                super.disableLink(tag);
                ImporterWebUtils.disableLink(tag);
            };
            @Override
            public void onClick(AjaxRequestTarget target) {
                Importer importer = ImporterWebUtils.importer();
                Long jobid = getModelObject();
                Task<ImportContext> task = importer.getTask(jobid);
                if (task != null && !task.isDone() && !task.isCancelled()) {
                    task.getMonitor().setCanceled(true);
                    task.cancel(false);
                    try {
                        task.get();
                    }
                    catch(Exception e) {
                    }
                }

                setEnabled(false);
               
                Component next = getParent().get("next");
                next.setEnabled(true);
               
                target.addComponent(this);
                target.addComponent(next);
            }
        }.setOutputMarkupId(true).setEnabled(false));

        importTable = new ImportContextTable("imports", new ImportContextProvider(true) {
            @Override
            protected List<org.geoserver.web.wicket.GeoServerDataProvider.Property<ImportContext>> getProperties() {
                return Arrays.asList(ID, STATE, UPDATED);
            }
        }, true) {
            protected void onSelectionUpdate(AjaxRequestTarget target) {
                removeImportLink.setEnabled(!getSelection().isEmpty());
                target.addComponent(removeImportLink);
            };
        };
        importTable.setOutputMarkupId(true);
        importTable.setFilterable(false);
        importTable.setSortable(false);
        form.add(importTable);

        form.add(removeImportLink = new AjaxLink("remove") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                Importer importer = ImporterWebUtils.importer();
                for (ImportContext c : importTable.getSelection()) {
                    try {
                        importer.delete(c);
                    } catch (IOException e) {
                        LOGGER.log(Level.WARNING, "Error deleting context", c);
                    }
                }
                importTable.clearSelection();
View Full Code Here

        }

        StoreInfo targetStore = (StoreInfo) (store.getObject() != null ? store
                .getObject() : null);

        Importer importer = ImporterWebUtils.importer();
        return importer.createContextAsync(source, targetWorkspace, targetStore);

    }
View Full Code Here

    }
   
    // in order to test this, run once, then change the serialVersionUID of ImportContext2
    @Test
    public void testSerialVersionUIDChange() throws Exception {
        Importer imp =  new Importer(null) {

            @Override
            public File getImportRoot() {
                File root = new File("target");
                root.mkdirs();
View Full Code Here

public abstract class TransformTestSupport extends TestCase {

    public void doJSONTest(ImportTransform transform) throws Exception {
        StringWriter buffer = new StringWriter();

        Importer im = createNiceMock(Importer.class);
        PageInfo pi = createNiceMock(PageInfo.class);
       
        replay(im, pi);

        ImportJSONWriter jsonio = new ImportJSONWriter(im, pi, buffer);
View Full Code Here

TOP

Related Classes of org.geoserver.importer.Importer

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.