001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016:
017: package org.geotools.data.complex;
018:
019: import java.io.IOException;
020: import java.net.URL;
021: import java.util.Collections;
022: import java.util.Map;
023: import java.util.Set;
024:
025: import org.geotools.data.DataStore;
026: import org.geotools.data.DataStoreFactorySpi;
027: import org.geotools.data.complex.config.ComplexDataStoreConfigurator;
028: import org.geotools.data.complex.config.ComplexDataStoreDTO;
029: import org.geotools.data.complex.config.XMLConfigDigester;
030:
031: /**
032: * DataStoreFactory for ComplexDataStore.
033: *
034: * NOTE: currently this one is not registered through the geotools datastore plugin mechanism. Instead, we're
035: * directly using DataAccessFactory
036: *
037: * @author Gabriel Roldan, Axios Engineering
038: * @version $Id: ComplexDataStoreFactory.java 25814 2007-06-12 12:03:41Z groldan $
039: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/community-schemas/community-schema-ds/src/main/java/org/geotools/data/complex/ComplexDataStoreFactory.java $
040: * @since 2.4
041: */
042: public class ComplexDataStoreFactory implements DataStoreFactorySpi {
043:
044: public static final Param DBTYPE = new Param("dbtype",
045: String.class, "Fixed value 'complex'", true, "complex");
046: public static final Param URL = new Param("url", URL.class,
047: "URL to a complex datastore XML configuration file", true);
048:
049: public ComplexDataStoreFactory() {
050: // no-op
051: }
052:
053: public DataStore createDataStore(Map params) throws IOException {
054: Set/*<FeatureTypeMapping>*/mappings;
055: ComplexDataStore dataStore;
056:
057: URL configFileUrl = (URL) ComplexDataStoreFactory.URL
058: .lookUp(params);
059: XMLConfigDigester configReader = new XMLConfigDigester();
060: ComplexDataStoreDTO config = configReader.parse(configFileUrl);
061: mappings = ComplexDataStoreConfigurator.buildMappings(config);
062:
063: dataStore = new ComplexDataStore(mappings);
064:
065: return dataStore;
066: }
067:
068: public DataStore createNewDataStore(Map params) throws IOException {
069: throw new UnsupportedOperationException();
070: }
071:
072: public String getDisplayName() {
073: return "Complex DataStore.";
074: }
075:
076: public String getDescription() {
077: return "Complex DataStore allows mapping of FeatureTypes to externally defined Output Schemas";
078: }
079:
080: public Param[] getParametersInfo() {
081: return new Param[] { ComplexDataStoreFactory.DBTYPE,
082: ComplexDataStoreFactory.URL };
083: }
084:
085: public boolean canProcess(Map params) {
086: try {
087: Object dbType = ComplexDataStoreFactory.DBTYPE
088: .lookUp(params);
089: Object configUrl = ComplexDataStoreFactory.URL
090: .lookUp(params);
091: return "complex".equals(dbType) && configUrl != null;
092: } catch (Exception e) {
093: //e.printStackTrace();
094: }
095: return false;
096: }
097:
098: public boolean isAvailable() {
099: return true;
100: }
101:
102: public Map getImplementationHints() {
103: return Collections.EMPTY_MAP;
104: }
105:
106: }
|