Revision 44304 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/feature/impl/DefaultFeatureStore.java

View differences:

DefaultFeatureStore.java
47 47
import org.gvsig.expressionevaluator.Expression;
48 48
import org.gvsig.expressionevaluator.ExpressionBuilder;
49 49
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
50
import org.gvsig.fmap.dal.BaseStoresRepository;
50 51

  
51 52
import org.gvsig.fmap.dal.DALLocator;
52 53
import org.gvsig.fmap.dal.DataManager;
......
168 169
import org.gvsig.tools.util.HasAFile;
169 170
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
170 171
import org.gvsig.tools.util.UnmodifiableBasicMap;
171
import org.gvsig.tools.util.UnmodifiableBasicSet;
172
import org.gvsig.tools.util.UnmodifiableBasicSetChained;
173 172
import org.gvsig.tools.visitor.VisitCanceledException;
174 173
import org.gvsig.tools.visitor.Visitor;
175 174

  
......
2994 2993
    @Override
2995 2994
    public StoresRepository getStoresRepository() {
2996 2995
        final StoresRepository mainRepository = this.dataManager.getStoresRepository();
2997
        StoresRepository repository = new StoresRepository() {
2996
        StoresRepository localRepository = this.provider.getStoresRepository();
2997
        StoresRepository repository = new BaseStoresRepository(this.getName()) {
2998
            
2998 2999
            @Override
2999
            public void add(String name, DataStoreParameters parameters) {
3000
                mainRepository.add(name, parameters);
3000
            protected DataStoreParameters getMyParameters(String name) {
3001
                // Uff, esta implementacion no es nada buena
3002
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
3003
                if( children==null ) {
3004
                    return null;
3005
                }
3006
                DataStore store = children.get(name);
3007
                if( store==null ) {
3008
                    return null;
3009
                }
3010
                return store.getParameters();
3001 3011
            }
3002 3012

  
3003 3013
            @Override
3004
            public void remove(String name) {
3005
                mainRepository.remove(name);
3014
            protected boolean isEmptyMyRepository() {
3015
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
3016
                return children==null || children.isEmpty();
3006 3017
            }
3007 3018

  
3008 3019
            @Override
3009
            public DataStore get(String key) {
3010
                DataStore store = getChildren().get(key);
3011
                if( store != null ) {
3012
                    return store;
3020
            protected int getMySize() {
3021
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
3022
                if( children==null ) {
3023
                    return 0;
3013 3024
                }
3014
                return mainRepository.get(key);
3025
                return children.size();
3015 3026
            }
3016 3027

  
3017 3028
            @Override
3018
            public boolean isEmpty() {
3019
                return getChildren().isEmpty() && mainRepository.isEmpty();
3029
            public void add(String name, DataStoreParameters parameters) {
3030
                mainRepository.add(name, parameters);
3020 3031
            }
3021 3032

  
3022 3033
            @Override
3023
            public boolean containsKey(String key) {
3024
                return getChildren().containsKey(key) || mainRepository.containsKey(key);
3034
            public void remove(String name) {
3035
                mainRepository.remove(name);
3025 3036
            }
3026 3037

  
3027
            @Override
3028
            public Map<String, DataStore> toMap() {
3029
                return null;
3030
            }
3031

  
3032
            @Override
3033
            public int size() {
3034
                return getChildren().size()+mainRepository.size();
3035
            }
3036

  
3037
            @Override
3038
            public UnmodifiableBasicSet<String> keySet() {
3039
                UnmodifiableBasicMap<String, DataStore> children = getChildren();
3040
                if( children.isEmpty() ) {
3041
                    return mainRepository.keySet();
3042
                }
3043
                return new UnmodifiableBasicSetChained<>(
3044
                        children.keySet(), 
3045
                        mainRepository.keySet()
3046
                );
3047
            }
3048

  
3049
            @Override
3050
            public Iterator<DataStore> iterator() {
3051
                final Iterator<String> it = this.keySet().iterator();
3052
                return new Iterator<DataStore>() {
3053
                    @Override
3054
                    public boolean hasNext() {
3055
                        return it.hasNext();
3056
                    }
3057

  
3058
                    @Override
3059
                    public DataStore next() {
3060
                        String name = it.next();
3061
                        return get(name);
3062
                    }
3063
                };
3064
            }
3065 3038
        };
3039
        if( localRepository!=null ) {
3040
            repository.addRepository(localRepository);
3041
        }
3042
        repository.addRepository(mainRepository);
3066 3043
        return repository;
3067 3044
    }
3068 3045

  

Also available in: Unified diff