public static Set ancestors( FeatureType featureType ) { if (featureType == null || featureType.getAncestors() == null || featureType.getAncestors().length == 0) { return Collections.EMPTY_SET; } return new HashSet(Arrays.asList(featureType.getAncestors())); }
public static boolean isDecendedFrom( FeatureType featureType, FeatureType isParentType ) { if (featureType == null || isParentType == null) return false; FeatureType ancestors[] = featureType.getAncestors(); if (ancestors != null) { TEST: for( int i = 0; i < ancestors.length; i++ ) { FeatureType ancestor = ancestors[i]; if (isParentType == ancestor) return true; if (false) { // hack idea #1? if (isParentType.getNamespace().equals(ancestor.getNamespace())) { continue TEST; } if (isParentType.equals(ancestor.getTypeName())) { continue TEST; } return true; // match based on namespace, typeName } } } return false; }
if (featureType == null) return false; FeatureType ancestors[] = featureType.getAncestors(); if (ancestors != null) { TEST: for( int i = 0; i < ancestors.length; i++ ) {
/** * This order is to be respected, based on Ancestors and so on. * <p> * This method is "faster" then actually constructing the merged * AttribtueTypes. * </p> */ public List getNames( FeatureType featureType, List names ){ if( featureType == null || featureType.getAttributeTypes() == null ){ return names; } FeatureType ancestors[] = featureType.getAncestors(); if( ancestors != null && ancestors.length != 0 ){ for( int i=0, length = ancestors.length; i<length; i++ ){ FeatureType superType = ancestors[i]; getNames( superType, names ); } } AttributeType attributes[] = featureType.getAttributeTypes(); if( attributes != null && attributes.length != 0 ){ for( int i=0, length = attributes.length; i<length; i++ ){ AttributeType type = attributes[i]; String name = type.getName(); if( !names.contains( name )){ names.add( name ); } } } return names; }
FeatureType ancestors[] = featureType.getAncestors(); if( ancestors != null && ancestors.length != 0 ){ for( int i=0, length = ancestors.length; i<length; i++ ){
private Filter restriction( FeatureType featureType, String name, Filter filter ){ FeatureType ancestors[] = featureType.getAncestors(); if( ancestors != null && ancestors.length != 0 ){ for( int i=0, length = ancestors.length; i<length; i++ ){ FeatureType superType = ancestors[i]; filter = restriction( superType, name, filter ); } } AttributeType attributes[] = featureType.getAttributeTypes(); if( attributes != null && attributes.length != 0 ){ for( int i=0, length = attributes.length; i<length; i++ ){ AttributeType type = attributes[i]; if( name.equals( type.getName() )){ filter = override( filter, type.getRestriction() ); } } } return filter; }
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); } }
builder.setDefaultGeometry(original.getDefaultGeometry()); FeatureType[] ancestors = original.getAncestors();
builder.setDefaultGeometry(original.getGeometryDescriptor()); FeatureType[] ancestors = original.getAncestors();
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); } }