Hey, sorry for the long time taken to get back to this.
On Mon, May 21, 2012 at 5:43 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:
Hey Gabriel,
Not so sure… the catalog api is set up to allow multiple layers for a single resource. I realize that at the moment there is a 1-1 relationship but one of the long term goals for the catalog is to move all publishing concerns from REsourceInfo to LayerInfo, at which time I think the case for having multiple layers for a single resource will become stronger.
What exactly is the impediment?
Yeah I know in the long term goal is to allow multiple layerinfos reference the same resourceinfo. Yet at the current state of affair that is not possible. Doing so leads to a broken catalog. So it’d be better to enforce the 1:1 relationship until we actually fix that.
The thing goes like that, as far as I understand it:
- Add FeatureTypeInfo FT1
- Add LayerInfo for it, it’s gonna be called FT1 too
- Add a second LayerInfo for FT1, set its name to L2. LayerInfoImpl.setName(String name) does this.resource.setName(name)
- Now the resourceinfo name changed under the hook, the layer L2 was saved, but both layers end up being called the same, L2, as LayerInfoImpl.getName() delegates to this.resource.getName();
In the end, you have multiple layers referencing the same resource but called the same. Moreover, the under-the-hook change for the resourceinfo is never persisted with the in-memory catalog, but the test that adds multiple layers for the same resource doesn’t check anything besides the add not failing.
Now, for the in-memory catalog the side effect is just that the ResourceInfo gets renamed under the hook. If that were actually done in application code, the result would be that after restart all the layers would be named as the resourceinfo was first named, as it was not persisted.
For the database implementation it is an impediment because the queries are evaluated against the persisted attribute value, not the in-memory one, and hence can’t go on. By either way, the Catalog is broken, and as far as I know, nowhere in application code this is being used. Hence the need to enforce the 1:1 relationship until we take care of it in a saner way (i.e. allowing layers to be named independently of its resource).
The following test (add it to CatalogImplTest) fails at the second assert. It should actually fail at the first one because there’s more than one layer named “LAYER-2”, but DefaultCatalogFacade short-circuits the evaluation and returns at the first match.
public void testAddMultipleLayersForTheSameResource()throws Exception{
addLayer();
final String initialName = ft.getName();
LayerInfo layer = catalog.getFactory().createLayer();
layer.setResource(ft);
layer.setName(“LAYER-2”);
catalog.add(layer);
assertNotNull(catalog.getLayerByName(“LAYER-2”));
assertNotNull(catalog.getLayerByName(initialName));
}
Hope it all makes sense now, let me know if I’m missing something.
Cheers,
Gabriel
On Mon, May 21, 2012 at 10:15 AM, Gabriel Roldan <groldan@anonymised.com> wrote:
Hey there,
may I draw your attention to http://jira.codehaus.org/browse/GEOS-5121
for a minute and ask to comment out on whether the description and
patch look good?
I found this an impediment on implementing the GSIP-69 jdbc backend so
please check it at your earliest convenience.
TIA,
Gabriel
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.
–
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
–
Gabriel Roldan
OpenGeo - http://opengeo.org
Expert service straight from the developers.