Demo java module and Query Schema Browser

LabKey Support Forum (Inactive)
Demo java module and Query Schema Browser Will Holtz  2014-07-16 09:12
Status: Closed
 
I'm messing around with the Demo java module (https://www.labkey.org/wiki/home/Documentation/page.view?name=demoModule). It compiles, loads and seems to be fully functional. However, when I am in the folder I instantiated the Demo module in and go to Admin->Developer Links->Schema Browser, the demo schema is not listed. I have verified the table exists in my database. Is this expected behavior? What would I need to add to the Demo module in order to get the associated schema exposed in the Schema Browser? I am on v14.1.

thanks!
-Will
 
 
adam responded:  2014-07-16 13:09
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