Rule Designer command-line tool
You can automate routine operations and extend the model by using JavaScript.
You use the Rule Designer command-line
tool to automate routine operations from the command line. The command-line
tool launches Rule Designer in headless
mode,
that is, with no user interface for the development environment, to
run specified JavaScript files.
The tool is packaged as an Eclipse plug-in named ilog.rules.studio.javascript. The plug-in includes the entire Rule Designer and Eclipse APIs, plus a dedicated set of global variables offering services to extend the model. You can also use the variables to build and extract a ruleset archive. However, the build automation tool provides an easier way to do these tasks, as described in Rule Designer build automation tool.
These variables serve as Rule Designer API entry points. Other Java™ class names, such as java.lang.System, must be fully qualified to be called from within the JavaScript file.
The JavaScript main method is the entry point for the command-line tool. It is called when the JavaScript file is run. All the parameters used to start the tool are used to set up the command-line tool itself. You cannot use them to parameterize the JavaScript execution.
Here is a sample of JavaScript using a predefined variable and a fully qualified Java class.
function main() {
var HOME = "<my_absolute_path_to_the_projects_folder>"
// Import projects into the workspace.
java.lang.System.out.println(">>> importing projects "); // Use a fully qualified Java class.
var projects = importHelper.importFolderContent(HOME); // Use a predefined global variable importHelper.
}
You can use the Rule Designer command-line tool to extend the rule model. This is not a dynamic process; rules loaded in the workspace before you extend the model do not inherit from the model extension. You must do the model extension before you import or open a project in the workspace. If the workspace already contains projects, you must first run a script to set the model and save the preferences, and then run a second script to manipulate the projects. The second execution reloads the workspace with the model extension.
The script folder in the ilog.rules.studio.javascript plug-in installation provides two JavaScript samples:
-
modelExtension.js, to set the rule model extension
-
importBuildExtract.js, to manipulate the projects
If the workspace is empty, you can set the model extension in the same script execution. You must uncomment a single line in the importBuildExtract.js script.
var projects = modelHelper.extendRuleModel(
META_MODEL_HOME+"rulestudiocustommodel.brmx",
META_MODEL_HOME+"rulestudiocustommodel.brdx", false);