* @return the minimum set of attribute names needed to render
* <code>layer</code>
*/
private List<PropertyName> findStyleAttributes(LiteFeatureTypeStyle[] styles,
FeatureType schema) {
final StyleAttributeExtractor sae = new StyleAttributeExtractor();
LiteFeatureTypeStyle lfts;
Rule[] rules;
int rulesLength;
final int length = styles.length;
for (int t = 0; t < length; t++) {
lfts = styles[t];
rules = lfts.elseRules;
rulesLength = rules.length;
for (int j = 0; j < rulesLength; j++) {
sae.visit(rules[j]);
}
rules = lfts.ruleList;
rulesLength = rules.length;
for (int j = 0; j < rulesLength; j++) {
sae.visit(rules[j]);
}
}
if(sae.isUsingDynamincProperties()) {
return null;
}
Set<PropertyName> attributes = sae.getAttributes();
Set<String> attributeNames = sae.getAttributeNameSet();
/*
* DJB: this is an old comment - erase it soon (see geos-469 and below) -
* we only add the default geometry if it was used.
*
* GR: if as result of sae.getAttributeNames() ftsAttributes already
* contains geometry attribute names, they gets duplicated, which produces
* an error in AbstracDatastore when trying to create a derivate
* SimpleFeatureType. So I'll add the default geometry only if it is not
* already present, but: should all the geometric attributes be added by
* default? I will add them, but don't really know what's the expected
* behavior
*/
List<PropertyName> atts = new ArrayList<PropertyName>(attributes);
Collection<PropertyDescriptor> attTypes = schema.getDescriptors();
Name attName;
for (PropertyDescriptor pd : attTypes) {
//attName = pd.getName().getLocalPart();
attName = pd.getName();
// DJB: This geometry check was commented out. I think it should
// actually be back in or
// you get ALL the attributes back, which isn't what you want.
// ALX: For rasters I need even the "grid" attribute.
// DJB:geos-469, we do not grab all the geometry columns.
// for symbolizers, if a geometry is required it is either
// explicitly named
// ("<Geometry><PropertyName>the_geom</PropertyName></Geometry>")
// or the default geometry is assumed (no <Geometry> element).
// I've modified the style attribute extractor so it tracks if the
// default geometry is used. So, we no longer add EVERY geometry
// column to the query!!
if ((attName.getLocalPart().equalsIgnoreCase("grid"))
&& !attributeNames.contains(attName.getLocalPart())
|| (attName.getLocalPart().equalsIgnoreCase("params"))
&& !attributeNames.contains(attName.getLocalPart())
) {
atts.add(filterFactory.property (attName));
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine("added attribute " + attName);
}
}
try {
// DJB:geos-469 if the default geometry was used in the style, we
// need to grab it.
if (sae.getDefaultGeometryUsed()
&& (!attributeNames.contains(schema.getGeometryDescriptor().getName().toString()))
) {
atts.add(filterFactory.property ( schema.getGeometryDescriptor().getName() ));
}
} catch (Exception e) {