uDIG

Cannot resolve PostGIS layer to JDBCDataStore

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: UDIG 1.2.RC1
  • Fix Version/s: UDIG 1.2.RC3
  • Component/s: database
  • Labels:
    None
  • Environment:
    JDK 1.6.0_18, gtk.linux.x86_64

Description

I'm implementing a custom ActionTool working on a PostGIS layer, and I need to access the underlying DataSource from the tool implementation. I'm not sure if the following code is the best way of doing so, but with this approach, I hit a bug in PostgisSchemaFolder

ILayer layer = getContext().getSelectedLayer();
try
{
IService service = layer.getGeoResource().resolve(IService.class, null);
IResolve member = service.members(null).get(0);
boolean canResolve = member.canResolve(JDBCDataStore.class);
if (canResolve)

{ JDBCDataStore store = member.resolve(JDBCDataStore.class, null); // FIXME: store is null! DataSource dataSource = store.getDataSource(); log.info(dataSource.toString()); }

}
catch (IOException exc)

{ exc.printStackTrace(); }

member is of class PostgisSchemaFolder. canResolve() returns true for JDBCDataStore, but resolve() only works for DataStore, not for JDBCDataStore. I locally patched the resolve() method, replacing DataStore by JDBCDataStore to make things work.

Activity

Hide
Jody Garnett added a comment -
Fixed as of -r31759, thanks for the patch.
Show
Jody Garnett added a comment - Fixed as of -r31759, thanks for the patch.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: