Hello,
for the archives, or to whom it may concern. I didn't find the problem
directly, but I tracked this down to something very weird.
I basically want to add a new layer to a map. This is often a layer DB
layer from a table that gets created dynamically.
The workflow where this happens is:
1) Find a service (for a DB). Done with the example code from the wiki
(http://udig.refractions.net/confluence/display/DEV/2+Catalog)
for( IService service : serviceFactory.createService( params ) ){
try {
CatalogPlugin.getDefault().getLocalCatalog().add( service );
// skip code to find the chosen resource, i.e. DB table
}catch (IOException couldNotConnect ){}
}
2) Add new resource to a map. Everything works.
3) A new Table/View is created on the DB. udig gets notified of this and...
4) ...runs the same code as in (1), but look for newly created table
5) New table is found, service is added (again?)
6) Application behaves erratically: layer shows up on the list, but has
no data (because of NullGeoResource)
The problems seems to be
CatalogPlugin.getDefault().getLocalCatalog().add( service );
The DB is the same, only a new table has been created. I *think* the
catalog holds two services, where there should be a single one.
I fixed the problem by keeping a reference to the first service being
added. Before I run the for loop again, I remove the service. So either
serviceFactory.createService( params ) shouldn't return two instances of
the same service, or Catalog.add( service ) should handle the case where
the service has already been added. (It *is* the same DB, so it should
be a single instance of the service, shouldn't it?)
Anyway, I might be completely wrong. This was very difficult to find.
And I think I've got it running, but for OracleServiceImpl.lock()
problems. (Which seem to be completely unrelated to all of this, as I've
had lock problems running udig trunk against the DB, and without any
comlexities of tables that get created *after* the catalog has been
created. That is, lock problems do appear when udig is run as a "normal"
product".)
If all of this makes sense to anyone, and if anyone wants more info,
please let me know.
Cheers,
Ugo
Ugo Taddei wrote:
Hello,
I'm trying to programatically add a layer (from an Oracle DB). Though
the code works in most circumstances, sometimes I see my layer with an
OracleGeoResource (just before it gets added in
AddLayersCommand.run(IProgressMonitor) ), have its georesource turned
into a NullGeoResource(http://NULL).
The layer comes from an oracle view that gets created dynamically. The
point is, when I run the code again, the layer gets added.
Am I missing something, like telling the Catalog to synchronize?
This is a tough one. I've tracked the problem down to
LayerFactoryImpl.createLayer(IGeoResource) but I'd like to make sure I'm
not missing anything before I dig further.
BTW, in LayerFactoryImpl.createLayer(IGeoResource), the line
layer.setGeoResource(preferredResource);
might yield
LayerImp.geoResource = null;
Does anyone want to have that? (Perhaps that's the reason for my problem?)
Thanks in advance,
Ugo
--
Ugo Taddei
Fraunhofer Institut Intelligente Analyse- und Informationssysteme (FhG IAIS)
http://www.iais.fraunhofer.de
Department Knowledge Discovery - IAIS.KD -
Working Group Spatial Decision Support
http://www.iais.fraunhofer.de/kd.html
phone (+49)2241-14-2184 fax (+49)2241-14-2072
Schloss Birlinghoven, D-53754 Sankt Augustin, Germany
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel