Revision 43205

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/impl/DefaultDataManager.java
1 1
package org.gvsig.fmap.dal.impl;
2 2

  
3
import org.gvsig.fmap.dal.feature.spi.ExpressionEvaluatorBase;
4 3
import java.io.File;
5 4
import java.io.InputStream;
6 5
import java.net.URL;
......
9 8
import java.util.HashMap;
10 9
import java.util.List;
11 10
import java.util.Map;
11

  
12 12
import org.gvsig.fmap.dal.DataFactory;
13 13
import org.gvsig.fmap.dal.DataManager;
14
import static org.gvsig.fmap.dal.DataManager.READ_STORE_AUTHORIZATION;
15 14
import org.gvsig.fmap.dal.DataServerExplorer;
16 15
import org.gvsig.fmap.dal.DataServerExplorerFactory;
17 16
import org.gvsig.fmap.dal.DataServerExplorerParameters;
......
28 27
import org.gvsig.fmap.dal.Register;
29 28
import org.gvsig.fmap.dal.exception.DataException;
30 29
import org.gvsig.fmap.dal.exception.InitializeException;
30
import org.gvsig.fmap.dal.exception.OpenException;
31 31
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
32
import org.gvsig.fmap.dal.exception.CreateFileStoreException;
32 33
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
33 34
import org.gvsig.fmap.dal.feature.EditableFeatureType;
34 35
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
......
41 42
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
42 43
import org.gvsig.fmap.dal.feature.paging.impl.FeaturePagingHelperImpl;
43 44
import org.gvsig.fmap.dal.feature.spi.ExpressionBuilderBase;
45
import org.gvsig.fmap.dal.feature.spi.ExpressionEvaluatorBase;
44 46
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider;
45 47
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices;
46 48
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProvider;
47 49
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProviderFactory;
48 50
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider;
49 51
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices;
52
import org.gvsig.fmap.dal.raster.NewRasterStoreParameters;
53
import org.gvsig.fmap.dal.raster.impl.RasterStoreFactory;
50 54
import org.gvsig.fmap.dal.raster.impl.RasterStoreOldFactory;
51
import org.gvsig.fmap.dal.raster.impl.RasterStoreFactory;
52 55
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider;
56
import org.gvsig.fmap.dal.spi.DALSPILocator;
53 57
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
54 58
import org.gvsig.fmap.dal.spi.DataStoreProvider;
55 59
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
......
71 75

  
72 76
public class DefaultDataManager
73 77
        implements DataManager, DataManagerProviderServices, Services {
74
    
78

  
75 79
    final static private String DATA_MANAGER_CACHE = "Data.manager.caches";
76 80
    final static private String DATA_MANAGER_CACHE_DESCRIPTION =
77 81
        "DAL cache providers";
78
    
82

  
83
    public static final String FILESYSTEM_EXPLORER_NAME = "FilesystemExplorer";
84

  
85

  
79 86
    private class Registers {
80 87

  
81 88
        private final Register store;
......
305 312
        );
306 313
        return explorer;
307 314
    }
308
    
315

  
309 316
    @Override
310 317
    public DataServerExplorer openServerExplorer(String explorerName, Object... arguments) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException {
311 318
        if( (arguments.length % 2)!= 0 ) {
......
319 326
            parameters.setDynValue(name, value);
320 327
        }
321 328
        return this.openServerExplorer(explorerName, parameters);
322
        
329

  
323 330
    }
324
    
331

  
325 332
    /**
326 333
     * @param parameters
327 334
     * @return
......
343 350
     * @return
344 351
     * @throws InitializeException
345 352
     * @throws ProviderNotRegisteredException
346
     * @throws ValidateDataParametersException 
353
     * @throws ValidateDataParametersException
347 354
     */
348 355
    @Override
349 356
    public DataStore createStore(DataStoreParameters parameters)
......
351 358
        ValidateDataParametersException {
352 359
        return openStore(parameters.getDataStoreName(), parameters);
353 360
    }
354
    
361

  
355 362
    @Override
356 363
    public DataStore openStore(String providerName, DataStoreParameters parameters) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException {
357 364

  
......
361 368
        }
362 369

  
363 370
        parameters.validate();
364
        
371

  
365 372
        String storeName = this.getStoreName(parameters);
366 373

  
367 374
        DataStoreFactory_v2_4 storeFactory = (DataStoreFactory_v2_4) this.getStoreRegister().getFactory(storeName);
......
395 402
        }
396 403
        return this.openStore(providerName, parameters);
397 404
    }
398
    
405

  
399 406
    @Override
400 407
    public FeatureStore createMemoryStore(String autoOrderAttributeName) throws InitializeException {
401 408
        try {
......
608 615
    public  ExpressionEvaluator createExpresion() {
609 616
        return new ExpressionEvaluatorBase();
610 617
    }
611
    
618

  
612 619
    @Override
613 620
    public FeaturePagingHelper createFeaturePagingHelper(
614 621
            FeatureStore featureStore, int pageSize) throws BaseException {
......
724 731
        x = reourceLoader.getClass().getResourceAsStream(name);
725 732
        return x;
726 733
    }
727
    
734

  
728 735
    @Override
729 736
    public ExpressionBuilder createExpressionBuilder() {
730 737
        return new ExpressionBuilderBase();
......
801 808
        }
802 809
    }
803 810

  
811
    @Override
812
    public void createFileStore(String providerName, NewRasterStoreParameters params, boolean overwrite) throws DataException {
813
        DataManagerProviderServices dataManager = DALSPILocator.getDataManagerProviderServices();
814
        DataServerExplorerParameters eparams = null;
815
        DataServerExplorer serverExplorer;
816
        try {
817
            serverExplorer = dataManager.openServerExplorer(FILESYSTEM_EXPLORER_NAME, eparams);
818
        } catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) {
819
            throw new OpenException(FILESYSTEM_EXPLORER_NAME, e);
820
        }
804 821

  
822
        try {
823
            serverExplorer.add(providerName, params, overwrite);
824
        } catch (DataException e) {
825
            throw new CreateFileStoreException(e, providerName);
826
        }
827
    }
805 828

  
829

  
806 830
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/exception/CreateFileStoreException.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.dal.exception;
25

  
26
public class CreateFileStoreException extends DataException {
27

  
28
    /**
29
     *
30
     */
31
    private static final long serialVersionUID = -8864100116239927854L;
32
    private final static String MESSAGE_FORMAT = "Can't create file store '%(resource)'.";
33
	private final static String MESSAGE_KEY = "_CreateFileStoreException";
34

  
35
	public CreateFileStoreException(Throwable cause, String resource) {
36
		super(MESSAGE_FORMAT, cause, MESSAGE_KEY, serialVersionUID);
37
		setValue("resource", resource);
38
	}
39

  
40
}
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/main/java/org/gvsig/fmap/dal/DataManager.java
25 25
import java.io.File;
26 26
import java.util.List;
27 27

  
28
import org.gvsig.fmap.dal.exception.DataException;
28 29
import org.gvsig.fmap.dal.exception.InitializeException;
29 30
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
30 31
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
......
34 35
import org.gvsig.fmap.dal.feature.FeatureQuery;
35 36
import org.gvsig.fmap.dal.feature.FeatureStore;
36 37
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper;
38
import org.gvsig.fmap.dal.raster.NewRasterStoreParameters;
37 39
import org.gvsig.fmap.dal.resource.ResourceManager;
38 40
import org.gvsig.tools.dataTypes.DataType;
39 41
import org.gvsig.tools.dynobject.DynObject;
......
146 148
            ValidateDataParametersException;
147 149

  
148 150
    public DataStore openStore(
149
            String providerName, 
150
            Object... arguments) 
151
        throws 
152
            InitializeException, 
153
            ProviderNotRegisteredException, 
154
            ValidateDataParametersException;    
155
    
151
            String providerName,
152
            Object... arguments)
153
        throws
154
            InitializeException,
155
            ProviderNotRegisteredException,
156
            ValidateDataParametersException;
157

  
156 158
    public DataStore openStore(DynStruct struct)
157 159
            throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException;
158 160

  
......
231 233
            DataServerExplorerParameters parameters)
232 234
            throws InitializeException, ProviderNotRegisteredException,
233 235
            ValidateDataParametersException;
234
    
236

  
235 237
    public DataServerExplorer openServerExplorer(
236
            String explorerName, 
238
            String explorerName,
237 239
            Object... arguments)
238
        throws 
239
            InitializeException, 
240
            ProviderNotRegisteredException, 
240
        throws
241
            InitializeException,
242
            ProviderNotRegisteredException,
241 243
            ValidateDataParametersException;
242 244
    /**
243 245
     * @param parameters
244
     * @return 
245
     * @throws org.gvsig.fmap.dal.exception.InitializeException 
246
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException 
247
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException 
246
     * @return
247
     * @throws org.gvsig.fmap.dal.exception.InitializeException
248
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
249
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
248 250
     * @deprecated see openServerExplorer
249 251
     */
250 252
    public DataServerExplorer createServerExplorer(
251 253
            DataServerExplorerParameters parameters)
252 254
            throws InitializeException, ProviderNotRegisteredException,
253 255
            ValidateDataParametersException;
254
    
256

  
255 257
    /**
256 258
     * @param parameters
257
     * @return 
258
     * @throws org.gvsig.fmap.dal.exception.InitializeException 
259
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException 
260
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException 
259
     * @return
260
     * @throws org.gvsig.fmap.dal.exception.InitializeException
261
     * @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
262
     * @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
261 263
     * @deprecated see openStore
262 264
     */
263 265
    public DataStore createStore(DataStoreParameters parameters)
264 266
            throws InitializeException, ProviderNotRegisteredException,
265 267
            ValidateDataParametersException;
266
        
268

  
267 269
    /**
268 270
     * Returns a list of String containing the names of the available
269 271
     * DataServerExplorer providers.
......
296 298
     */
297 299
    public Evaluator createExpresion(String expression)
298 300
            throws InitializeException;
299
    
301

  
300 302
    /**
301 303
     * Creates an instance of Evaluator to evaluate a expression.
302 304
     *
303 305
     * @return instance of ExpressionEvaluator representing the given expression.
304 306
     */
305 307
    public ExpressionEvaluator createExpresion();
306
    
308

  
307 309
    /*
308 310
     * ====================================================================
309 311
     *
......
424 426

  
425 427
    /**
426 428
     * Creates a default ExpressionBuilder.
427
     * 
428
     * This ExpressionBuilder is not dependent on a data source, 
429
     *
430
     * This ExpressionBuilder is not dependent on a data source,
429 431
     * and is not advisable to use it.
430
     * 
432
     *
431 433
     * @return the ExpressionBuilder
432 434
     */
433 435
    public ExpressionBuilder createExpressionBuilder();
434
    
436

  
435 437
    /**
436 438
	 * Returns a list of String containing the names of the available cache providers.
437 439
	 *
438 440
	 * @return
439 441
	 * 		list of strings with the names of the available cache providers
440
	 */    
442
	 */
441 443
    public List getFeatureCacheProviders();
442 444

  
443 445
	/**
444 446
	 * Returns an instance of {@link DataServerExplorerParameters} corresponding
445 447
	 * to the given name used by the cache to create a store to save the
446 448
	 * retrieved data.
447
	 * 
449
	 *
448 450
	 * @param name
449 451
	 *            name of a registered feature cache provider
450
	 * 
452
	 *
451 453
	 * @throws InitializeException
452 454
	 *             if parameter initialization causes an error.
453
	 * 
455
	 *
454 456
	 * @throws ProviderNotRegisteredException
455 457
	 *             if could not find a cache provider by the given name.
456
	 * 
458
	 *
457 459
	 */
458 460
	public DynObject createCacheParameters(String name)
459 461
			throws InitializeException, ProviderNotRegisteredException;
460
    
462

  
463
    /**
464
     * @param providerName
465
     * @param params
466
     * @param overwrite
467
     * @throws DataException
468
     */
469
    public void createFileStore(String providerName, NewRasterStoreParameters params, boolean overwrite) throws DataException;
470

  
461 471
}

Also available in: Unified diff