/** * 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; }
@Override protected String getJDBCUrl(Map params) throws IOException { File db = (File) DATABASE.lookUp(params); if (db.getPath().startsWith("file:")) { db = new File(db.getPath().substring(5)); } if (baseDirectory != null) { // check for a relative path if (!db.isAbsolute()) { db = new File(baseDirectory, db.getPath()); } } return "jdbc:sqlite:" + db; }
public DataStore createDataStore(Map<String, Serializable> params) throws IOException { File dir = directoryLookup(params); String namespaceURI = (String) NAMESPACE.lookUp(params); if (dir.exists() && dir.isDirectory()) { return new PropertyDataStore(dir, namespaceURI); } else { throw new IOException("Directory is required"); } }
public boolean canProcess(Map params) { // we don't try to steal single shapefiles away from the main factory if (super.canProcess(params)) { try { URL url = (URL) URLP.lookUp(params); File f = URLs.urlToFile(url); return f != null && f.exists() && f.isDirectory(); } catch (Exception e) { return false; } } else { return false; } } }
public DataStore createDataStore(Map<String, Serializable> params) throws IOException { String providerClassName = (String) GENERALIZATION_INFOS_PROVIDER_CLASS.lookUp(params); String repositoryClassName = (String) REPOSITORY_CLASS.lookUp(params); String providerParam = (String) GENERALIZATION_INFOS_PROVIDER_PARAM.lookUp(params); URI namespace = (URI) NAMESPACEP.lookUp(params); try { Class providerClass = Class.forName(providerClassName); GeneralizationInfosProvider provider = (GeneralizationInfosProvider) providerClass.newInstance(); GeneralizationInfos gInfos = provider.getGeneralizationInfos(providerParam); Class repositoryClass = Class.forName(repositoryClassName); Repository repository = (Repository) repositoryClass.newInstance(); return new PreGeneralizedDataStore(gInfos, repository, namespace); } catch (Exception ex) { throw new IOException(ex.getMessage()); } }
@Override public boolean canProcess(Map params) { if (!super.canProcess(params)) { return false; // was not in agreement with getParametersInfo } Integer port = null; String instance = null; try { port = (Integer) PORT.lookUp(params); instance = (String) INSTANCE.lookUp(params); } catch (IOException e) { } // we only need one or the other of these return (port != null || instance != null); }
static void addConnectionProperties(BasicDataSource dataSource, Map configuration) throws IOException { SQLiteConfig config = new SQLiteConfig(); config.setSharedCache(true); config.enableLoadExtension(true); Object synchronous = READ_ONLY.lookUp(configuration); if (Boolean.TRUE.equals(synchronous)) { config.setPragma(SQLiteConfig.Pragma.SYNCHRONOUS, "OFF"); config.setReadOnly(true); } // config.setPragma(SQLiteConfig.Pragma.MMAP_SIZE, "268435456"); for (Map.Entry e : config.toProperties().entrySet()) { dataSource.addConnectionProperty((String) e.getKey(), (String) e.getValue()); } }
@Override public boolean canProcess(Map<String, Serializable> params) { try { File file = (File) FILE_PARAM.lookUp(params); String indexPath = (String) INDEX_PARAM.lookUp(params); String dsPath = (String) DS_PARAM.lookUp(params); AncillaryFileManager ancilaryFileManager = new AncillaryFileManager(file, indexPath, dsPath); DataStoreConfiguration datastoreConfig = ancilaryFileManager.getDatastoreConfiguration(); return datastoreConfig.getDatastoreSpi().canProcess(datastoreConfig.getParams()); } catch (NoSuchAlgorithmException | JAXBException | IOException e) { return false; } }
@Override protected String getJDBCUrl(Map params) throws IOException { // jdbc url String host = null; Integer port = null; try { host = (String) HOST.lookUp(params); port = (Integer) PORT.lookUp(params); } catch (IOException ex) { // do nothing } String db = (String) DATABASE.lookUp(params); if (host == null && port == null && db != null) return "jdbc:" + getDatabaseID() + ":" + db; return super.getJDBCUrl(params); }
public boolean canProcess(Map<String, Serializable> params) { String repositoryClass = null, providerClass = null; try { repositoryClass = (String) REPOSITORY_CLASS.lookUp(params); providerClass = (String) GENERALIZATION_INFOS_PROVIDER_CLASS.lookUp(params); } catch (IOException ex) { return false; } if (repositoryClass == null || providerClass == null) { return false; } return true; }
protected JDBCDataStore createDataStoreInternal(JDBCDataStore dataStore, Map params) throws IOException { // check the foreign keys parameter Boolean foreignKeys = (Boolean) ASSOCIATIONS.lookUp(params); if (foreignKeys != null) { dataStore.setAssociations(foreignKeys.booleanValue()); } return dataStore; }
public DataSource createNewDataSource(Map params) throws IOException { String refName = (String) JNDI_REFNAME.lookUp(params); try { return (DataSource) GeoTools.getInitialContext(GeoTools.getDefaultHints()).lookup(refName); } catch (Exception e) { throw new DataSourceException("Could not find the specified data source in JNDI", e); } }
public boolean canProcess(Map params) { try { Object dbType = AppSchemaDataAccessFactory.DBTYPE.lookUp(params); Object configUrl = AppSchemaDataAccessFactory.URL.lookUp(params); return DBTYPE_STRING.equals(dbType) && configUrl != null; } catch (Exception e) { // e.printStackTrace(); } return false; }
@Override public MongoDataStore createDataStore(Map<String, Serializable> params) throws IOException { MongoDataStore dataStore = new MongoDataStore( (String) DATASTORE_URI.lookUp(params), (String) SCHEMASTORE_URI.lookUp(params)); String uri = (String) NAMESPACE.lookUp(params); if (uri != null) { dataStore.setNamespaceURI(uri); } return dataStore; }
protected final boolean checkDBType(Map params, String dbtype) { String type; try { type = (String) DBTYPE.lookUp(params); if (dbtype.equals(type)) { return true; } return false; } catch (IOException e) { return false; } }
@Override protected String getJDBCUrl(Map params) throws IOException { String db = (String) DATABASE.lookUp(params); return "jdbc:sqlite:" + db; }
public T lookUp(final Map params) throws IOException { T parameter = (T) super.lookUp(params); return parameter == null ? defaultValue : parameter; } }
@Override protected String getJDBCUrl(Map params) throws IOException { String alias = (String) ALIAS.lookUp(params); return "jdbc:oracle:oci:@" + alias; }