[GeoNetwork-devel] [GeoNetwork opensource Developer website] #1236: Metadata not being spatially indexed in Oracle database

#1236: Metadata not being spatially indexed in Oracle database
----------------------------+-----------------------------------------------
Reporter: asedgmen | Owner: geonetwork-devel@…
     Type: defect | Status: new
Priority: major | Milestone: v2.8.1
Component: General | Version: v2.8.0
Keywords: Oracle spatial |
----------------------------+-----------------------------------------------
The following error occurs when an ISO 19139 record is created or edited
in a GeoNetwork instance using Oracle with spatial indexing in the
database (tested against both Oracle 11g Enterprise and XE):

2013-03-06 13:14:55,905 ERROR [geonetwork.datamanager] - The metadata
document index with id=1 is corrupt/invalid - ignoring it. Error: Unknown
attribute id org.geotools.feature.IllegalAttributeException:Unknown
attribute id:null value:null
         at
org.geotools.feature.simple.SimpleFeatureImpl.setAttribute(SimpleFeatureImpl.java:246)
         at
org.fao.geonet.kernel.search.spatial.SpatialIndexWriter.index(SpatialIndexWriter.java:162)
         at
org.fao.geonet.kernel.search.SearchManager.index(SearchManager.java:686)
         at
org.fao.geonet.kernel.DataManager.indexMetadata(DataManager.java:553)
         .

The hard coded id attribute name "id" being used in the SpatialIndexWriter
class is conflicting with the name of the id column in the Oracle
database. Prior to adding a spatial index entry to the database, the
underlying Geotools code checks the SPATIALINDEX database table (described
in a simple feature schema) for a column name matching the hard coded id
attribute. Column names for the SPATIALINDEX table in an Oracle database
are presented in upper case in the simple feature schema, i.e, the id
column appears as "ID", causing the column name check to fail. This issue
does not occur with Postgres/PostGIS databases as column names are
presented in lower case.

I looked at trying to force Oracle to use lower case column names
(couldn't get it to work), and changing the hard coded id attribute to
upper case (breaks spatial indexing in Postgres). I found a solution that
worked well was to make use of the "findIdColumn" method provided in the
SpatialIndexWriter class, which obtains the name of the id column as
presented in the simple feature schema. Substituting the use of the hard
coded id value with a value obtained by the "findIdColumn" method resolves
the issue - achieved by updating line 162 of
org.fao.geonet.kernel.search.spatial.SpatialIndexWriter.java (2.8.0 tag)
with the following:

   Before
     template.setAttribute('''_IDS_ATTRIBUTE_NAME''', id);
   After
     template.setAttribute('''_idColumn.toString()''', id);

Spatial indexing for both Oracle and Postgres databases works with this
modification.

--
Ticket URL: <http://trac.osgeo.org/geonetwork/ticket/1236&gt;
GeoNetwork opensource Developer website <http://sourceforge.net/projects/geonetwork/&gt;
GeoNetwork opensource is a standards based, Free and Open Source catalog application to manage spatially referenced resources through the web. It provides powerful metadata editing and search functions as well as an embedded interactive web map viewer. This website contains information related to the development of the software.

#1236: Metadata not being spatially indexed in Oracle database
-----------------------+----------------------------------------------------
  Reporter: asedgmen | Owner: geonetwork-devel@…
      Type: defect | Status: closed
  Priority: major | Milestone: v2.8.1
Component: General | Version: v2.8.0
Resolution: fixed | Keywords: Oracle spatial
-----------------------+----------------------------------------------------
Changes (by jesseeichar):

  * status: new => closed
  * resolution: => fixed

Comment:

Committed fix: dbb361f

--
Ticket URL: <http://trac.osgeo.org/geonetwork/ticket/1236#comment:1&gt;
GeoNetwork opensource Developer website <http://sourceforge.net/projects/geonetwork/&gt;
GeoNetwork opensource is a standards based, Free and Open Source catalog application to manage spatially referenced resources through the web. It provides powerful metadata editing and search functions as well as an embedded interactive web map viewer. This website contains information related to the development of the software.