Pages

Monday, December 31, 2012

Documenting WEF Models

Web Experience Factory is a pretty good tool for rapid development, but its designer lacks automated documentation that can be used to explain an application to a new developer. Models can get extremely complicated, especially when they're assembled by developers who are just starting to use the tool. This article describes how graphs can be generated using eclipse.

Using an Eclipse Plugin to Generate Graphs
I've worked with projects that, in some cases, imported dozens of other models, making it quite challenging to follow a sequence of events. About a year ago I had the idea of generating a graph showing how models are imported into each other, but quickly got lost in the details of graphing within eclipse.
I recently stumbled on an open source application named Graphviz, and when I saw the simplicity of using a DOT file to describe a graph, I was able to quickly develop a plugin to inspect a WEF model and produce a graph of it.

An easy candidate for a graph is tracing how models import other models. The plugin does this by recursively traversing the import builders in each model, producing a graph similar to this example.


Once I figured that out, I was able to add some more to the plugin, producing a graph of service consumer operation calls like the one below. This graph indicates that model_4 contains an action list builder named alTest that invokes the doSomeOperation operation exposed by the service consumer builder named svcConsumer.

The graph of action list calls (builders which invoke action lists) is very similar to the one above, except the target node is an action list instead of a service operation.
After the plugin is installed by following these instructions, you will see the following submenu when right clicking on a model.


Just select the graph you wish to generate and it will appear in an eclipse browser window. Although I developed this tool for my own use, I'm making it available free of charge to anyone.

If the tool doesn't work for you, then please leave me a message on this blog (or email me).


References: Download plugin from http://www.dsixe.com/eclipse

Tuesday, December 4, 2012

Using com.bowstreet.builders.webapp.api.Method

I've been writing some more custom builders recently and had a hard time figuring out how to generate a method with arguments.

Below is an example:

        Method method = new Method(builderCall, genContext);
        method.setName("myMethod");
        IXml args = null;
        
        try {
           args = XmlUtil.parseXml("<top><Argument><Name>msgValue</Name><Type>String</Type></Argument></top>");
        } catch (IOException e) {
           e.printStackTrace();
        }
        
        method.setArguments(args);
        StringBuffer sb = new StringBuffer("{ \n");
        sb.append("    webAppAccess.getVariables().getVariable(\"myVar\").setValue(msgValue); \n");
        sb.append("}");
        method.setBody(sb.toString());
        method.invokeBuilder();

and here's the code added to the model on regen:

/**
 * Generated Method [myMethod]
 */
public void myMethod(WebAppAccess webAppAccess, String msgValue)
{ 
    webAppAccess.getVariables().getVariable("myVar").setValue(msgValue); 
}
I figured out the magic XML for method.setArguments() by looking at the model XML for a standard method builder.