[Geoserver-devel] Proposing couple CatalogBuilder changes

Hi,
I've noticed in a couple of places I added code that looks like

CatalogBuilder builder = new CatalogBuilder(catalog);
builder.setStore(store);
if (store instanceof CoverageStoreInfo) {
     CoverageStoreInfo cstore = (CoverageStoreInfo) store;
     AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) getCatalog().getResourcePool().getGridCoverageReader(cstore, null);
     CoverageInfo ci = builder.buildCoverage(reader);
     return builder.buildLayer(ci);
} else if (store instanceof DataStoreInfo) {
     DataStoreInfo dstore = (DataStoreInfo) store;
     FeatureTypeInfo fti = builder.buildFeatureType(dstore.getDataStore(null)
             .getFeatureSource(resource.getName()));
     return builder.buildLayer(fti);
}

Hmmm... the builder should already have the information
to build a coverage or a specific type once the
store is set and the resource is named, going shopping
for readers and feature sources seems like a concern
the client code should not have?

What about adding:
builder.buildCoverage() // builds the default coverage
builder.buildFeatureType(Name)

or to have a more future proof method:
builder.buildCoverage(Name)
that can be called with "null" also.

Finally, wouldn't it be nicer if the buidler
could accept a ResourceInfo in buildLayer
and figure out by itself how to handle it internally?

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Hi Andrea,

The changes seem good to me. I do think the class will quite quickly become a grab bag of a bunch of different stuff but i am happy as long as that stuff is contained to a single class. Some decent javadocs on each of the methods with its assumptions should help us refactor it later into something more coherent.

+1 on the changes.

-Justin

Andrea Aime wrote:

Hi,
I've noticed in a couple of places I added code that looks like

CatalogBuilder builder = new CatalogBuilder(catalog);
builder.setStore(store);
if (store instanceof CoverageStoreInfo) {
     CoverageStoreInfo cstore = (CoverageStoreInfo) store;
     AbstractGridCoverage2DReader reader = (AbstractGridCoverage2DReader) getCatalog().getResourcePool().getGridCoverageReader(cstore, null);
     CoverageInfo ci = builder.buildCoverage(reader);
     return builder.buildLayer(ci);
} else if (store instanceof DataStoreInfo) {
     DataStoreInfo dstore = (DataStoreInfo) store;
     FeatureTypeInfo fti = builder.buildFeatureType(dstore.getDataStore(null)
             .getFeatureSource(resource.getName()));
     return builder.buildLayer(fti);
}

Hmmm... the builder should already have the information
to build a coverage or a specific type once the
store is set and the resource is named, going shopping
for readers and feature sources seems like a concern
the client code should not have?

What about adding:
builder.buildCoverage() // builds the default coverage
builder.buildFeatureType(Name)

or to have a more future proof method:
builder.buildCoverage(Name)
that can be called with "null" also.

Finally, wouldn't it be nicer if the buidler
could accept a ResourceInfo in buildLayer
and figure out by itself how to handle it internally?

Cheers
Andrea

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.