svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.spi / src / main / java / org / gvsig / fmap / dal / spi / AbstractDataStore.java @ 47606
History | View | Annotate | Download (2.92 KB)
1 | 44337 | jjdelcerro | package org.gvsig.fmap.dal.spi; |
---|---|---|---|
2 | |||
3 | import org.gvsig.fmap.dal.BaseStoresRepository; |
||
4 | import org.gvsig.fmap.dal.DataManager; |
||
5 | import org.gvsig.fmap.dal.DataStore; |
||
6 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
7 | import org.gvsig.fmap.dal.StoresRepository; |
||
8 | import org.gvsig.tools.dispose.impl.AbstractDisposable; |
||
9 | import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
||
10 | import org.gvsig.tools.util.UnmodifiableBasicMap; |
||
11 | import org.slf4j.Logger; |
||
12 | import org.slf4j.LoggerFactory; |
||
13 | |||
14 | /**
|
||
15 | *
|
||
16 | * @author jjdelcerro
|
||
17 | */
|
||
18 | @SuppressWarnings("UseSpecificCatch") |
||
19 | public abstract class AbstractDataStore |
||
20 | extends AbstractDisposable
|
||
21 | implements DataStore
|
||
22 | { |
||
23 | |||
24 | protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractDataStore.class); |
||
25 | |||
26 | 45966 | jjdelcerro | protected boolean ignoreDALResource; |
27 | |||
28 | 44337 | jjdelcerro | protected AbstractDataStore() {
|
29 | 45966 | jjdelcerro | this.ignoreDALResource = false; |
30 | 44337 | jjdelcerro | } |
31 | |||
32 | protected abstract DataManager getDataManager(); |
||
33 | |||
34 | @Override
|
||
35 | public ResourcesStorage getResourcesStorage() {
|
||
36 | try {
|
||
37 | return this.getExplorer().getResourcesStorage(this); |
||
38 | } catch (Exception ex) { |
||
39 | LOGGER.warn("Can't create resources storage",ex);
|
||
40 | return null; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | @Override
|
||
45 | public StoresRepository getStoresRepository() {
|
||
46 | final StoresRepository mainRepository = this.getDataManager().getStoresRepository(); |
||
47 | StoresRepository repository = new BaseStoresRepository(this.getName()) { |
||
48 | |||
49 | @Override
|
||
50 | protected DataStoreParameters getMyParameters(String name) { |
||
51 | // Uff, esta implementacion no es nada buena
|
||
52 | DataStore store = getChildren().get(name); |
||
53 | if( store==null ) { |
||
54 | return null; |
||
55 | } |
||
56 | return store.getParameters();
|
||
57 | } |
||
58 | |||
59 | @Override
|
||
60 | protected boolean isEmptyMyRepository() { |
||
61 | UnmodifiableBasicMap<String, DataStore> children = getChildren();
|
||
62 | return children==null || children.isEmpty(); |
||
63 | } |
||
64 | |||
65 | @Override
|
||
66 | protected int getMySize() { |
||
67 | UnmodifiableBasicMap<String, DataStore> children = getChildren();
|
||
68 | if( children==null ) { |
||
69 | return 0; |
||
70 | } |
||
71 | return children.size();
|
||
72 | } |
||
73 | |||
74 | @Override
|
||
75 | public void add(String name, DataStoreParameters parameters) { |
||
76 | mainRepository.add(name, parameters); |
||
77 | } |
||
78 | |||
79 | @Override
|
||
80 | public void remove(String name) { |
||
81 | mainRepository.remove(name); |
||
82 | } |
||
83 | |||
84 | }; |
||
85 | return repository;
|
||
86 | } |
||
87 | |||
88 | @Override
|
||
89 | public UnmodifiableBasicMap<String,DataStore> getChildren() { |
||
90 | return UnmodifiableBasicMap.EMPTY_UNMODIFIABLEBASICMAP;
|
||
91 | } |
||
92 | |||
93 | 45966 | jjdelcerro | public void setIgnoreDALResource(boolean ignoreDALResource) { |
94 | this.ignoreDALResource = ignoreDALResource;
|
||
95 | } |
||
96 | 44337 | jjdelcerro | |
97 | } |