Helma Logo
main list history

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

2Currently 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.
4Approve and document the use of optional type specifications in type.properties files when Prototypes are using the embedded db data-store.
7  title = String
8  published = Date
9  available = Boolean
10  qty = Number
12After 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:
14  var proto = app.getPrototype("Book");
15  writeln("proto:"+p);
16  var props = proto.typeProperties.propertyNames();
18  while(props.hasNext()) {
19    var p = props.next();
20    writeln("prop "+p+"="+proto.typeProperties.getProperty(p));
21  }
23Though I nicer API could be defined in by adding for example: 
24  getPropertyType(propertyName)
25method to helma.framework.core.Prototype for example.
26That way code to get the same info from SQL metadata could be hidden behind this common api.
28The 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.