Demo java module and Query Schema Browser | adam | 2014-07-16 13:09 |
Status: Closed | ||
Hi Will, As you may have seen, the database schemas defined by file-based (non-Java) modules are automatically exposed to the query layer (you'll see them in the query schema browser and can use all the standard query actions on them). The code that handles this is SimpleModule.registerSchemas(). Java modules must register their schemas explicitly... typically, these modules want more control over exactly which schemas & tables are exposed, and the shape of those tables. They do this by calling DefaultSchema.registerProvider(). There are quite a few examples in the code, but WikiSchema is one simple example to start with. If you want your Java module to expose the entire schema you could follow the pattern in SimpleModule... just add code like this to your module's doStartup() method: DefaultSchema.registerProvider("demo", new DefaultSchema.SchemaProvider(this) { public QuerySchema createSchema(final DefaultSchema schema, Module module) { DbSchema dbSchema = DbSchema.get("demo"); return QueryService.get().createSimpleUserSchema(dbSchema.getQuerySchemaName(), null, schema.getUser(), schema.getContainer(), dbSchema); } }); Not tested, but that's the basic idea. Adam |
||