[Geoserver-users] minOccurs from schema.xsd not being used in GeoServer 2.0.1

Description of the situation: We have in our database (Oracle) some fields that are not nullable, such as id etc. To make sure WFS queries requesting specific propertynames only give the requested propertynames we have therefore made specific schema-files where minOccurs has been set to 0 for all properties. This works fine on GeoServer 1.7.7 but when making the switch to 2.0.1 the non-nullable fields are being delivered in getFeature queries.

DescribeFeatureType shows the correct minOccurs-values, and tracing creation of the FeatureType-elements in GeoServer shows that the schema.xsd-file is being read and parsed correctly.

The problem seems to be in ResourcePool.java specifically the function handleSchemaOverride. This function checks the schema from database against the schema from the xsd-file, and removes the fields that do not exist in the xsd-file from the attribute-list generated from the database schema. I managed to add the functionality I expected from the function by modifying the code as follows:

for ( Iterator c = children.iterator(); c.hasNext(); ) {
   XSDElementDeclaration ce = (XSDElementDeclaration) c.next();
   if ( at.getName().equals( ce.getName() ) ) {
      found = true;
      at.setMinOccurs(((org.eclipse.xsd.impl.XSDParticleImpl)((org.eclipse.xsd.impl.XSDElementDeclarationImpl)ce).getContainer()).getMinOccurs()); //added
      at.setMaxOccurs(((org.eclipse.xsd.impl.XSDParticleImpl)((org.eclipse.xsd.impl.XSDElementDeclarationImpl)ce).getContainer()).getMaxOccurs()); //added
      break;
   }
}

I realize the problem may lie somewhere in our configuration of GeoServer so before I stare myself blind on the setup of our schema-files I thought it best to ask here whether this is a known issue, or whether this functionality should be working out of the box.

Regards
Roar Ingebrigtsen
Software developer
Norwegian Mapping Authorities

Hi Roar,

It sure is nice when people find the problems and solve them :). The patch looks great. I will commit it asap.

Thanks!

-Justin

On 1/28/10 6:44 AM, Roar Ingebrigtsen wrote:

Description of the situation: We have in our database (Oracle) some fields that are not nullable, such as id etc. To make sure WFS queries requesting specific propertynames only give the requested propertynames we have therefore made specific schema-files where minOccurs has been set to 0 for all properties. This works fine on GeoServer 1.7.7 but when making the switch to 2.0.1 the non-nullable fields are being delivered in getFeature queries.

DescribeFeatureType shows the correct minOccurs-values, and tracing creation of the FeatureType-elements in GeoServer shows that the schema.xsd-file is being read and parsed correctly.

The problem seems to be in ResourcePool.java specifically the function handleSchemaOverride. This function checks the schema from database against the schema from the xsd-file, and removes the fields that do not exist in the xsd-file from the attribute-list generated from the database schema. I managed to add the functionality I expected from the function by modifying the code as follows:

for ( Iterator c = children.iterator(); c.hasNext(); ) {
    XSDElementDeclaration ce = (XSDElementDeclaration) c.next();
    if ( at.getName().equals( ce.getName() ) ) {
       found = true;
       at.setMinOccurs(((org.eclipse.xsd.impl.XSDParticleImpl)((org.eclipse.xsd.impl.XSDElementDeclarationImpl)ce).getContainer()).getMinOccurs()); //added
       at.setMaxOccurs(((org.eclipse.xsd.impl.XSDParticleImpl)((org.eclipse.xsd.impl.XSDElementDeclarationImpl)ce).getContainer()).getMaxOccurs()); //added
       break;
    }
}

I realize the problem may lie somewhere in our configuration of GeoServer so before I stare myself blind on the setup of our schema-files I thought it best to ask here whether this is a known issue, or whether this functionality should be working out of the box.

Regards
Roar Ingebrigtsen
Software developer
Norwegian Mapping Authorities

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.