Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IService


     */
    public IService acquire( Map<String, Serializable> connectionParameters,
            IProgressMonitor monitor ) throws IOException {
       
        List<IService> possible = new ArrayList<IService>();
        IService createdService = null;
       
        if (monitor == null) monitor = new NullProgressMonitor();

        monitor.beginTask("acquire", 100);
        monitor.subTask("acquire services");

        try {

            possible = constructServices(connectionParameters, monitor);

            if (possible.isEmpty()) {
                throw new IOException("Unable to connect to any service ");
            }

            createdService = possible.get(0);

            try {
                add(createdService);// TODO don't clean this one up!
                return createdService;
            } catch (Throwable t) {
                // usually indicates an IOException as the service is unable to connect
                CatalogPlugin.trace("trouble connecting to " + createdService.getID(), t);
            }

        } finally {
            List<IService> members = checkMembers(possible);
           
            for( Iterator<IService> iterator = members.iterator(); iterator.hasNext(); ) {
                IService service = iterator.next();

                if (service.equals(createdService))
                    continue;

                service.dispose(new SubProgressMonitor(monitor, 10));
            }
           
            monitor.done();
        }
        return null;
View Full Code Here


        if (id == null)
            return null;

        if (IService.class.isAssignableFrom(type)) {
            monitor2.beginTask(Messages.CatalogImpl_monitorTask, 1);
            IService service = getServiceById(id);
            monitor2.done();
            return type.cast(service);
        }

        URL url = id.toURL();
        if (IResolve.class.isAssignableFrom(type)) {
            for( IService service : services ) {
                if (URLUtils.urlEquals(url, service.getIdentifier(), true)) {
                    IResolve child = getChildById(service, id, false, monitor2);
                    if (child != null)
                        return type.cast(child);
                }
            }
View Full Code Here

        List<IService> catalogServices = new ArrayList<IService>();

        for( IService service : constructServiceList ) {

            ID id = service.getID();
            IService found = getById(IService.class, id, new NullProgressMonitor());

            if (!(found == null)) {
                catalogServices.add(service);
            }
View Full Code Here

        List<IService> catalogServices = new ArrayList<IService>();

        for( IService service : constructServiceList ) {

            ID id = service.getID();
            IService found = getById(IService.class, id, new NullProgressMonitor());

            if (found == null) {
                catalogServices.add(service);
            }
        }
View Full Code Here

            IProgressMonitor monitor3 = new SubProgressMonitor(monitor, 60);
            monitor3.beginTask("connect", possible.size() * 10);

            for( Iterator<IService> iterator = possible.iterator(); iterator.hasNext(); ) {
                IService service = iterator.next();

                if (service == null) continue;

                monitor3.subTask("connect " + service.getID());
                try {
                    // try connecting
                    IServiceInfo info = service.getInfo(new SubProgressMonitor(monitor3, 10));

                    if (info == null) {
                        CatalogPlugin.trace("unable to connect to " + service.getID(), null);
                        continue; // skip unable to connect
                    }

                    availableServices.add(service);
                } catch (Throwable t) {
                    // usually indicates an IOException as the service is unable to connect
                    CatalogPlugin.trace("trouble connecting to " + service.getID(), t);
                }
            }
            monitor3.done();
        } finally {
            monitor.done();
View Full Code Here

    }

    @Before
    public void setUp() throws Exception {
        instance = new CatalogImpl();
        instance.add(new IService(){

            public <T> T resolve( Class<T> adaptee, IProgressMonitor monitor ) throws IOException {
                return null;
            }

            public List< ? extends IGeoResource> resources( IProgressMonitor monitor )
                    throws IOException {
                return null;
            }

            public Map<String, Serializable> getConnectionParams() {
                return null;
            }

            public <T> boolean canResolve( Class<T> adaptee ) {
                return false;
            }

            public Status getStatus() {
                return null;
            }

            public Throwable getMessage() {
                return null;
            }

            public URL getIdentifier() {
                try {
                    return new URL("http://localhost:1234/testing/1"); //$NON-NLS-1$
                } catch (MalformedURLException e) {
                    return null;
                }
            }
            protected IServiceInfo createInfo( IProgressMonitor monitor ) throws IOException {
                try {
                    return new IServiceInfo("Testing 1", "", "", getIdentifier().toURI(), (URI) null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                            (URI) null, (new String[]{"Test"}), (ImageDescriptor) null); //$NON-NLS-1$
                } catch (URISyntaxException e) {
                    throw (RuntimeException) new RuntimeException( ).initCause( e );
                }                
            }
        });
        instance.add(new IService(){

            public <T> T resolve( Class<T> adaptee, IProgressMonitor monitor ) throws IOException {
                return null;
            }
View Full Code Here

        }
        return false;
  }
  private File toShpFile( IResolve resolve ) {
      IGeoResource resource = (IGeoResource) resolve;
        IService service;
        try {
            service = resource.service(new NullProgressMonitor());
        if (service.canResolve(ShapefileDataStore.class)) {
            return service.resolve(File.class, new NullProgressMonitor());
        }
        } catch (IOException e) {
            RasteringsPlugin.log("Error obtaining shapefile file", e); //$NON-NLS-1$
            return null;
        }
View Full Code Here

       
        List members = catalog.members(new DummyMonitor());
        if (!members.isEmpty()) {
            //clear the catalog
            for (Iterator itr = members.iterator(); itr.hasNext();) {
                IService service = (IService)itr.next();
                catalog.remove(service);
            }
        }
        members = catalog.members(new DummyMonitor());
        assertTrue(members.isEmpty());
View Full Code Here

       
        List members = catalog.members(new DummyMonitor());
        if (!members.isEmpty()) {
            //clear the catalog
            for (Iterator itr = members.iterator(); itr.hasNext();) {
                IService service = (IService)itr.next();
                catalog.remove(service);
            }
        }
        members = catalog.members(new DummyMonitor());
        assertTrue(members.isEmpty());
       

        final WorkflowWizard workflowWizard = mapImport.getDialog().getWorkflowWizard();
    workflowWizard.getWorkflow()
            .setContext(context);
        mapImport.run(new DummyMonitor(),context);
       
        UDIGTestUtil.inDisplayThreadWait(3000, new WaitCondition(){

      public boolean isTrue()  {
        State state = workflowWizard.getWorkflow().getCurrentState();
        if ( state instanceof ResourceSelectionState )
          return true;
        return false;
      }
         
        }, true);
        assertTrue(workflowWizard.getWorkflow().getCurrentState() instanceof ResourceSelectionState);
       
        //check the resource page to ensure that it isn't ignored
        ResourceSelectionState currentState = (ResourceSelectionState) workflowWizard.getWorkflow().getCurrentState();

        assertTrue(currentState.getResources()==null || currentState.getResources().isEmpty());
       
        //Set the resources on the state and press finish
        IService service=currentState.getServices().iterator().next();
        Map<IGeoResource, IService> resources=new HashMap<IGeoResource, IService>();
       
        for (IResolve resolve : service.resources(new NullProgressMonitor())) {
      resources.put((IGeoResource) resolve, service);
    }
       
       
        currentState.setResources(resources);
View Full Code Here

                      store.getSchema().getTypeName())) {
                    ShpServiceExtension fac = new ShpServiceExtension();
                    Map<String, Serializable> params = fac
                        .createParams(resolve
                            .getIdentifier());
                    IService replacement = fac
                        .createService(resolve
                            .getIdentifier(),
                            params);
                    catalog.replace(
                        resolve.getID(),
View Full Code Here

TOP

Related Classes of org.locationtech.udig.catalog.IService

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.