Package org.locationtech.udig.catalog

Examples of org.locationtech.udig.catalog.IService


        return ID;
    }

    @Override
    public Collection<IService> getServices() {
        IService service = CatalogPlugin.getDefault().getLocalCatalog().getById(IService.class, MapGraphicService.SERVICE_ID, new NullProgressMonitor());
        return Collections.singleton(service);
    }
View Full Code Here


  public Map<String, Serializable> createConnectionParameters(Object data) {
    if( data==null )
            return null;
        if( data instanceof WFSServiceImpl ){
            IService wfs = (IService) data;
            return wfs.getConnectionParams();
        }
        URL url = toCapabilitiesURL( data );
        if( url != null ) {
            // well we have a url - lets try it!           
            List<IResolve> list = CatalogPlugin.getDefault().getLocalCatalog().find( url, null );
            for( IResolve resolve : list ){
                if( resolve instanceof WFSServiceImpl) {
                    // got a hit!
                    IService wfs = (IService) resolve;
                    return wfs.getConnectionParams();
                }
                else if (resolve instanceof WFSGeoResourceImpl ){
                    WFSGeoResourceImpl layer = (WFSGeoResourceImpl) resolve;
                    IService wfs;
                    try {
                        wfs = (IService) layer.parent( null );
                        return wfs.getConnectionParams();
                    } catch (IOException e) {
                        checkedURL( layer.getIdentifier() );
                    }                   
                }
            }
View Full Code Here

            org.locationtech.udig.catalog.TemporaryResourceFactory {

    public IGeoResource createResource( Object param ) throws IOException {
        SimpleFeatureType featureType = (SimpleFeatureType) param;

        IService service = getMemoryService();

        MemoryDataStore ds = service.resolve(MemoryDataStore.class, new NullProgressMonitor());
        List<String> typeNamesList = Arrays.asList(ds.getTypeNames());
        String localPart = featureType.getName().getLocalPart();
        if (typeNamesList.contains(localPart)) {
            try {
                ds.updateSchema(localPart, featureType);
            } catch (Exception e) {
                // some datastores do not support schema update, try a name change
                // create the feature type
                String name = checkSameName(typeNamesList, localPart);
                SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
                b.setName(name);
                b.setCRS(featureType.getCoordinateReferenceSystem());
                List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors();
                b.addAll(attributeDescriptors);
                featureType = b.buildFeatureType();
                ds.createSchema(featureType);
            }
        } else {
            ds.createSchema(featureType);
        }

        IGeoResource resource = null;
        for( IResolve resolve : service.resources(new NullProgressMonitor()) ) {
            if (resolve instanceof IGeoResource) {
                IGeoResource r = (IGeoResource) resolve;
                if (r.resolve(SimpleFeatureType.class, new NullProgressMonitor()).getName().getLocalPart()
                        .equals(featureType.getName().getLocalPart())) {
                    resource = r;
View Full Code Here

                IGeoResourceInfo.class));
    }

    @Test
    public void testResolve() throws IOException {
        IService children = getResolve().resolve(IService.class, null);
        assertTrue("May not have null parent", children != null); //$NON-NLS-1$
        IGeoResourceInfo info = getResolve().resolve(IGeoResourceInfo.class, null);
        if (!isLeaf())
            assertTrue("May not have null info", info != null); //$NON-NLS-1$
    }
View Full Code Here

    }

    @Test
    public void testResolveMonitor() throws IOException {
        FakeProgress monitor = new FakeProgress();
        IService children = getResolve().resolve(IService.class, monitor);
        assertTrue("May not have null parent", children != null); //$NON-NLS-1$

        monitor = new FakeProgress();
        IGeoResourceInfo info = getResolve().resolve(IGeoResourceInfo.class, monitor);
        if (!isLeaf())
View Full Code Here

    /**
     * Calls createService and finds the georesource containing the features.
     */
    public static IGeoResource createGeoResource(SimpleFeature [] features, boolean deleteService) throws IOException{
      IService service = getService(features, deleteService);
     
      List<? extends IGeoResource> resources = service.resources(null);
      for (IGeoResource resource : resources) {
        if( resource.resolve(FeatureSource.class, null).getSchema().getName().getLocalPart().
            equals(features[0].getFeatureType().getTypeName()))
          return resource;
      }
View Full Code Here

     *
     * @param catalog
     * @return
     */
    public static IService createService(ICatalog catalog) {
      IService service;
      MemoryServiceExtensionImpl ext=new MemoryServiceExtensionImpl();
     
      java.util.Map<String, Serializable> params = ext.createParams(MemoryServiceExtensionImpl.URL);
      service=(MemoryServiceImpl) ext.createService(MemoryServiceExtensionImpl.URL, params);
      catalog.add(service);
View Full Code Here

       * @param deleteService
       */
      public static IService getService(SimpleFeature[] features, boolean deleteService) throws IOException {
        ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
        List<IResolve> services = catalog.find(MemoryServiceExtensionImpl.URL, new NullProgressMonitor());
        IService service=null;
        if( services.isEmpty() ){
          service = createService(catalog);
        }else{
          IResolve resolve=services.get(0);
          if (resolve instanceof IGeoResource) {
            IGeoResource resource = (IGeoResource) resolve;
            service=resource.service(null);
          }else if (resolve instanceof IService) {
            service=(IService) services.get(0);       
          }
        }
        if( deleteService ){
                if( service.resolve(MemoryDataStore.class, null) instanceof ActiveMemoryDataStore ){
                  ActiveMemoryDataStore ds=(ActiveMemoryDataStore) service.resolve(MemoryDataStore.class, null);
                    ds.removeSchema(features[0].getFeatureType().getTypeName());
                } else {
                    List< ? extends IGeoResource> members = service.resources(new NullProgressMonitor());
                    for( IGeoResource resource : members ) {
                        FeatureStore<SimpleFeatureType, SimpleFeature> s = resource
                                .resolve(FeatureStore.class, new NullProgressMonitor());
                        if (s.getSchema().getTypeName().equals(
                                features[0].getName().getLocalPart()))
                            s.removeFeatures(Filter.INCLUDE);
                    }
                }
        }
       
        MemoryDataStore ds=service.resolve(MemoryDataStore.class, null);
        try{
          ds.getSchema(features[0].getFeatureType().getTypeName());
    //      if( deleteService)
    //        throw new IOException("SimpleFeatureType already exists in Service"); //$NON-NLS-1$
        }catch( SchemaNotFoundException exception){
View Full Code Here

     * @param resolveTo the object the resource will resolve to
     * @return an {@link IGeoResource}
     * @throws IOException
     */
    public static IGeoResource createResource( URL id, Object resolveTo ) throws IOException {
        IService service=DummyService.createService(id, null, Collections.singletonList(Collections.singletonList(resolveTo)));
       
        IGeoResource resource = service.resources(null).get(0);
        return resource;
    }
View Full Code Here

       
        if(service == null){
          List<IService> services = CatalogPlugin.getDefault().getServiceFactory().createService(url);
          Iterator<IService> srv = services.iterator();
          while(srv.hasNext()){
            IService s = srv.next();
            if(s.canResolve(WebMapServer.class)){
              service = s;
            }
          }

            if(service == null){
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.