Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.ICatalog


        if( !services.isEmpty() ){
            return true;
        }
       
        ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
        List<IService> availableServices;
       
        monitor.beginTask(Messages.ConnectionState_task, IProgressMonitor.UNKNOWN);
       
        errors = null;
        try {
                // use the context object to try to build connection info
            Object context = getWorkflow().getContext();
   
            if( context instanceof IService ){
                services.add((IService)context);
                //services = Collections.singleton((IService)context);
            }else if (context instanceof IGeoResource){
                IService service = ((IGeoResource) context).service(monitor);
                services.add((IService)context);
                services.add(service);
            }else{
           
                Map<String, Serializable> params = factory.createConnectionParameters(context);
               
                URL url = factory.createConnectionURL(context)
       
                if (params == null && url == null)
                    return false; // could not build connection info
               
                if(url != null){
                    availableServices = catalog.constructServices(url, monitor);
                    if(!availableServices.isEmpty()){
                        services.add(availableServices.iterator().next());
                        return true;
                    }
                }
               
                if(params != null && !params.isEmpty()){
                    availableServices = catalog.constructServices(params, monitor);
                    if(!availableServices.isEmpty()){
                        services.add(availableServices.iterator().next());
                    }
                }
            }
View Full Code Here


        }       
        return services;
    }

    private static Collection<IService> searchLocalCatalog( URL url, IProgressMonitor monitor ) {
        ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
       
        List<IResolve> resolves = localCatalog.find(url, monitor);
        ArrayList<IService> services = new ArrayList<IService>();
        for( IResolve iResolve : resolves ) {
            if (iResolve instanceof IService) {
                IService service = (IService) iResolve;
                services.add(service);
View Full Code Here

    public static synchronized void addServiceToCatalog( String serviceFile, IProgressMonitor progressMonitor ) {
        try {
            URL fileUrl = new File(serviceFile).toURI().toURL();
            // add the service to the catalog and map
            IServiceFactory sFactory = CatalogPlugin.getDefault().getServiceFactory();
            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
            List<IService> services = sFactory.createService(fileUrl);
            for( IService service : services ) {
                catalog.add(service);
            }
        } catch (Exception e) {
            JGrassPlugin.log(
                    "JGrassPlugin problem: eu.hydrologis.udig.catalog.utils#JGrassCatalogUtilities#addServiceToCatalog", e); //$NON-NLS-1$
            e.printStackTrace();
View Full Code Here

                return;
            }
            /*
             * test code to make the catalog understand that the map should be added
             */
            final ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
            final JGrassService originalJGrassService = catalog.getById(JGrassService.class, id, monitor);

            /*
             * create the same service
             */
            if (originalJGrassService == null)
                return;
            final URL ID = originalJGrassService.getIdentifier();
            Map<String, Serializable> connectionParams = originalJGrassService.getConnectionParams();
            IServiceFactory locator = CatalogPlugin.getDefault().getServiceFactory();
            final List<IService> rereadService = locator.acquire(ID, connectionParams);

            /*
             * replace the service
             */
            if (rereadService.size() > 0) {
                Runnable refreshCatalogRunner = new Runnable(){
                    public void run() {
                        final IService newJGrassService = rereadService.get(0);
                        catalog.remove(originalJGrassService);
                        catalog.add(newJGrassService);
                    }
                };

                new Thread(refreshCatalogRunner).start();
            }
View Full Code Here

     * @param map the map to which to add the resource to
     */
    public static void addResourceFromUrlToMap( URL url, IProgressMonitor progressMonitor, int addPosition, IMap map ) {

        synchronized (url) {
            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
            // first search the local catalog.
            List<IResolve> matches = catalog.find(url, new SubProgressMonitor(progressMonitor, 2));

            for( IResolve resolve : matches ) {
                List<IResolve> members = null;
                try {
                    List<IGeoResource> geoResources = new ArrayList<IGeoResource>();
View Full Code Here

            File locationFile = new File(locationPath);

            ID locationId = new ID(locationFile.toURI().toURL());
            URL mapsetUrl = JGrassMapsetGeoResource.createId(locationFile.getAbsolutePath(), mapsetName);
            ID mapsetId = new ID(mapsetUrl);
            ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
            mapset = localCatalog.getById(JGrassMapsetGeoResource.class, mapsetId, ProgressManager.instance().get());
            if (mapset == null) {
                // try with the service
                // URL locationId = JGrassService.createId(locationPath);
                JGrassService locationService = localCatalog.getById(JGrassService.class, locationId, ProgressManager.instance()
                        .get());
                mapset = locationService.getMapsetGeoresourceByName(mapsetName);
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
View Full Code Here

    try {
      target = new URL( protocol, host, port, associate);
    } catch (MalformedURLException e) {
      return Collections.emptyList();     
    }   
    ICatalog local = CatalogPlugin.getDefault().getLocalCatalog();
   
    // look up frendly wfs entry from local catalog (if present)
    IGeoResource friend = local.getById( IGeoResource.class, new ID(target), monitor );
    if( friend == null ) {
      return Collections.emptyList();
    }
    else {
      return new ArrayList<IResolve>( Collections.singletonList( friend ) );
View Full Code Here

        try {
            target = new URL( protocol, host, port, associate);
        } catch (MalformedURLException e) {
            return Collections.emptyList();        
        }      
        ICatalog local = CatalogPlugin.getDefault().getLocalCatalog();
       
        // look up frendly wfs entry from local catalog (if present)
        IGeoResource friend = local.getById( IGeoResource.class, new ID(target), monitor );
        if( friend == null ) {
            return Collections.emptyList();
        }
        else {
            return new ArrayList<IResolve>( Collections.singletonList( friend ) );
View Full Code Here

    @Test
  public void testNormal() throws Exception{
      Object context = getContext();

      final ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();

      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());

      catalogImport.getDialog().getWorkflowWizard().getWorkflow()
        .setContext(context);
      catalogImport.run(new DummyMonitor(),context);

            //sleep for 10 seconds, if dialog still active by then kill it
            UDIGTestUtil.inDisplayThreadWait(2000000, new WaitCondition(){

                public boolean isTrue() {
                    try {
                        return !catalog.members(new DummyMonitor()).isEmpty();
                    } catch (IOException e) {
                        return false;
                    }
                }

            }, true);

      members = catalog.members(new DummyMonitor());
      assertTrue(!members.isEmpty());
      for (Iterator itr = members.iterator(); itr.hasNext();) {
        assertServiceType((IService)itr.next());
      }
  }
View Full Code Here

TOP

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

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.