Revision 46301 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/project/documents/table/TableManager.java
TableManager.java | ||
---|---|---|
55 | 55 |
import org.gvsig.fmap.dal.DALLocator; |
56 | 56 |
import org.gvsig.fmap.dal.DataManager; |
57 | 57 |
import org.gvsig.fmap.dal.DataStoreParameters; |
58 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
59 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
60 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
58 | 61 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
59 | 62 |
import org.gvsig.fmap.dal.feature.FeatureQueryOrder; |
60 | 63 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
... | ... | |
73 | 76 |
import org.gvsig.tools.util.Invocable; |
74 | 77 |
import org.gvsig.tools.util.MappedIterator; |
75 | 78 |
import org.gvsig.tools.util.UnmodifiableBasicSet; |
79 |
import org.slf4j.LoggerFactory; |
|
76 | 80 |
|
77 | 81 |
/** |
78 | 82 |
* Factory of Table. |
... | ... | |
83 | 87 |
@SuppressWarnings("UseSpecificCatch") |
84 | 88 |
public class TableManager extends AbstractDocumentManager { |
85 | 89 |
|
90 |
final static private org.slf4j.Logger LOGGER = LoggerFactory.getLogger(TableDocument.class); |
|
91 |
|
|
86 | 92 |
private static class TableDocumentStoresRepository extends AbstractStoresRepository { |
87 | 93 |
|
88 | 94 |
public TableDocumentStoresRepository(String name, String label) { |
... | ... | |
158 | 164 |
return ((TableDocument)t).getFeatureStore().getParameters(); |
159 | 165 |
}); |
160 | 166 |
} |
161 |
|
|
162 |
|
|
167 |
|
|
168 |
@Override |
|
169 |
public void add(String name, DataStoreParameters parameters) { |
|
170 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
171 |
TableDocument doc = (TableDocument) ProjectManager.getInstance().createDocument(TYPENAME); |
|
172 |
doc.setName(name); |
|
173 |
//FIXME: |
|
174 |
DataManager dataManager = DALLocator.getDataManager(); |
|
175 |
FeatureStore store; |
|
176 |
try { |
|
177 |
store = (FeatureStore) dataManager.openStore( |
|
178 |
parameters.getProviderName(), |
|
179 |
parameters |
|
180 |
); |
|
181 |
doc.setStore(store); |
|
182 |
project.addDocument(doc); |
|
183 |
} catch (InitializeException | ProviderNotRegisteredException | ValidateDataParametersException ex) { |
|
184 |
LOGGER.warn("Can't add table to project", ex); |
|
185 |
} |
|
186 |
|
|
187 |
} |
|
188 |
|
|
189 |
@Override |
|
190 |
public void add(String name, FeatureStore store) { |
|
191 |
Project project = ProjectManager.getInstance().getCurrentProject(); |
|
192 |
TableDocument doc = (TableDocument) ProjectManager.getInstance().createDocument(TYPENAME); |
|
193 |
doc.setName(name); |
|
194 |
doc.setStore(store); |
|
195 |
project.addDocument(doc); |
|
196 |
} |
|
163 | 197 |
} |
164 | 198 |
|
165 | 199 |
public static final String PERSISTENCE_TABLE_DOCUMENT_DEFINITION_NAME = |
Also available in: Unified diff