Hello all.

 

I need an OracleDatastore with  a fidmapper which returns FIDColumns As
Attributes. The only way I found is to create a new Factory extending
OracleDataStoreFactory, override the createDatastore method as follows
(I have to copy it to modify only a line in the middle...this is a
dangerous thing, because it will hide any further change of super.
createDataStore() ) and extend OracleDatastore to override the
buildFIDMapperFactory. There is a better way? I've seen that the
original buildFIDMapperFactory method (inherited from JDBC1DataStore)
have a datastoreConfig in his signature, but its contents are not used
to parameterize the new DefaultFIDMapperFactory. Is it possible to
change this behavior in the official geotools package? 

 

// METHOD in the new Factory

public DataStore createDataStore(Map params) throws IOException {

        this.params = params;

        super.createDataStore(params);

        

        /* There are no defaults here. Calling canProcess verifies that

         * all these variables exist.

         */

        String host = (String) HOST.lookUp( params );

        Integer port = (Integer) PORT.lookUp( params );

        String instance = (String) INSTANCE.lookUp( params );

        String user = (String) USER.lookUp( params );

        String passwd = (String) PASSWD.lookUp( params );

        String schema = (String) SCHEMA.lookUp( params ); // checks
uppercase

        String namespace = (String) NAMESPACE.lookUp( params );

        String dbtype = (String) DBTYPE.lookUp( params );

        Integer maxConn = (Integer) MAXCONN.lookUp(params);

        Integer minConn = (Integer) MINCONN.lookUp(params);

        Boolean validateConn = (Boolean) VALIDATECONN.lookUp(params);

        

        if( !"oracle".equals( dbtype )){

            throw new IOException( "Parameter 'dbtype' must be oracle");

        }

        

        if (!canProcess(params)) {

            throw new IOException("Cannot connect using provided
parameters");

        }

        

        

        boolean validate = validateConn != null &&
validateConn.booleanValue();

        int maxActive = maxConn != null ? maxConn.intValue() : 10;

        int maxIdle = minConn != null ? minConn.intValue() : 4;

        DataSource source = getDefaultDataSource(host, user, passwd,
port.intValue(), instance, maxActive, maxIdle, validate);

        

        //THIS IS THE ONLY CHANGED ROW - TO INSTANTIATE AN DIFFERENT
DATASTORE

        SITOracleDatastore dataStore = new SITOracleDatastore(source,
namespace, schema, new HashMap(), (Boolean)
FIDCOLUMNSASATTRIBUTES.lookUp(params));

        //ALE FINE

        

        return dataStore;

        

    }

 

// Method in the new DATASTORE

@Override

    protected FIDMapperFactory buildFIDMapperFactory(JDBCDataStoreConfig
dataStoreConfig) {

        if (fidColumnsAsAttributes) {

            return new DefaultFIDMapperFactory(true);

        } else {

            return new DefaultFIDMapperFactory(false);

        }

    }

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to