public DataAccess<T, F> getDataStore() { return delegate.getDataStore(); }
public DataAccess<T, F> getDataStore() { final DataAccess<T, F> store = delegate.getDataStore(); if (store == null) return null; else return (DataAccess) SecuredObjects.secure(store, policy); }
@Override public DataAccess getDataStore() { return originalFeatureSource.getDataStore(); }
public DataAccess<SimpleFeatureType, SimpleFeature> getDataStore() { return delegate.getDataStore(); }
/** * Wraps a {@link FeatureSource} in a {@link LayerInfo} containing a {@link FeatureTypeInfo}. * * @param featureSource the feature source to be wrapped * @return The wrapping layer */ protected LayerInfo getLayerFromFeatureSource(final FeatureSource featureSource) { // TODO: Wrap info from GeoTools {@link FeatureSource#getInfo()} for GetFeatureInfo, etc. FeatureTypeInfoImpl featureTypeInfo = null; try { featureTypeInfo = new FeatureSourceWrappingFeatureTypeInfoImpl(featureSource); } catch (IOException | TransformException | FactoryException e) { throw new IllegalStateException("Error constructing wrapping feature source", e); } featureTypeInfo.setName(featureSource.getName().getLocalPart()); featureTypeInfo.setEnabled(true); featureTypeInfo.setCatalog(catalog); LayerInfo layerInfo = catalog.getFactory().createLayer(); layerInfo.setResource(featureTypeInfo); layerInfo.setEnabled(true); // CollectionFeatureSource doesn't support getDataStore if (!(featureSource instanceof CollectionFeatureSource) && featureSource.getDataStore() instanceof WFSDataStore) { layerInfo.setType(PublishedType.REMOTE); } else { layerInfo.setType(PublishedType.VECTOR); } return layerInfo; }
public synchronized DataAccess<FeatureType, Feature> access(Name name) { try { return featureSource(name).getDataStore(); } catch (IOException e) { return null; } }
public JdbcMultipleValueEncoder(FeatureTypeMapping typeMapping, Writer output) { this.store = (JDBCDataStore) typeMapping.getSource().getDataStore(); this.output = output; }
public void dispose() { DataAccessRegistry.unregister(this); // dispose all the source data stores for (FeatureTypeMapping mapping : mappings.values()) { mapping.getSource().getDataStore().dispose(); } mappings.clear(); }
public static DataAccess<FeatureType, Feature> getDataAccess(Name featureTypeName) throws IOException { return getInstance().featureSource(featureTypeName).getDataStore(); }
@Override public List<PropertyName> getSurrogatePropertyNames( List<PropertyName> requested, FeatureTypeMapping featureTypeMapping) { // let's se if this is a feature type coming from MongoDB if (!(featureTypeMapping.getSource() != null && featureTypeMapping.getSource().getDataStore() instanceof MongoDataStore)) { // not a MongoDB feature type mapping return Collections.emptyList(); } // let's iterate over the requested properties and try to get the matching JSON path List<PropertyName> properties = new ArrayList<>(); for (PropertyName propertyName : requested) { // get the JSON path matching the current requested property properties.addAll(extractJsonPaths(featureTypeMapping, propertyName)); } return properties; }
boolean usedDataAccess = false; for (FeatureTypeMapping mapping : featureTypeMappings) { if (mapping.getSource().getDataStore() == dataAccess || (mapping.getIndexSource() != null && Objects.equals( mapping.getIndexSource().getDataStore(), dataAccess))) { usedDataAccess = true; break;
@Override public DataAccessMappingFeatureIterator buildIterator( AppSchemaDataAccess store, FeatureTypeMapping featureTypeMapping, Query query, Transaction transaction) { // let's se if this is a feature type coming from MongoDB if (!(featureTypeMapping.getSource() != null && featureTypeMapping.getSource().getDataStore() instanceof MongoDataStore)) { // not a MongoDB feature type mapping return null; } try { // we consider that data coming from MongoDB is always normalized return new DataAccessMappingFeatureIterator( store, featureTypeMapping, query, false, true); } catch (Exception exception) { throw new RuntimeException( "Error creating App-Schema iterator for MongoDB data store.", exception); } }
private StringBuffer encodeSelectKeyFrom(FeatureChainLink lastMappingStep) throws SQLException { FeatureTypeMapping lastTypeMapping = lastMappingStep.getFeatureTypeMapping(); JDBCDataStore store = (JDBCDataStore) lastTypeMapping.getSource().getDataStore(); SimpleFeatureType lastType = (SimpleFeatureType) lastTypeMapping.getSource().getSchema();
private WrappedFilterToSql createFilterToSQL(FeatureTypeMapping featureMapping) { JDBCDataStore store = (JDBCDataStore) featureMapping.getSource().getDataStore(); SimpleFeatureType sourceType = (SimpleFeatureType) featureMapping.getSource().getSchema(); FilterToSQL filterToSQL = null; if (store.getSQLDialect() instanceof PreparedStatementSQLDialect) { PreparedFilterToSQL preparedFilterToSQL = store.createPreparedFilterToSQL(sourceType); // disable prepared statements to have literals actually encoded in the SQL preparedFilterToSQL.setPrepareEnabled(false); filterToSQL = preparedFilterToSQL; } else { filterToSQL = store.createFilterToSQL(sourceType); } return new WrappedFilterToSql(featureMapping, filterToSQL); }
private void createWhereClause( Filter filter, String nestedProperty, FeatureChainedAttributeDescriptor nestedAttrDescr, StringBuffer sql) throws FilterToSQLException { FeatureChainLink lastLink = nestedAttrDescr.getLastLink(); String simpleProperty = nestedAttrDescr.getAttributePath().toString(); FeatureTypeMapping featureMapping = lastLink.getFeatureTypeMapping(); JDBCDataStore store = (JDBCDataStore) featureMapping.getSource().getDataStore(); FeatureTypeMapping featureMappingForUnrolling = nestedAttrDescr.getFeatureTypeOwningAttribute(); NamespaceAwareAttributeRenameVisitor duplicate = new NamespaceAwareAttributeRenameVisitor(nestedProperty, simpleProperty); Filter duplicated = (Filter) filter.accept(duplicate, null); Filter unrolled = unrollFilter(duplicated, featureMappingForUnrolling); JoiningFieldEncoder fieldEncoder = new JoiningFieldEncoder(lastLink.getAlias(), store); WrappedFilterToSql filterToSQL = createFilterToSQL(featureMapping); filterToSQL.setFieldEncoder(fieldEncoder); String encodedFilter = filterToSQL.encodeToString(unrolled); sql.append(" ").append(encodedFilter); }
mapping.getSource().getDataStore().dispose();
assertEquals(guSourceFs.getDataStore(), cpMapping.getSource().getDataStore()); assertEquals(guSourceFs.getDataStore(), ccMapping.getSource().getDataStore()); assertEquals(guSourceFs.getDataStore(), cgiMapping.getSource().getDataStore()); assertNotEquals(guSourceFs.getDataStore(), mfSourceFs.getDataStore());
/** @throws IOException */ @Test public void testCreateDataStore() throws IOException { DataAccess<FeatureType, Feature> ds = factory.createDataStore(params); assertNotNull(ds); FeatureSource<FeatureType, Feature> mappedSource = ds.getFeatureSource(mappedTypeName); assertNotNull(mappedSource); assertSame(ds, mappedSource.getDataStore()); ds.dispose(); }
private void encodeJoinCondition( FeatureChainedAttributeDescriptor nestedAttrDescr, int stepIdx, StringBuffer sql) throws SQLException, IOException, FilterToSQLException { FeatureChainLink parentStep = nestedAttrDescr.getLink(stepIdx); FeatureChainLink nestedStep = nestedAttrDescr.getLink(stepIdx + 1); FeatureTypeMapping parentFeature = parentStep.getFeatureTypeMapping(); JDBCDataStore store = (JDBCDataStore) parentFeature.getSource().getDataStore(); NestedAttributeMapping nestedFeatureAttr = parentStep.getNestedFeatureAttribute(); FeatureTypeMapping nestedFeature = nestedFeatureAttr.getFeatureTypeMapping(null); String parentTableName = parentFeature.getSource().getSchema().getName().getLocalPart(); String parentTableAlias = parentStep.getAlias(); WrappedFilterToSql parentToSQL = createFilterToSQL(parentFeature); // don't escape, as it will be done by the encodeColumn methods parentToSQL.setSqlNameEscape(""); Expression parentExpression = nestedFeatureAttr.getSourceExpression(); String parentTableColumn = parentToSQL.encodeToString(parentExpression); String nestedTableAlias = nestedStep.getAlias(); WrappedFilterToSql nestedFilterToSQL = createFilterToSQL(parentFeature); // don't escape, as it will be done by the encodeColumn methods nestedFilterToSQL.setSqlNameEscape(""); Expression nestedExpr = nestedFeatureAttr.getMapping(nestedFeature).getSourceExpression(); String nestedTableColumn = nestedFilterToSQL.encodeToString(nestedExpr); if (stepIdx == 0) { encodeColumnName(store, parentTableColumn, parentTableName, sql, null); } else { encodeAliasedColumnName(store, parentTableColumn, parentTableAlias, sql, null); } sql.append(" = "); encodeAliasedColumnName(store, nestedTableColumn, nestedTableAlias, sql, null); }
/** * Tests that registry works. * * @param dataAccess The app schema data access to check * @param typeName Feature type * @param isNonFeature true if the type is non feature * @throws IOException */ private void checkRegisteredDataAccess( AppSchemaDataAccess dataAccess, Name typeName, boolean isNonFeature) throws IOException { FeatureTypeMapping mapping = AppSchemaDataAccessRegistry.getMappingByName(typeName); assertNotNull(mapping); // compare with the supplied data access assertEquals(dataAccess.getMappingByName(typeName).equals(mapping), true); if (isNonFeature) { assertTrue(mapping.getTargetFeature().getType() instanceof NonFeatureTypeProxy); } // should return a simple feature source FeatureSource<FeatureType, Feature> source = AppSchemaDataAccessRegistry.getMappingByName(typeName).getSource(); assertNotNull(source); assertEquals(mapping.getSource(), source); // should return a mapping feature source FeatureSource<FeatureType, Feature> mappedSource = DataAccessRegistry.getFeatureSource(typeName); assertNotNull(mappedSource); // compare with the supplied data access assertTrue(mappedSource.getDataStore().equals(dataAccess)); }