JoinInfo info = new JoinInfo();
info.setPrimaryAlias("a");
for (int i = 0; i < query.getJoins().size(); i++) {
Join j = query.getJoins().get(i);
JoinPart part = new JoinPart(j);
info.getParts().add(part);
//load the feature type being joined to
JDBCFeatureSource joinFeatureSource = dataStore.getAbsoluteFeatureSource(j.getTypeName());
part.setFeatureSource(joinFeatureSource);
//ensure every join as a unique alias
String alias = String.valueOf((char)('b' + i));
part.setAlias(alias);
//hack on the join filter as necessary
Filter joinFilter = j.getJoinFilter();
Map<String, String> mappings = new HashMap<String, String>();
if (query.getAlias() != null) {
//rewrite any user specified alias with the one we specified
mappings.put(query.getAlias(), "a");
}
if (j.getAlias() != null) {
//rewrite any user specified alias with the one we specified
mappings.put(j.getAlias(), alias);
}
if (!mappings.isEmpty()) {
joinFilter = (Filter) joinFilter.accept(new JoinPrefixRewriter(mappings), null);
}
//qualify all property names in the join filter so that they known about their
// feature type and alias
joinFilter = (Filter) joinFilter.accept(new JoinQualifier(featureType, "a",
joinFeatureSource.getSchema(), alias), null);
part.setJoinFilter(joinFilter);
//split the other filter
Filter[] prePostFilters = joinFeatureSource.splitFilter(j.getFilter());
//build the query and return feature types based on the post filter
SimpleFeatureType[] types = joinFeatureSource.buildQueryAndReturnFeatureTypes(
joinFeatureSource.getSchema(), j.getPropertyNames(), prePostFilters[1]);
//alias any attributes in this feature type that clash with attributes in the primary
// feature type
types[0] = SimpleFeatureTypeBuilder.copy(types[0]);
for (AttributeDescriptor att : types[0].getAttributeDescriptors()) {