/** * Returns the same name than the feature type (ie, {@code getSchema().getName()} to honor the * simple feature land common practice of calling the same both the Features produces and their * types * * @since 1.7 * @see FeatureSource#getName() */ public Name getName() { return getSchema().getName(); }
/** * Returns the same name than the feature type (ie, {@code getSchema().getName()} to honor the * simple feature land common practice of calling the same both the Features produces and their * types * * @since 1.7 * @see FeatureSource#getName() */ public Name getName() { return getSchema().getName(); }
/** * Sets the feature type in which templates are loaded against. * * @deprecated use {@link #setFeatureType(FeatureTypeInfo)} */ public void setFeatureType(SimpleFeatureType featureType) { this.featureType = featureType; FeatureTypeInfo ft = catalog.getFeatureTypeByName(featureType.getName()); if (ft == null) { return; // throw new IllegalArgumentException("No feature type named " + featureType.getName() + // " in catalog"); } setFeatureType(ft); }
/** * Given a feature id following the <typename>.<internalId> convention, the original type and * the destination type, this converts the id from <original>.<internalid> to * <target>.<internalid> * * @param id * @param original * @param target */ public static FeatureId reTypeId( FeatureId sourceId, SimpleFeatureType original, SimpleFeatureType target) { final String originalTypeName = original.getName().getLocalPart(); final String destTypeName = target.getName().getLocalPart(); if (destTypeName.equals(originalTypeName)) return sourceId; final String prefix = originalTypeName + "."; if (sourceId.getID().startsWith(prefix)) { return new FeatureIdImpl( destTypeName + "." + sourceId.getID().substring(prefix.length())); } else return sourceId; }
public SimpleFeature next() throws NoSuchElementException { final SimpleFeature next = delegate.next(); // check all write protected attributes are null final SimpleFeatureType featureType = next.getFeatureType(); for (AttributeDescriptor att : featureType.getAttributeDescriptors()) { String name = att.getLocalName(); if (!writableAttributes.contains(name)) { Object value = next.getAttribute(name); if (value != null) { String typeName = getSchema().getName().getLocalPart(); if (response == Response.CHALLENGE) { throw SecureCatalogImpl.unauthorizedAccess(typeName); } else { throw new UnsupportedOperationException( "Trying to write on the write protected attribute " + name); } } } } return next; } }
/** * Flattens a SimpleFeatureCollection that may contain SimpleFeatures as attributes of other * features. * * @param collection The input SimpleFeatureCollection * @return A SimpleFeatureCollection whose features have no SimpleFeature attributes, or the * original one, if no SimpleFeature attributes were found */ public static SimpleFeatureCollection flatten(SimpleFeatureCollection collection) { SimpleFeatureType schema = collection.getSchema(); // collect the attributes List<AttributeDescriptor> attributeDescriptors = new ArrayList<AttributeDescriptor>(); scanAttributeDescriptors(attributeDescriptors, schema, null); // build the flattened feature type SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(schema.getName()); for (AttributeDescriptor desc : attributeDescriptors) builder.add(desc); SimpleFeatureType flattenedType = builder.buildFeatureType(); // if the number of attributes is the same, we did not encounter a new attribute if (collection.getSchema().getAttributeCount() == flattenedType.getAttributeCount()) { return collection; } return new FlatteningFeatureCollection(collection, flattenedType); }
String typeName = getSchema().getName().getLocalPart(); if (policy.getResponse() == org.geoserver.security.Response.CHALLENGE) { throw SecureCatalogImpl.unauthorizedAccess(typeName);
String typeName = getSchema().getName().getLocalPart(); if (policy.getResponse() == Response.CHALLENGE) { throw SecureCatalogImpl.unauthorizedAccess(typeName);
@Test public void testLookupFeatureType() throws Exception { try { rts.getSchema(MockData.BUILDINGS.getLocalPart()); fail("The original type name should not be visible"); } catch (IOException e) { // cool, as expected } final SimpleFeatureType schema = rts.getSchema(RENAMED); assertNotNull(schema); assertEquals(RENAMED, schema.getName().getLocalPart()); }
baseDirName = "featureTypes"; String name = featureType.getTypeName(); String namespace = featureType.getName().getNamespaceURI(); FeatureTypeInfo ftInfo = null; if (catalog != null && namespace != null) { if (featureType.getName().getNamespaceURI() != null) { nsInfo = catalog.getNamespaceByURI(featureType.getName().getNamespaceURI());
@Test public void testGetFeaturesFeatureSource() throws Exception { // check the schemas in feature source and feature collection SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); assertEquals(RENAMED, fs.getSchema().getName().getLocalPart()); SimpleFeatureCollection fc = fs.getFeatures(); assertEquals(RENAMED, fc.getSchema().getName().getLocalPart()); assertTrue(fc.size() > 0); // make sure the feature schema is good as well FeatureIterator<SimpleFeature> it = fc.features(); SimpleFeature sf = it.next(); it.close(); assertEquals(RENAMED, sf.getFeatureType().getName().getLocalPart()); // check the feature ids have been renamed as well assertTrue( "Feature id has not been renamed, it's still " + sf.getID(), sf.getID().startsWith(RENAMED)); }
@Test public void testGetFeaturesReader() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED), Transaction.AUTO_COMMIT); SimpleFeature sf = fr.next(); fr.close(); assertEquals(RENAMED, sf.getFeatureType().getName().getLocalPart()); // check the feature ids have been renamed as well assertTrue( "Feature id has not been renamed, it's still " + sf.getID(), sf.getID().startsWith(RENAMED)); }
@Test public void testRemoteType() throws Exception { SimpleFeatureType ft = DataUtilities.createType( "remoteType", "the_geom:MultiPolygon,FID:String,ADDRESS:String"); GeoServerDataDirectory dd = createDataDirectoryMock(); Catalog cat = createNiceMock(Catalog.class); expect(cat.getFeatureTypeByName(ft.getName())).andReturn(null).once(); replay(dd, cat); GeoServerTemplateLoader tl = new GeoServerTemplateLoader(getClass(), dd); tl.setCatalog(cat); tl.setFeatureType(ft); tl.findTemplateSource("header.ftl"); verify(cat); } }
/** * Returns the same name than the feature type (ie, {@code getSchema().getName()} to honor the * simple feature land common practice of calling the same both the Features produces and their * types * * @since 2.5 * @see FeatureSource#getName() */ public Name getName() { return getSchema().getName(); }
&& descriptor.getEndAttribute() == null) { GranuleSource gs = sr.getGranules(name, true); final Query query = new Query(gs.getSchema().getName().getLocalPart());
@Override public SimpleFeatureSource getFeatureSource(String typeName) throws IOException { SimpleFeatureType schema = source.getSchema(); if (schema.getName().getLocalPart().equals(typeName)) { return source; } else { throw new IOException("Schema '" + typeName + "' does not exist."); } }
@Test public void testFeautureReaderFidFilter() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED, fidFilter), Transaction.AUTO_COMMIT); assertEquals(RENAMED, fr.getFeatureType().getName().getLocalPart()); assertTrue(fr.hasNext()); SimpleFeature sf = fr.next(); assertFalse(fr.hasNext()); fr.close(); assertEquals(fid, sf.getID()); }
@Test public void testFeautureSourceFidFilter() throws Exception { // grab the last feature in the collection (there are more than one) SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); // build a filter that will retrieve that feature only FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); final String fid = RENAMED + ".1107531701011"; Filter fidFilter = ff.id(Collections.singleton(ff.featureId(fid))); SimpleFeatureCollection fc = fs.getFeatures(new Query(RENAMED, fidFilter)); assertEquals(RENAMED, fc.getSchema().getName().getLocalPart()); assertEquals(1, fc.size()); FeatureIterator<SimpleFeature> it = fc.features(); assertTrue(it.hasNext()); SimpleFeature sf = it.next(); assertFalse(it.hasNext()); it.close(); assertEquals(fid, sf.getID()); }
@Test public void testFeautureSourceFidFilter() throws Exception { // grab the last feature in the collection (there are more than one) SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); // build a filter that will retrieve that feature only FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); final String fid = RENAMED + ".f001"; Filter fidFilter = ff.id(Collections.singleton(ff.featureId(fid))); SimpleFeatureCollection fc = fs.getFeatures(new Query(RENAMED, fidFilter)); assertEquals(RENAMED, fc.getSchema().getName().getLocalPart()); assertEquals(1, fc.size()); FeatureIterator<SimpleFeature> it = fc.features(); assertTrue(it.hasNext()); SimpleFeature sf = it.next(); assertFalse(it.hasNext()); it.close(); assertEquals(fid, sf.getID()); }
/** * Returns the expose primary key columns flag for the specified feature type * * @param featureType * @return * @throws IOException */ protected boolean isExposePrimaryKeyColumns(SimpleFeatureType featureType) throws IOException { ContentEntry entry = ensureEntry(featureType.getName()); JDBCState state = (JDBCState) entry.getState(Transaction.AUTO_COMMIT); return state.isExposePrimaryKeyColumns(); }