/** * Parses a complex datastore configuration file in xml format into a {@link * AppSchemaDataAccessDTO} * * @param dataStoreConfigUrl config file location * @return a DTO object representing the datastore's configuration * @throws IOException if an error occurs parsing the file */ public AppSchemaDataAccessDTO parse(URL dataStoreConfigUrl) throws IOException { AppSchemaDataAccessDTO config = digest(dataStoreConfigUrl); return config; }
protected boolean isOrUnionReplacementEnabled() { return AppSchemaDataAccessConfigurator.isOrUnionReplacementEnabled(); } }
/** * 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; }
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; }
@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()); }
@Test public void testGML32Declared() { AppSchemaFeatureTypeRegistry registry = new AppSchemaFeatureTypeRegistry(gml32NS); registry.addSchemas(schemaIndex); AttributeType type = registry.getAttributeType(BOREHOLE_TYPE); assertTrue(type instanceof FeatureType); }
parseGmlSchemas(); Map<String, DataAccess<FeatureType, Feature>> sourceDataStores = null; Set<FeatureTypeMapping> featureTypeMappings = null; try { sourceDataStores = acquireSourceDatastores(); featureTypeMappings = createFeatureTypeMappings(sourceDataStores); return featureTypeMappings; } finally { disposeUnusedSourceDataStores(sourceDataStores, featureTypeMappings); typeRegistry.disposeSchemaIndexes(); typeRegistry = null;
private AppSchemaDataAccess buildDataAccess(String mappingsFileName) throws Exception { // generate the path to a mappings-file in the resources directory String configFilePath = extendFilename(testDir.getPath(), mappingsFileName); URL configFileUrl = URLs.fileToUrl(new File(configFilePath)); // parse the mappings-file XMLConfigDigester configReader = new XMLConfigDigester(); AppSchemaDataAccessDTO config = configReader.parse(configFileUrl); // generate the set of mappings needed to build the application-schema datastore Set<FeatureTypeMapping> mappings; mappings = AppSchemaDataAccessConfigurator.buildMappings(config); AppSchemaDataAccess datastore = new AppSchemaDataAccess(mappings); return datastore; }
private AttributeDescriptor getTargetDescriptor(TypeMapping dto, CoordinateReferenceSystem crs) throws IOException { String prefixedTargetName = dto.getTargetElementName(); Name targetNodeName = Types.degloseName(prefixedTargetName, namespaces); AttributeDescriptor targetDescriptor = typeRegistry.getDescriptor(targetNodeName, crs); if (targetDescriptor == null) { throw new NoSuchElementException( "descriptor " + targetNodeName + " not found in parsed schema"); } // check if default geometry was set in FeatureTypeMapping // NOTE: if a default geometry is already set, it will be overridden String defaultGeomXPath = dto.getDefaultGeometryXPath(); if (defaultGeomXPath != null && !defaultGeomXPath.isEmpty()) { targetDescriptor = retypeAddingDefaultGeometry(targetDescriptor, defaultGeomXPath); } return targetDescriptor; }
/** * 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); }
/** Build the resolver (catalog plus cache) for this data access. */ private SchemaResolver buildResolver() { return new SchemaResolver(buildCatalog(), buildCache()); }
private void setSourceDataStoresRules(Digester digester) { final String dataStores = "AppSchemaDataAccess/sourceDataStores"; digester.addObjectCreate(dataStores, XMLConfigDigester.CONFIG_NS_URI, ArrayList.class); setCommonSourceDataStoreRules(SourceDataStore.class, "DataStore", digester); // extension point allowing data sources to provide a custom syntax for their configuration extensions.forEach(extension -> extension.configXmlDigesterDataSources(digester)); // set the list of SourceDataStores for ComlexDataStoreDTO digester.addSetNext(dataStores, "setSourceDataStores"); }
@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); }
/** * Helper method to allow config digester passing a string. * * @see #setMultiple(boolean) * @param isMultiple */ public void setMultiple(String isMultiple) { boolean multiple = Boolean.valueOf(isMultiple).booleanValue(); setMultiple(multiple); }
/** * Helper method to allow config digester passing a string. * * @see #setList(boolean) * @param isList */ public void setList(String list) { boolean isList = Boolean.valueOf(list).booleanValue(); setList(isList); }
/** * Create the test directory. * * @see junit.framework.TestCase#setUp() */ @Before public void setUp() throws IOException { FileUtils.deleteDirectory(testDir); // copy all the test data into the test directory copyTestData("ArchSite.xsd", testDir); copyTestData("ArchSiteNillable.xml", testDir); copyTestData("AppSchemaFileDataTest.xml", testDir); copyTestData("PointFeatureGeomPropertyfile.properties", new File(testDir, "directory")); }
/** * Test that mappings are loaded OK. * * @throws Exception */ @Test public void testLoadMappingsConfig() throws Exception { XMLConfigDigester reader = new XMLConfigDigester(); final URL url = getClass().getResource(schemaBase + "GeologicUnit.xml"); AppSchemaDataAccessDTO config = reader.parse(url); Set mappings = AppSchemaDataAccessConfigurator.buildMappings(config); assertNotNull(mappings); assertEquals(1, mappings.size()); }
@Test public void testGML32Undeclared() { // GEOT-4756: no namespace support provided.. due to namespaces not set in // mapping file. This is legitimate if the mapping doesn't use any GML attributes. // Previously, this won't work. AppSchemaFeatureTypeRegistry registry = new AppSchemaFeatureTypeRegistry(); registry.addSchemas(schemaIndex); AttributeType type = registry.getAttributeType(BOREHOLE_TYPE); assertTrue(type instanceof FeatureType); } }
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); } }