public static Map defaultParams(String description) { return defaultParams(aquireFactory(description)); }
/** * Returns the descriptions for the available DataStores. * * <p>Arrrg! Put these in the select box. * * @return Descriptions for user to choose from */ public static List listDataStoresDescriptions() { List list = new ArrayList(); for (Iterator i = getAvailableDataStoreFactories().iterator(); i.hasNext(); ) { DataAccessFactory factory = (DataAccessFactory) i.next(); initializeDataStoreFactory(factory); list.add(factory.getDisplayName()); } return list; }
/** * Convert map to real values based on factory Params. * * <p>The resulting map should still be checked with factory.acceptsMap( map ) * * @param factory * @param params * @return Map with real values that may be acceptable to Factory * @throws IOException DOCUMENT ME! */ public static Map toConnectionParams(DataAccessFactory factory, Map params) throws IOException { Map map = new HashMap(params.size()); Param[] info = factory.getParametersInfo(); // Convert Params into the kind of Map we actually need for (Iterator i = params.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); Object value = find(info, key).lookUp(params); if (value != null) { map.put(key, value); } } return map; }
DataAccessFactory factory = aquireFactory(params); if (factory == null) { return null;
public static String lookupDataStoreFactoryFormat(String type) { for (DataAccessFactory factory : DataStoreUtils.getAvailableDataStoreFactories()) { if (!(factory instanceof DataStoreFactorySpi)) { continue; } if (factory.getDisplayName().equals(type)) { for(Map.Entry e: formatToDataStoreFactory.entrySet()) { if (e.getValue().equals(factory.getClass().getCanonicalName())) { return (String) e.getKey(); } } return factory.getDisplayName(); } } return null; }
/** * Looks up the datastore using the given params, verbatim, and then eventually wraps it into a * renaming wrapper so that feature type names are good ones from the wfs point of view (that * is, no ":" in the type names) * * @param params * @deprecated use {@link #getDataAccess(Map)} */ public static DataStore getDataStore(Map params) throws IOException { DataAccess<? extends FeatureType, ? extends Feature> store; store = getDataAccess(params); if (!(store instanceof DataStore)) { return null; } return (DataStore) store; }
/** * processed parameters with relative URLs resolved against data directory. * * @param m * @return processed parameters with relative URLs resolved against data directory * @deprecated Unused, call {@link ResourcePool#getParams(Map, GeoServerResourceLoader)} * directly. */ public static <K, V> Map<K, V> getParams(Map<K, V> m) { return getParams(m, null); }
/** * Returns the datastore factory used to create underlying resources for a datastore. * * <p>This method first uses {@link DataStoreInfo#getType()} to obtain the datastore. In the * event of a failure it falls back on {@link DataStoreInfo#getConnectionParameters()}. * * @param info The data store metadata. * @return The datastore factory, or null if no such factory could be found, or the factory is * not available. * @throws IOException Any I/O errors. */ public DataAccessFactory getDataStoreFactory(DataStoreInfo info) throws IOException { DataAccessFactory factory = null; DataStoreInfo expandedStore = clone(info, true); if (info.getType() != null) { factory = DataStoreUtils.aquireFactory(expandedStore.getType()); } if (factory == null && expandedStore.getConnectionParameters() != null) { Map<String, Serializable> params = getParams(expandedStore.getConnectionParameters(), catalog.getResourceLoader()); factory = DataStoreUtils.aquireFactory(params); } return factory; }
public static String lookupDataStoreFactoryFormat(String type) { for (DataAccessFactory factory : DataStoreUtils.getAvailableDataStoreFactories()) { if (factory == null) { continue; } if (factory.getDisplayName() != null && factory.getDisplayName().equals(type)) { for (Map.Entry e : formatToDataStoreFactory.entrySet()) { if (e.getValue().equals(factory.getClass().getCanonicalName())) { return (String) e.getKey(); } } return factory.getDisplayName(); } } return null; }
dataStore = DataStoreUtils.getDataAccess(connectionParameters); if (dataStore == null) {
/** * Looks up a format based on a set of connection parameters. */ public static DataFormat lookup(Map<String,Serializable> params) { DataStoreFactorySpi factory = (DataStoreFactorySpi) DataStoreUtils.aquireFactory(params); if (factory != null) { return new DataStoreFormat(factory); } return null; }
/** @return the name/description set of available datastore factories */ private Map<String, DataAccessFactory> getAvailableDataStores() { // dataStores is transient, a back button may get us to the serialized version so check for // it if (dataStores == null) { final Iterator<DataAccessFactory> availableDataStores; availableDataStores = DataStoreUtils.getAvailableDataStoreFactories().iterator(); Map<String, DataAccessFactory> storeNames = new HashMap<String, DataAccessFactory>(); while (availableDataStores.hasNext()) { DataAccessFactory factory = availableDataStores.next(); if (factory.getDisplayName() != null) { storeNames.put(factory.getDisplayName(), factory); } } dataStores = storeNames; } return dataStores; }
/** * When loading from DTO use the params to locate factory. * * <p>bleck * * @param params */ public static DataAccessFactory aquireFactory(Map params) { for (Iterator i = getAvailableDataStoreFactories().iterator(); i.hasNext(); ) { DataAccessFactory factory = (DataAccessFactory) i.next(); initializeDataStoreFactory(factory); if (factory.canProcess(params)) { return factory; } } return null; }
/** Looks up a format based on a set of connection parameters. */ public static DataFormat lookup(Map<String, Serializable> params) { DataStoreFactorySpi factory = (DataStoreFactorySpi) DataStoreUtils.aquireFactory(params); if (factory != null) { return new DataStoreFormat(factory); } return null; }
/** * @return the name/description set of available datastore factories */ private Map<String, DataAccessFactory> getAvailableDataStores() { // dataStores is transient, a back button may get us to the serialized version so check for // it if (dataStores == null) { final Iterator<DataAccessFactory> availableDataStores; availableDataStores = DataStoreUtils.getAvailableDataStoreFactories().iterator(); Map<String, DataAccessFactory> storeNames = new HashMap<String, DataAccessFactory>(); while (availableDataStores.hasNext()) { DataAccessFactory factory = availableDataStores.next(); if(factory.getDisplayName() != null) { storeNames.put(factory.getDisplayName(), factory); } } dataStores = storeNames; } return dataStores; }
/** * After user has selected Description can aquire Factory based on display name. * * <p>Use factory for: * * <ul> * <li>List of Params (attrb name, help text) * <li>Checking user's input with factory.canProcess( params ) * </ul> * * @param diplayName */ public static DataAccessFactory aquireFactory(String displayName) { if (displayName == null) { return null; } for (Iterator i = getAvailableDataStoreFactories().iterator(); i.hasNext(); ) { DataAccessFactory factory = (DataAccessFactory) i.next(); initializeDataStoreFactory(factory); if (displayName.equals(factory.getDisplayName())) { return factory; } if (displayName.equals(factory.getClass().toString())) { return factory; } } return null; }
/** Loads the available tables from this database. */ @Override public void prepare(ProgressMonitor m) throws IOException { tables = new ArrayList<Table>(); DataStoreFactorySpi factory = (DataStoreFactorySpi) DataStoreUtils.aquireFactory(parameters); if (factory == null) { throw new IOException("Unable to find data store for specified parameters"); } m.setTask("Loading tables"); DataStore store = factory.createDataStore(parameters); if (store == null) { throw new IOException("Unable to create data store from specified parameters"); } format = DataFormat.lookup(parameters); try { for (String typeName : store.getTypeNames()) { Table tbl = new Table(typeName, this); tbl.setFormat(format); tables.add(tbl); } } finally { // TODO: cache the datastore for subsquent calls store.dispose(); } }
public static DataStoreFactorySpi lookupDataStoreFactory(String format) { // first try and see if we know about this format directly String factoryClassName = formatToDataStoreFactory.get(format); if (factoryClassName != null) { try { Class factoryClass = Class.forName(factoryClassName); DataStoreFactorySpi factory = (DataStoreFactorySpi) factoryClass.newInstance(); return factory; } catch (Exception e) { throw new RestletException("Datastore format unavailable: " + factoryClassName, Status.SERVER_ERROR_INTERNAL); } } // if not, let's see if we have a file data store factory that knows about the extension String extension = "." + format; for (DataAccessFactory dataAccessFactory : DataStoreUtils.getAvailableDataStoreFactories()) { if (dataAccessFactory instanceof FileDataStoreFactorySpi) { FileDataStoreFactorySpi factory = (FileDataStoreFactorySpi) dataAccessFactory; for (String handledExtension : factory.getFileExtensions()) { if (extension.equalsIgnoreCase(handledExtension)) { return factory; } } } } throw new RestletException("Unsupported format: " + format, Status.CLIENT_ERROR_BAD_REQUEST); }
/** * Loads the available tables from this database. */ @Override public void prepare(ProgressMonitor m) throws IOException { tables = new ArrayList<Table>(); DataStoreFactorySpi factory = (DataStoreFactorySpi) DataStoreUtils.aquireFactory(parameters); if (factory == null) { throw new IOException("Unable to find data store for specified parameters"); } m.setTask("Loading tables"); DataStore store = factory.createDataStore(parameters); if (store == null) { throw new IOException("Unable to create data store from specified parameters"); } format = DataFormat.lookup(parameters); try { for (String typeName : store.getTypeNames()) { Table tbl = new Table(typeName, this); tbl.setFormat(format); tables.add(tbl); } } finally { //TODO: cache the datastore for subsquent calls store.dispose(); } }
public static DataAccessFactory lookupDataStoreFactory(String format) { // first try and see if we know about this format directly String factoryClassName = formatToDataStoreFactory.get(format); if (factoryClassName != null) { try { Class factoryClass = Class.forName(factoryClassName); return (DataAccessFactory) factoryClass.newInstance(); } catch (Exception e) { throw new RestException( "Datastore format unavailable: " + factoryClassName, HttpStatus.INTERNAL_SERVER_ERROR); } } // if not, let's see if we have a file data store factory that knows about the extension String extension = "." + format; for (DataAccessFactory dataAccessFactory : DataStoreUtils.getAvailableDataStoreFactories()) { if (dataAccessFactory instanceof FileDataStoreFactorySpi) { FileDataStoreFactorySpi factory = (FileDataStoreFactorySpi) dataAccessFactory; for (String handledExtension : factory.getFileExtensions()) { if (extension.equalsIgnoreCase(handledExtension)) { return factory; } } } } throw new RestException("Unsupported format: " + format, HttpStatus.BAD_REQUEST); }