| ILOG JRules User Guide > Customizing JRules > Concepts > Rule Studio Command-Line Tool |
Rule Studio Command-Line Tool |
PREVIOUS NEXT |
JRules provides a command-line tool to allow you to automate routine operations from the command line. The command-line tool launches Rule Studio in "headless" mode (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 Studio and Eclipse APIs, plus a dedicated set of global variables offering services to extend the model, import projects into the workspace, and to build and extract a ruleset archive. These variables serve as Rule Studio API entry points, other Java class names, such as java.lang.System, have to 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 and cannot be used 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.
}
The Rule Studio command-line tool allows you to set an extended model for the rules. This is not a dynamic process, any rule loaded in the workspace before the model is extended will not inherit from this model extension. You need to perform the model extension before a project is imported or opened 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 will reload the workspace with the model extension.
The script folder in the installation of the ilog.rules.studio.javascript plug-in provides two JavaScript samples:
modelExtension.js).
importBuildExtract.js).
If the workspace is empty, the model extension can be set in the same script execution; there is a single line to uncomment in the importBuildExtract.js script to do this.
var projects = modelHelper.extendRuleModel( META_MODEL_HOME+"rulestudiocustommodel.brmx", META_MODEL_HOME+"rulestudiocustommodel.brdx", false);
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |