final String alias = info.getName();
final SimpleFeatureType nativeFeatureType = dataStore.getSchema( typeName );
final SimpleFeatureType featureType = (SimpleFeatureType) getFeatureType( info );
if ( !typeName.equals( alias ) || DataUtilities.compare(nativeFeatureType,featureType) != 0 ) {
RetypingDataStore retyper = new RetypingDataStore(dataStore) {
@Override
protected String transformFeatureTypeName(String originalName) {
if(!typeName.equals(originalName))
return originalName;
return alias;
}
@Override
protected SimpleFeatureType transformFeatureType(SimpleFeatureType original)
throws IOException {
if ( original.getTypeName().equals( typeName ) ) {
return featureType;
}
return super.transformFeatureType(original);
}
};
fs = retyper.getFeatureSource(alias);
}
else {
//normal case
fs = dataStore.getFeatureSource(info.getQualifiedName());
}