Revision 45043 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
DefaultDataManager.java | ||
---|---|---|
13 | 13 |
import java.util.Objects; |
14 | 14 |
import java.util.Set; |
15 | 15 |
import java.util.UUID; |
16 |
import javax.json.JsonArray; |
|
17 |
import javax.json.JsonObject; |
|
18 |
import javax.json.JsonValue; |
|
16 | 19 |
import org.apache.commons.io.IOUtils; |
17 | 20 |
import org.apache.commons.lang3.StringUtils; |
18 | 21 |
import org.gvsig.expressionevaluator.Expression; |
... | ... | |
21 | 24 |
import org.gvsig.expressionevaluator.MutableSymbolTable; |
22 | 25 |
import org.gvsig.expressionevaluator.impl.DefaultDALExpressionBuilder; |
23 | 26 |
import org.gvsig.expressionevaluator.impl.symboltable.FeatureSymbolTableImpl; |
27 |
import org.gvsig.expressionevaluator.spi.JsonUtils; |
|
24 | 28 |
import org.gvsig.fmap.dal.BaseStoresRepository; |
25 | 29 |
import org.gvsig.fmap.dal.DALLocator; |
26 | 30 |
|
... | ... | |
108 | 112 |
import org.slf4j.Logger; |
109 | 113 |
import org.slf4j.LoggerFactory; |
110 | 114 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager.DatabaseWorkspaceListener; |
111 |
import org.gvsig.fmap.dal.feature.FeatureStoreNotification; |
|
112 | 115 |
import org.gvsig.tools.observer.Observer; |
113 | 116 |
|
114 | 117 |
@SuppressWarnings("UseSpecificCatch") |
... | ... | |
377 | 380 |
} |
378 | 381 |
|
379 | 382 |
@Override |
383 |
public NewDataStoreParameters createNewStoreParameters(String providerName) throws InitializeException, ProviderNotRegisteredException { |
|
384 |
String explorerName = this.getServerExplorerFromStore(providerName); |
|
385 |
return createNewStoreParameters(explorerName, providerName); |
|
386 |
} |
|
387 |
|
|
388 |
@Override |
|
380 | 389 |
public NewDataStoreParameters createNewStoreParameters(String explorerName, String providerName) throws InitializeException, ProviderNotRegisteredException { |
381 | 390 |
try { |
382 | 391 |
DataServerExplorer explorer = this.openServerExplorer(explorerName, (DataServerExplorerParameters)null); |
... | ... | |
786 | 795 |
} |
787 | 796 |
|
788 | 797 |
@Override |
798 |
public void newStore(String providerName, NewDataStoreParameters parameters, boolean overwrite) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
|
799 |
String explorerName = this.getServerExplorerFromStore(providerName); |
|
800 |
newStore(explorerName, providerName, parameters, overwrite); |
|
801 |
} |
|
802 |
|
|
803 |
@Override |
|
789 | 804 |
public void newStore(String explorerName, String providerName, NewDataStoreParameters parameters, boolean overwrite) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
790 | 805 |
if( explorerName == null ) { |
791 | 806 |
String msg = "Explorer name can't be null."; |
... | ... | |
870 | 885 |
} |
871 | 886 |
|
872 | 887 |
@Override |
888 |
public EditableFeatureType createFeatureType(JsonObject json) { |
|
889 |
EditableFeatureType featureType = this.createFeatureType(); |
|
890 |
featureType.setLabel((String) JsonUtils.getitem(json, "name")); |
|
891 |
JsonArray columns = json.getJsonArray("columns"); |
|
892 |
for (JsonValue item : columns ) { |
|
893 |
JsonObject jsonattr = (JsonObject) item; |
|
894 |
EditableFeatureAttributeDescriptor attr = featureType.add( |
|
895 |
jsonattr.getString("name"), |
|
896 |
jsonattr.getString("type") |
|
897 |
); |
|
898 |
for (String name : jsonattr.keySet()) { |
|
899 |
attr.set(name, JsonUtils.getitem(jsonattr, name)); |
|
900 |
} |
|
901 |
} |
|
902 |
return featureType; |
|
903 |
} |
|
904 |
|
|
905 |
@Override |
|
873 | 906 |
public DataServerExplorerPool getDataServerExplorerPool() { |
874 | 907 |
if (this.dataServerExplorerPool == null) { |
875 | 908 |
this.dataServerExplorerPool = new DefaultDataServerExplorerPool(); |
... | ... | |
990 | 1023 |
throw new ProviderNotRegisteredException(name); |
991 | 1024 |
} |
992 | 1025 |
return featureCacheProviderFactory.createCacheProvider(parameters); |
993 |
} catch (InstantiationException e) {
|
|
1026 |
} catch (Exception e) { |
|
994 | 1027 |
throw new InitializeException(e); |
995 |
} catch (IllegalAccessException e) { |
|
996 |
throw new InitializeException(e); |
|
997 | 1028 |
} |
998 | 1029 |
} |
999 | 1030 |
|
... | ... | |
1026 | 1057 |
throw new ProviderNotRegisteredException(name); |
1027 | 1058 |
} |
1028 | 1059 |
return featureCacheProviderFactory.createParameters(); |
1029 |
} catch (InstantiationException e) {
|
|
1060 |
} catch (Exception e) { |
|
1030 | 1061 |
throw new InitializeException(e); |
1031 |
} catch (IllegalAccessException e) { |
|
1032 |
throw new InitializeException(e); |
|
1033 | 1062 |
} |
1034 | 1063 |
} |
1035 | 1064 |
|
... | ... | |
1332 | 1361 |
public void removeStoreObserver(Observer observer) { |
1333 | 1362 |
this.storeObservers.remove(observer); |
1334 | 1363 |
} |
1364 |
|
|
1365 |
@Override |
|
1366 |
public String getServerExplorerFromStore(String name) { |
|
1367 |
Register r = this.getServerExplorerRegister(); |
|
1368 |
for (DataFactory factory0 : r) { |
|
1369 |
DataServerExplorerFactory factory = (DataServerExplorerFactory) factory0; |
|
1370 |
if( factory.isStoreSupported(name) ) { |
|
1371 |
return factory.getName(); |
|
1372 |
} |
|
1373 |
} |
|
1374 |
return null; |
|
1375 |
} |
|
1376 |
|
|
1335 | 1377 |
|
1336 | 1378 |
} |
Also available in: Unified diff