Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IService


        Job addToCatalog = new Job("Add "+file.getName() ){
            @Override
            protected IStatus run(IProgressMonitor monitor) {
                ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
                URL url = new ID( file, null ).toURL();
                IService service = null;
                try {
                    service = localCatalog.acquire( url, monitor );
                }
                catch( IOException unepected ){
                }
View Full Code Here


     * @param localCatalog
     * @param service
     */
    private void addToCatalog( ICatalog localCatalog, IService service ) {
        ID id = service.getID();
        IService found = localCatalog.getById(IService.class, id, new NullProgressMonitor());
        if (found != null) {
            // existing catalog entry to replace
            // (if this is only being done for a "refresh" we may be able to take less
            // drastic action)
            localCatalog.replace(service.getID(), service);
View Full Code Here

            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
           
            for( File file : files ) {
                try {
                    URL url = file.toURI().toURL();
                    IService handle = catalog.acquire(url, null);
                    if (handle != null) {
                        // connected okay add all resources
                        List<IGeoResource> resources = (List<IGeoResource>) handle
                                .resources(new NullProgressMonitor());
                        dataHandles.addAll(resources);
                    }
                } catch (IOException eek) {
                    String message = "Could not add " + file;
View Full Code Here

            Boolean isCaching = resource.resolve( Boolean.class, m);
            if( isCaching != null ){
                return isCaching;
            }
        }
        IService service = resource.service(null);
        if( service == null ){
            return null; // cannot determine sevice at this time!
        }
        ID serviceID = service.getID();       
//        if( serviceID.isWFS() ){
//            return true; // we want to cache for WFS
//        }
        if( serviceID.isFile() ){
            String ext = serviceID.toExtension();
View Full Code Here

        prop.addListener(l);
       
        URL id = layer.getID();
        ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
        IGeoResource resource = localCatalog.getById(IGeoResource.class, new ID(id), new NullProgressMonitor());
        IService parent = resource.service(new NullProgressMonitor());
        localCatalog.replace(parent.getID(), parent);
       
        assertEquals(0, changed[0]);
       
        assertTrue(prop.isTrue(layer, "Polygon")); //$NON-NLS-1$
        assertTrue(prop.isTrue(layer, "Polygon")); //$NON-NLS-1$
        assertTrue(prop.isTrue(layer, "Polygon")); //$NON-NLS-1$
        assertTrue(prop.isTrue(layer, "Polygon")); //$NON-NLS-1$

        localCatalog.replace(parent.getID(), parent);
       
        assertEquals(1, changed[0]);
       
        parent=CatalogTests.createResource(null, "ResolveTo").service(new NullProgressMonitor()); //$NON-NLS-1$

        localCatalog.replace(parent.getID(), parent);
        changed[0]=0;
        assertEquals(0, changed[0]);
    }
View Full Code Here

        if( search != null ){
            for( IResolve resolve : search.getSelected() ){
                if( resolve instanceof IGeoResource ){
                    try {
                        IGeoResource geoResource = (IGeoResource) resolve;
                        IService service = geoResource.service( new NullProgressMonitor() );
                        list.add( service );
                    }
                    catch( IOException t){
                        CatalogUIPlugin.log("Unable to connect to service "+ t, t);
                    }
                }
                if( resolve instanceof IService ){
                    IService service =(IService) resolve;
                    list.add( service );
                }
            }
        }
        EndConnectionState state = getWorkflow().getState(EndConnectionState.class);
View Full Code Here

        ResourceSearchState search = getWorkflow().getState( ResourceSearchState.class );
        if( search != null ){
            for( IResolve resolve : search.getSelected() ){
                if( resolve instanceof IGeoResource ){
                    IGeoResource geoResource = (IGeoResource) resolve;
                    IService service = geoResource.service( new NullProgressMonitor() );
                    resources.put( geoResource, service );
                }
            }
        }
       
        Collection<IService> services = getServices();
       
        List<IService> toRemove=new ArrayList<IService>();
        if( services != null ){
            for( IService service : services ) {
                List< ? extends IGeoResource> members = service.resources(monitor);
                if (members != null && members.size() < 1){
                    toRemove.add(service);
                    continue;
                }
                addPreferredResources(service, members);
View Full Code Here

                showInfo(new Info(catalog.getIdentifier(), info));
            } catch (IOException e) {
                CatalogUIPlugin.log("No information for catalog", e); //$NON-NLS-1$
            }
        } else if (record instanceof IService) {
            IService service = (IService) record;
            IServiceInfo info;
            try {
                info = service.getInfo(searchMonitor);
                showInfo(new Info(service.getIdentifier(), info));
            } catch (IOException e) {
                CatalogUIPlugin.log("No information for service", e); //$NON-NLS-1$
            }

        } else if (record instanceof IGeoResource) {
View Full Code Here

    private boolean testing;
    private boolean error = false;

    public void op( final Display display, final Object target, final IProgressMonitor monitor )
            throws Exception {
        final IService service = (IService) target;
        final DataStore ds = service.resolve(DataStore.class, monitor);
        if (!(ds instanceof ShapefileDataStore)) {
            try {
                ds.createSchema(null);
            } catch (UnsupportedOperationException e) {
                if (testing) {
                    error = true;
                    return;
                } else {
                    display.asyncExec(new Runnable(){
                        public void run() {
                            MessageDialog
                                    .openInformation(display.getActiveShell(),
                                            Messages.NewFeatureTypeOp_title,
                                            Messages.NewFeatureTypeOp_message);
                        }
                    });
                    return;
                }
            } catch (Exception e) {
                // try it
            }
        }

        final SimpleFeatureType[] featureType = new SimpleFeatureType[1];
        if (!testing) {
           
            final FeatureTypeEditorDialog[] dialog=new FeatureTypeEditorDialog[1];
            PlatformGIS.syncInDisplayThread(new Runnable(){
                public void run() {
                    dialog[0] = new FeatureTypeEditorDialog(display
                            .getActiveShell(), new ValidateFeatureType(){

                                public String validate( SimpleFeatureType featureBuilder ) {
                                    return null;
                                }
                       
                    });
                }
            });
            int code=-1;
            do {
                code=openDialog(display, dialog[0], ds);
                if( code==Window.CANCEL){
                    featureType[0]=null;
                }else
                    featureType[0]=dialog[0].getFeatureType(true);
            } while( featureType[0] == null && code==Window.OK);
        } else {
            featureType[0] = DataUtilities.createType("TestName", "Geom:MultiLineString"); //$NON-NLS-1$ //$NON-NLS-2$
        }
        if (featureType[0] == null)
            return;

        try {

            if (ds instanceof ShapefileDataStore) {
                createShapefile(display, monitor, featureType[0], service.getIdentifier());
            } else {
                ds.createSchema(featureType[0]);
                long start=System.currentTimeMillis();
                while( !Arrays.asList(ds.getTypeNames()).contains(featureType[0].getName().getLocalPart() ) && start+5000>System.currentTimeMillis()){
                    Thread.sleep(300);
View Full Code Here

        }
    }

    private void tryAdaptingToService( Object object, Collection<Data> data ) throws IOException {
        if (object instanceof IService) {
            IService service = (IService) object;
            List< ? extends IGeoResource> resources = service.resources(ProgressManager.instance().get());
            for( IGeoResource resource : resources ) {
                data.add(new Data(resource));
            }
        }
       
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.