uDIG
  1. uDIG
  2. UDIG-1633

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

          • Assignee:
            Unassigned
            Reporter:
            Harald Wellmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: