Helma Logo
main list history
previous version  overview  next version

Version 1 by maks on 03. April 2008, 05:29

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.

Approve and document the use of optional type specifications in type.properties files when Prototypes are using the embedded db data-store.
  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");
  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: 
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.