public Abstract(String typeName, URI namespace, Collection types, Collection superTypes, GeometryAttributeType defaultGeom) throws SchemaException { super(typeName, namespace, types, superTypes, defaultGeom); Iterator st = superTypes.iterator(); while (st.hasNext()) { FeatureType ft = (FeatureType) st.next(); if (!ft.isAbstract()) { throw new SchemaException( "Abstract type cannot descend from no abstract type : " + ft); } } }
if (isAbstract() && !type.isAbstract()) { throw new RuntimeException( "FeatureTypeFactory poorly implemented, "
if (isAbstract() && !type.isAbstract()) { throw new RuntimeException( "FeatureTypeFactory poorly implemented, "
public FeatureType getSchema(String typeName) throws IOException { FeatureType ft = wrapped.getSchema(typeName); if(!isVersioned(typeName)) { return ft; } // if the feature type is versioned, we have to map the internal feature // type to an outside vision where versioned and pk columns are not // included Set names = new HashSet(Arrays.asList(filterPropertyNames(new DefaultQuery(typeName)))); List filtered = new ArrayList(); for (int i = 0; i < ft.getAttributeCount(); i++) { AttributeType cat = ft.getAttributeType(i); String name = cat.getName().toLowerCase(); if (names.contains(name)) { filtered.add(cat); } } AttributeType[] ats = (AttributeType[]) filtered .toArray(new AttributeType[filtered.size()]); try { return FeatureTypeBuilder.newFeatureType(ats, ft.getTypeName(), ft.getNamespace(), ft .isAbstract(), ft.getAncestors(), ft.getDefaultGeometry()); } catch (SchemaException e) { throw new DataSourceException( "Error converting FeatureType from versioned (internal) schema " + "to unversioned (external) schema " + typeName, e); } }
public FeatureCollection getVersionedFeatures(Query query) throws IOException { final FeatureType ft = getSchema(); // check the feature type is the right one final String typeName = ft.getTypeName(); if(query.getTypeName() != null && !query.getTypeName().equals(typeName)) throw new IOException("Incompatible type, this class can access only " + typeName); // make sure the view is around if(!Arrays.asList(store.wrapped.getTypeNames()).contains(store.getVFCViewName(typeName))) store.createVersionedFeatureCollectionView(typeName); // we have to hit the view DefaultQuery vq = new DefaultQuery(query); vq.setTypeName(VersionedPostgisDataStore.getVFCViewName(typeName)); vq = store.buildVersionedQuery(vq); FeatureCollection fc = store.wrapped.getFeatureSource(VersionedPostgisDataStore.getVFCViewName(typeName)).getFeatures(vq); try { final FeatureType fcSchema = fc.getSchema(); FeatureType renamedFt = FeatureTypes.newFeatureType(fcSchema.getAttributeTypes(), ft.getTypeName(), ft.getNamespace(), ft.isAbstract(), ft.getAncestors(), fcSchema.getDefaultGeometry()); return new ReTypingFeatureCollection(fc, renamedFt); } catch(SchemaException e) { throw new DataSourceException("Error ranming feature type", e); } }