/** * Takes a config object and creates a set of mappings. * * <p>In the process will parse xml schemas to geotools' Feature Model types and descriptors, * connect to source datastores and build the mapping objects from source FeatureTypes to the * target ones. * * @param config DOCUMENT ME! * @return a Set of {@link org.geotools.data.complex.FeatureTypeMapping} source to target * FeatureType mapping definitions * @throws IOException if any error occurs while creating the mappings */ public static Set<FeatureTypeMapping> buildMappings(AppSchemaDataAccessDTO config) throws IOException { return buildMappings(config, new DataAccessMap()); }
private Expression parseOgcCqlExpression(String sourceExpr) throws DataSourceException { return parseOgcCqlExpression(sourceExpr, ff); }
/** * This method will not create a source data store if an equivalent one (i.e. same configuration * parameters) is found in the provided <code>sourceDataStoreMap</code>. * * @see AppSchemaDataAccessConfigurator#buildMappings(AppSchemaDataAccessDTO) * @param sourceDataStoreMap map holding the source data stores created so far, e.g. while * parsing App-Schema configuration files included by the one currently being processed */ public static Set<FeatureTypeMapping> buildMappings( AppSchemaDataAccessDTO config, DataAccessMap sourceDataStoreMap) throws IOException { AppSchemaDataAccessConfigurator mappingsBuilder; mappingsBuilder = new AppSchemaDataAccessConfigurator(config, sourceDataStoreMap); Set<FeatureTypeMapping> mappingObjects = mappingsBuilder.buildMappings(); return mappingObjects; }
/** Build the resolver (catalog plus cache) for this data access. */ private SchemaResolver buildResolver() { return new SchemaResolver(buildCatalog(), buildCache()); }
parseGmlSchemas(); Map<String, DataAccess<FeatureType, Feature>> sourceDataStores = null; Set<FeatureTypeMapping> featureTypeMappings = null; try { sourceDataStores = acquireSourceDatastores(); featureTypeMappings = createFeatureTypeMappings(sourceDataStores); return featureTypeMappings; } finally { disposeUnusedSourceDataStores(sourceDataStores, featureTypeMappings);
validateConfiguredNamespaces(inputXPathSteps); final StepList inputXPathSteps = XPath.steps(root, itemXpath + "/" + inputXPath, namespaces); validateConfiguredNamespaces(inputXPathSteps); validateConfiguredNamespaces(targetXPathSteps); ? parseOgcCqlExpression(idExpr) : new AttributeExpressionImpl( idXpath, ? parseOgcCqlExpression(sourceExpr) : new AttributeExpressionImpl( inputXPath, final Map clientProperties = getClientProperties(attDto); Expression elementExpr = parseOgcCqlExpression(sourceElement); String sourceField = attDto.getLinkField(); StepList sourceFieldSteps = null; if (customNestedMapping != null) { attMapping = customNestedMapping; } else if (isJoining() && isJDBC) { attMapping = new JoiningNestedAttributeMapping(
Map<String, Serializable> datastoreParams = dsconfig.getParams(); datastoreParams = resolveRelativePaths(datastoreParams); dataStore = buildDataStore(extensions, dsconfig, config); "Cannot find a DataAccess for parameters " + "(some not shown) " + filterDatastoreParams(datastoreParams));
@Test public void testJoiningDefault() { // not set in the app-schema properties // joining should be on by default AppSchemaDataAccessRegistry.clearAppSchemaProperties(); boolean joining = AppSchemaDataAccessConfigurator.isJoining(); assertTrue(joining); }
boolean isJoining = AppSchemaDataAccessConfigurator.isJoining(); boolean removeQueryLimitIfDenormalised = false; || mappedSource instanceof JDBCFeatureStore)) { if (AppSchemaDataAccessConfigurator.isJoiningSet()) { throw new IllegalArgumentException( "Joining queries are only supported on JDBC data stores");
schemaParser.setResolver(buildResolver()); for (Iterator it = schemaFiles.iterator(); it.hasNext(); ) { schemaLocation = (String) it.next(); final URL schemaUrl = resolveResourceLocation(baseUrl, schemaLocation); AppSchemaDataAccessConfigurator.LOGGER.fine( "parsing schema " + schemaUrl.toExternalForm());
validateConfiguredNamespaces(inputXPathSteps); if (inputXPath != null) { final StepList inputXPathSteps = XPath.steps(root, itemXpath + "/" + inputXPath, namespaces); validateConfiguredNamespaces(inputXPathSteps); validateConfiguredNamespaces(targetXPathSteps); final Expression idExpression = (idXpath == null) ? parseOgcCqlExpression(idExpr) : new AttributeExpressionImpl(idXpath, new Hints( FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, this.namespaces)); sourceExpression = (inputXPath == null) ? parseOgcCqlExpression(sourceExpr) : new AttributeExpressionImpl(inputXPath, new Hints( FeaturePropertyAccessorFactory.NAMESPACE_CONTEXT, this.namespaces)); final Map clientProperties = getClientProperties(attDto); Expression elementExpr = parseOgcCqlExpression(sourceElement); String sourceField = attDto.getLinkField(); StepList sourceFieldSteps = null; if (isJoining()) { attMapping = new JoiningNestedAttributeMapping(idExpression, sourceExpression, targetXPathSteps, isMultiValued, clientProperties, elementExpr,
parseGmlSchemas(); Map<String, DataAccess<FeatureType, Feature>> sourceDataStores = null; Set<FeatureTypeMapping> featureTypeMappings = null; try { sourceDataStores = acquireSourceDatastores(); featureTypeMappings = createFeatureTypeMappings(sourceDataStores); return featureTypeMappings; } finally { disposeUnusedSourceDataStores(sourceDataStores, featureTypeMappings);
@Test public void testJoiningFalse() { // test joining set to false AppSchemaDataAccessRegistry.getAppSchemaProperties() .setProperty(AppSchemaDataAccessConfigurator.PROPERTY_JOINING, "false"); boolean joining = AppSchemaDataAccessConfigurator.isJoining(); assertFalse(joining); AppSchemaDataAccessRegistry.clearAppSchemaProperties(); }
/** * Build the resolver (catalog plus cache) for this data access. */ private AppSchemaResolver buildResolver() { return new AppSchemaResolver(buildCatalog(), buildCache()); }
schemaParser.setResolver(buildResolver()); for (Iterator it = schemaFiles.iterator(); it.hasNext();) { schemaLocation = (String) it.next(); final URL schemaUrl = resolveResourceLocation(baseUrl, schemaLocation); AppSchemaDataAccessConfigurator.LOGGER.fine("parsing schema " + schemaUrl.toExternalForm());
public DataAccess<FeatureType, Feature> createDataStore( Map params, boolean hidden, DataAccessMap sourceDataStoreMap) throws IOException { Set<FeatureTypeMapping> mappings; AppSchemaDataAccess dataStore; URL configFileUrl = (URL) AppSchemaDataAccessFactory.URL.lookUp(params); XMLConfigDigester configReader = new XMLConfigDigester(); AppSchemaDataAccessDTO config = configReader.parse(configFileUrl); // load related types that are mapped separately, and not visible on their own // this is when the related types are not feature types, so they don't appear // on getCapabilities, and getFeature also shouldn't return anything etc. List<String> includes = config.getIncludes(); for (Iterator<String> it = includes.iterator(); it.hasNext(); ) { params.put("url", buildIncludeUrl(configFileUrl, it.next())); // this will register the related data access, to enable feature chaining; // sourceDataStoreMap is passed on to keep track of the already created source data // stores // and avoid creating the same data store twice (this enables feature iterators sharing // the same transaction to re-use the connection instead of opening a new one for each // joined type) createDataStore(params, true, sourceDataStoreMap); } mappings = AppSchemaDataAccessConfigurator.buildMappings(config, sourceDataStoreMap); dataStore = new AppSchemaDataAccess(mappings, hidden); return dataStore; }
public void setTargetValue(String targetValue) { try { this.targetValue = parseOgcCqlExpression(targetValue, filterFactory); } catch (Exception exception) { throw new RuntimeException( String.format("Error parsing target value expression '%s'.", targetValue), exception); } }
/** * Takes a config object and creates a set of mappings. * * <p> * In the process will parse xml schemas to geotools' Feature Model types and descriptors, * connect to source datastores and build the mapping objects from source FeatureTypes to the * target ones. * </p> * * @param config * DOCUMENT ME! * * @return a Set of {@link org.geotools.data.complex.FeatureTypeMapping} source to target * FeatureType mapping definitions * * @throws IOException * if any error occurs while creating the mappings */ public static Set<FeatureTypeMapping> buildMappings(AppSchemaDataAccessDTO config) throws IOException { AppSchemaDataAccessConfigurator mappingsBuilder; mappingsBuilder = new AppSchemaDataAccessConfigurator(config); Set<FeatureTypeMapping> mappingObjects = mappingsBuilder.buildMappings(); return mappingObjects; }
@Test public void testJoiningTrue() { // test joining set to true AppSchemaDataAccessRegistry.getAppSchemaProperties() .setProperty(AppSchemaDataAccessConfigurator.PROPERTY_JOINING, "true"); boolean joining = AppSchemaDataAccessConfigurator.isJoining(); assertTrue(joining); AppSchemaDataAccessRegistry.clearAppSchemaProperties(); } }
@Test public void testLoadMappingsConfig() throws Exception { XMLConfigDigester reader = new XMLConfigDigester(); final URL url = getClass().getResource(schemaBase + "mappedPolygons.xml"); AppSchemaDataAccessDTO config = reader.parse(url); Set mappings = AppSchemaDataAccessConfigurator.buildMappings(config); assertNotNull(mappings); assertEquals(1, mappings.size()); }