Helma Logo
main list history

RFC: Optional property type declarations for embedded db

Proposal:

Currently when using a SQL DB, its possible to fetch DB metadata (via JDBC) from the HopObject property->DB table-column mapping in type.properties files, and use the metadata to determine the type of each property. No such facility currently exists for the embedded xml-based DB.

Implementation

Approve and document the use of optional type specifications in type.properties files when Prototypes are using the embedded db data-store.
Eg.
Book/type.properties
  title = String
  published = Date
  available = Boolean
  qty = Number

After some initial testing, this seems to actually work ok (as of helma 1.6.1) and the type values are available to JS app code now via:

  var proto = app.getPrototype("Book");
  writeln("proto:"+p);
  var props = proto.typeProperties.propertyNames(); 
  while(props.hasNext()) {
    var p = props.next();
    writeln("prop "+p+"="+proto.typeProperties.getProperty(p));
  }
Though I nicer API could be defined in by adding for example:
  getPropertyType(propertyName) 

method to helma.framework.core.Prototype for example.
That way code to get the same info from SQL metadata could be hidden behind this common api.

The availability of this API for introspection of Protype definitions would make it much easier for applications to do simple data validation and also to create other useful utils.