I am trying to add resources consisting of a shapefile (archsites.shp + 
accessory files), a mapping file and a schema to the app-schema 
src/test/resources/test-data directory in order to run unit tests using 
shapefile-based datastores. I tested the mapping file and schema in 
geoserver (built from trunk) and it seems to work fine, but when I try a 
unit test in geotools, I get  on the console:

Sep 22, 2010 4:43:19 PM org.geotools.factory.FactoryRegistry scanForPlugins
CONFIG: Factory implementations for category DataAccessFactory:
  org.geotools.data.complex.DataAccessIntegrationTest$InputDataAccessFactory
  
org.geotools.data.complex.AppSchemaDataAccessIntegrationTest$EarthResourceDataAccessFactory
  org.geotools.data.complex.AppSchemaDataAccessFactory
  org.geotools.data.DataAccessFinderTest$MockDataAccessFactory
Sep 22, 2010 4:43:19 PM org.geotools.factory.FactoryRegistry scanForPlugins
CONFIG: Factory implementations for category DataStoreFactorySpi:
  org.geotools.data.complex.XmlDataStoreTest$MockXmlDataStoreFactory
  org.geotools.data.DataAccessFinderTest$MockDataStoreFactory
  org.geotools.data.DataAccessFinderTest$MockUnavailableDataStoreFactory
  org.geotools.data.postgis.PostgisDataStoreFactory
  org.geotools.data.property.PropertyDataStoreFactory
Sep 22, 2010 4:10:02 PM 
org.geotools.data.complex.config.AppSchemaDataAccessConfigurator 
acquireSourceDatastores
SEVERE: Cannot find a DataAccess for parameters {create spatial 
index=true, memory mapped buffer=false, 
url=file:src\test\resources\test-data\aecoreco\data\shapes\archsites.shp, 
charset=ISO-8859-1}

with a trace of:
org.geotools.data.DataSourceException: Cannot find a DataAccess for 
parameters (some not shown) 
{url=file:src\test\resources\test-data\aecoreco\data\shapes\archsites.shp}
    at 
org.geotools.data.complex.config.AppSchemaDataAccessConfigurator.acquireSourceDatastores(AppSchemaDataAccessConfigurator.java:592)
    at 
org.geotools.data.complex.config.AppSchemaDataAccessConfigurator.buildMappings(AppSchemaDataAccessConfigurator.java:180)
    at 
org.geotools.data.complex.config.AppSchemaDataAccessConfigurator.buildMappings(AppSchemaDataAccessConfigurator.java:157)
    at 
org.geotools.data.complex.config.AppSchemaShapefileTest.testMappings(AppSchemaShapefileTest.java:61)
...

So it looks like I need to register a DataStoreFactory or 
DataStoreFactorySpi for shapefiles in some META-INF file somehow. I 
scanned the geotools manuals and lists looking for this but didn't seem 
to find anything that I could recognise as relevant. Could someone point 
me in the right direction? Thanks, Tara



For reference, the various resource files are:
the mapping file is:

<?xml version="1.0" encoding="UTF-8"?>
<as:AppSchemaDataAccess xmlns:as="http://www.geotools.org/app-schema";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://www.geotools.org/app-schema 
AppSchemaDataAccess.xsd">
  <namespaces>
    <Namespace>
        <prefix>gml</prefix>
        <uri>http://www.opengis.net/gml</uri>
    </Namespace>
    <Namespace>
        <prefix>aeras</prefix>
        <uri>urn:www.aecoreco.com:schemas:archsites</uri>
    </Namespace>
  </namespaces>
  <sourceDataStores>
      <DataStore>
          <id>datastore_shp</id>
          <parameters>
              <Parameter>
                  <name>url</name>
                  <value>file:../../../data/shapes/archsites.shp</value>
              </Parameter>
              <Parameter>
                  <name>memory mapped buffer</name>
                  <value>false</value>
              </Parameter>
              <Parameter>
                  <name>create spatial index</name>
                  <value>true</value>
              </Parameter>
              <Parameter>
                  <name>charset</name>
                  <value>ISO-8859-1</value>
              </Parameter>
          </parameters>
      </DataStore>
  </sourceDataStores>
  <catalog>../../../schemas/catalog.xml</catalog>
  <targetTypes>
      <FeatureType>
          
<schemaUri>http://www.aecoreco.com/schemas/archsites/ArchSite.xsd</schemaUri>
      </FeatureType>
  </targetTypes>
  <typeMappings>
      <FeatureTypeMapping>
          <sourceDataStore>datastore_shp</sourceDataStore>
          <sourceType>archsites</sourceType>
          <targetElement>aeras:ArchSiteNillable</targetElement>
          <attributeMappings>
            <AttributeMapping>
              <targetAttribute>
                gml:Point
              </targetAttribute>
              <sourceExpression>
                <OCQL>the_geom</OCQL>
              </sourceExpression>
            </AttributeMapping>
            <AttributeMapping>
              <targetAttribute>
                aeras:ID
              </targetAttribute>
              <sourceExpression>
                <OCQL>ID</OCQL>
              </sourceExpression>
            </AttributeMapping>
            <AttributeMapping>
              <targetAttribute>
                aeras:CAT_ID
              </targetAttribute>
              <sourceExpression>
                <OCQL>CAT_ID</OCQL>
              </sourceExpression>
            </AttributeMapping>
            <AttributeMapping>
              <targetAttribute>
                aeras:CAT_DESC
              </targetAttribute>
              <sourceExpression>
                <!--<OCQL>if_then_else(TRUE, CAT_DESC, NULL)</OCQL>-->
                <OCQL>if_then_else(equalTo(CAT_DESC, 'No Name'), 
Expression.Nil , CAT_DESC)</OCQL>
              </sourceExpression>
            </AttributeMapping>
          </attributeMappings>
      </FeatureTypeMapping>
  </typeMappings>
</as:AppSchemaDataAccess>

and the schema is

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2010 rel. 3 sp1 (http://www.altova.com) by Tara 
Athan (Athan Services) -->
<schema xmlns="http://www.w3.org/2001/XMLSchema"; 
xmlns:gml="http://www.opengis.net/gml"; 
xmlns:aeras="urn:www.aecoreco.com:schemas:archsites" 
targetNamespace="urn:www.aecoreco.com:schemas:archsites" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
    <import namespace="http://www.opengis.net/gml"; 
schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/gml.xsd"/>
    <element name="ArchSiteNillable" type="aeras:ArchSiteNillableType" 
substitutionGroup="gml:_Feature" />
    <complexType name="ArchSiteNillableType">
        <complexContent>
            <extension base="gml:AbstractFeatureType">
                <sequence>
                    <element ref="gml:Point"/>
                    <element name="ID" type="integer"/>
                    <element name="CAT_ID" type="integer"/>
                    <element name="CAT_DESC" type="string" nillable="true"/>
                </sequence>
            </extension>
        </complexContent>
    </complexType>
</schema>

I also have a catalog file:
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC
    "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
    "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd";>

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

  <rewriteURI uriStartString="http://www.aecoreco.com/schemas/archsites/";
              rewritePrefix="aeras/" /> 

  <rewriteURI uriStartString="urn:www.aecoreco.com:schemas:archsites:"
              rewritePrefix="aeras/" />  

</catalog>

The unit test code is as follows:


package org.geotools.data.complex.config;

import java.net.URL;
import java.util.Set;

import junit.framework.TestCase;

import org.geotools.data.complex.AppSchemaDataAccess;
import org.geotools.data.complex.FeatureTypeMapping;

/**
 * This is a test for AppSchemaDataAccessConfigurator on shapefiles.
 *
 * @author Tara Athan
 */
public class AppSchemaShapefileTest extends TestCase {

    final String schemaBase = "src/test/resources/test-data/aecoreco/";

    /**
     * Test the constructor
     */
    @SuppressWarnings("unchecked")
    public void testMappings() throws Exception {
        // configFilePath is the path to a mapping file in the resources 
directory
        String configFilePath = schemaBase + 
"mapping-files/aeras/ArchSite/ArchSiteNillable.xml";       
        URL configFileUrl = new URL("file:"+configFilePath);
       
        // config is the object created when the mapping file is parsed
        XMLConfigDigester configReader = new XMLConfigDigester();
        AppSchemaDataAccessDTO config = configReader.parse(configFileUrl);
       
        // mappings is the object needed to build the application-schema 
datastore
        Set<FeatureTypeMapping> mappings;
        mappings = AppSchemaDataAccessConfigurator.buildMappings(config);
        AppSchemaDataAccess dataStore = new AppSchemaDataAccess(mappings);

    }

}

-- 
Tara Athan
Owner, Athan Ecological Reconciliation Services
tara_athan at alt2is.com
707-272-2115 (cell, preferred)
707-485-1198 (office)
249 W. Gobbi St. #A
Ukiah, CA 95482


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to