Java Code Examples for org.geotools.data.DataStoreFactorySpi

The following examples show how to use org.geotools.data.DataStoreFactorySpi. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: sldeditor   Source File: DataSourceImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populates the list of available data stores that can be connected to.
 */
private void populateAvailableDataStores()
{
    DataAccessFactory fac;

    logger.debug("Available data store factories:");

    Iterator<DataStoreFactorySpi> iterator = DataStoreFinder.getAvailableDataStores();
    while (iterator.hasNext()) {
        fac = (DataAccessFactory) iterator.next();

        logger.debug("\t" + fac.getDisplayName());

        availableDataStoreList.add(fac.getDisplayName());
    }
}
 
Example 2
/** Populate name map. */
private static void populateNameMap() {
    Iterator<DataStoreFactorySpi> datastore = DataStoreFinder.getAvailableDataStores();

    while (datastore.hasNext()) {
        DataStoreFactorySpi dSPI = datastore.next();

        Param dbType = null;
        for (Param param : dSPI.getParametersInfo()) {
            if (param.key.equals(JDBCDataStoreFactory.DBTYPE.key)) {
                dbType = param;
                break;
            }
        }
        if (dbType != null) {
            nameMap.put(dSPI.getDisplayName(), (String) dbType.sample);
        }
    }
}
 
Example 3
Source Project: geowave   Source File: GeoWaveGTDataStoreFactory.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public DataStoreFactorySpi apply(final StoreFactoryFamilySpi input) {
  i++;
  switch (i) {
    case 1:
      return new GeoWaveGTDataStoreFactory1(input);
    case 2:
      return new GeoWaveGTDataStoreFactory2(input);
    case 3:
      return new GeoWaveGTDataStoreFactory3(input);
    case 4:
      return new GeoWaveGTDataStoreFactory4(input);
    case 5:
      return new GeoWaveGTDataStoreFactory5(input);
    case 6:
      return new GeoWaveGTDataStoreFactory6(input);
    case 7:
      return new GeoWaveGTDataStoreFactory7(input);
    case 8:
      return new GeoWaveGTDataStoreFactory8(input);
    case 9:
      return new GeoWaveGTDataStoreFactory9(input);
  }
  LOGGER.error("Too many GeoWave Datastores registered for GeoTools data store");
  return new GeoWaveGTDataStoreFactory(input);
}
 
Example 4
Source Project: sldeditor   Source File: DataSourceImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** Populates the list of available data stores that can be connected to. */
private void populateAvailableDataStores() {
    DataAccessFactory fac = null;

    logger.debug("Available data store factories:");

    Iterator<DataStoreFactorySpi> iterator = DataStoreFinder.getAvailableDataStores();
    while (iterator.hasNext()) {
        fac = iterator.next();

        logger.debug("\t" + fac.getDisplayName());

        availableDataStoreList.add(fac.getDisplayName());
    }
}
 
Example 5
Source Project: geowave   Source File: GeoWaveGTDataStoreFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public <T> Iterator<T> iterator(final Class<T> cls) {
  if ((cls != null) && cls.isAssignableFrom(DataStoreFactorySpi.class)) {
    return (Iterator<T>) new GeoWaveGTDataStoreFactoryIterator();
  }
  return null;
}
 
Example 6
Source Project: geowave   Source File: GeoWaveGTDataStoreFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public DataStoreFactorySpi next() {
  return it.next();
}
 
Example 7
/**
 * Creates a suitable {@link DataStore} for the specified parameters.
 * 
 * @param parameters list of GeoTools parameters.
 * @return data store, never null
 * @throws IOException could not create data store
 */
public static DataStore create(Map<String, Object> parameters) throws IOException {
	Object url = parameters.get(ShapefileDataStoreFactory.URLP.key);
	Logger log = LoggerFactory.getLogger(DataStoreFactory.class);
	if (url instanceof String) {
		parameters.put(ShapefileDataStoreFactory.URLP.key, ResourceUtils.getURL((String) url).toExternalForm());
	}
	if (DATASTORE_CACHE.containsKey(parameters)) {
		return DATASTORE_CACHE.get(parameters);
	}
	DataStore store = DataStoreFinder.getDataStore(parameters);
	Object typed = parameters.get(USE_TYPED_FIDS);
	if (typed instanceof String) {
		Boolean t = Boolean.valueOf((String) typed);
		if (!t) {
			if (store != null) {
				log.warn("Non-typed FIDs are only supported by first-generation JDBC datastores, "
						+ "using default fid format for datastore class " + store.getClass().getName());
			}
		}
	}
	if (null == store) {
		StringBuilder availableStr = new StringBuilder();
		StringBuilder missingStr = new StringBuilder();
		Iterator<DataStoreFactorySpi> all = DataStoreFinder.getAllDataStores();
		while (all.hasNext()) {
			DataStoreFactorySpi factory = all.next();
			if (!factory.isAvailable()) {
				log.warn("Datastore factory " + factory.getDisplayName() + "(" + factory.getDescription()
						+ ") is not available");
				if (missingStr.length() != 0) {
					missingStr.append(",");
				}
				missingStr.append(factory.getDisplayName());
			} else {
				if (availableStr.length() != 0) {
					availableStr.append(",");
				}
				availableStr.append(factory.getDisplayName());
			}
		}
		throw new IOException(
				"No datastore found. Possible causes are missing factory or missing library for your datastore"
						+ " (e.g. database driver).\nCheck the isAvailable() method of your"
						+ " DataStoreFactory class to find out which libraries are needed.\n"
						+ "Unavailable factories : " + missingStr + "\n" + "Available factories : " + availableStr
						+ "\n");
	}
	DATASTORE_CACHE.put(parameters, store);
	return store;
}