Rule Execution Server API

ilog.rules.studio.res.generator
Class IlrFileGenerator

java.lang.Object
  extended by ilog.rules.studio.res.generator.IlrFileGenerator
All Implemented Interfaces:
org.eclipse.jface.wizard.IWizardNode
Direct Known Subclasses:
IlrVelocityGenerator

public abstract class IlrFileGenerator
extends Object
implements org.eclipse.jface.wizard.IWizardNode

Defines a generator for the list in the new client project for the RuleApps wizard.

Since:
JRules 6.0

Nested Class Summary
 class IlrFileGenerator.Parameter
          Stores a ruleset parameter name and type.
 class IlrFileGenerator.RuleApp
          Provides some useful methods on a RuleApp project.
 class IlrFileGenerator.RulesetArchive
          Stores a ruleset archive name and version with two lists of ruleset parameters: a list of input parameters (the IN and INOUT parameters) and a list of output parameters (the INOUT and OUT parameters).
 
Field Summary
protected  boolean contentCreated
           
 
Constructor Summary
protected IlrFileGenerator()
          Constructs a new generator.
 
Method Summary
protected  void addContainerEntryInClasspath(String container)
          Adds to the Java project build path the specified container.
protected  void addLibraryEntryInClasspath(String path)
          Adds to the Java project build path the path specified as an absolute path.
protected  void addProjectEntryInClasspath(String path)
          Adds to the Java project build path the path specified as <projectName>.
protected  void addVariableEntryInClasspath(String path)
          Adds to the Java project build path the path specified as <EclipseVariable>/<relativePath>.
protected  String changeInClassName(String name)
          Gets the name specified, with a capital letter as the first letter.
protected  String changeInMethodName(String name)
          Gets the name specified, with a lower case letter as the first letter.
 org.eclipse.core.resources.IProject completeProjectFromTemplate(org.eclipse.core.resources.IProject iproject, IlrRuleAppProject sourceRuleAppProject, org.eclipse.core.runtime.IProgressMonitor monitor)
          Completes the specified project with the required files by calling the generateProjectContent(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) method.
protected  void copyFile(String source, String destination)
          Copies a file from a location (absolute path) in the generated Java project to a destination directory with a specific file name.
protected  String createPackage(org.eclipse.core.resources.IProject project, String root, String name)
          Creates a package in the root directory (relative to the project) of the destination project.
 org.eclipse.core.resources.IProject createProjectFromTemplate(String projectname, org.eclipse.core.runtime.IPath location, IlrRuleAppProject sourceRuleAppProject, org.eclipse.core.runtime.IProgressMonitor monitor)
          Creates the destination project and calls the generateProjectContent(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) method on the new project.
 String generateLaunchConfigurationFile(String main)
          Generates and saves a launch configuration file with the references to the Rule Project from the RuleApp project.
 void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject)
          Generates the content of the Java project.
 void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject, org.eclipse.core.runtime.IProgressMonitor monitor)
          Generates the content of the Java project.
 void generateProjectContent(org.eclipse.core.resources.IProject project)
          Generates the content of the simple project.
 void generateProjectContent(org.eclipse.core.resources.IProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
          Generates the content of the simple project.
 org.eclipse.jface.wizard.IWizard getCompletionWizard()
          Returns the completion wizard.
 org.eclipse.jface.wizard.IWizard getCreationWizard()
          Returns the creation wizard.
protected  String getExecutionServerHome()
          Gets the location of the ILOG_EXECUTION_SERVER_HOME Eclipse variable.
protected  List<IlrFileGenerator.Parameter> getInParameters()
          Gets a list of the in/inout ruleset parameters for the RuleApp project.
protected  List<IlrFileGenerator.Parameter> getInParameters(Collection<IlrRulesetParameter> rulesetParameters)
          Returns a list of input ruleset parameters as IlrFileGenerator.Parameter instances extracted from a collection of ilog.rules.res.model.IlrRulesetParameter objects
protected  List<IlrFileGenerator.Parameter> getInParameters(IlrRulesetArchiveDescriptor desc)
          Gets a list of the in/inout ruleset parameters for a ruleset archive of the RuleApp project.
protected  List<IlrFileGenerator.Parameter> getInParameters(IlrRulesetParameter[] params)
          Deprecated. As of ODM 8.5.1, replaced by getInParameters(Collection rulesetParameters).
protected  Set<String> getInParametersImports()
          Deprecated. As of ODM 8.5.1.
protected  Set<String> getInParametersImports(IlrRulesetArchiveDescriptor archive)
          Deprecated. As of ODM 8.5.1.
protected  org.eclipse.jdt.core.IJavaProject getJavaProject()
          Gets the generated destination Java project.
protected  String getJavaProjectNameAsClassName()
          Gets the Java project name as a valid Java class name, with a capital letter as the first letter.
protected  String getLaunchConfigurationName()
          Gets the launch configuration name that was set during the execution of the generateLaunchConfigurationFile(String) method.
protected  IlrFileGenerator.Parameter getNewParameter(String name, String type)
          Returns a new object of type Parameter.
protected  IlrFileGenerator.RulesetArchive getNewRulesetArchive()
          Returns a new object of type RulesetArchive.
 String getNotAllowedDescription()
          Returns the message to display in the 'Client Project for RuleApps' wizard if the generator is not allowed to run to return the reason why.
protected  List<IlrFileGenerator.Parameter> getOutParameters(Collection<IlrRulesetParameter> rulesetParameters)
          Returns a list of output ruleset parameters as IlrFileGenerator.Parameter instances extracted from a collection of ilog.rules.res.model.IlrRulesetParameter objects.
protected  List<IlrFileGenerator.Parameter> getOutParameters(IlrRulesetParameter[] params)
          Deprecated. As of ODM 8.5.1, replaced by getInParameters(Collection rulesetParameters).
protected  Set<String> getOutParametersImports()
          Deprecated. As of ODM 8.5.1.
protected  List<IlrFileGenerator.Parameter> getParameters(Collection<IlrRulesetParameter> rulesetParameters)
          Transforms a collection of ilog.rules.res.model.IlrRulesetParameter objects into a list of IlrFileGenerator.Parameter instances.
protected  List<IlrFileGenerator.Parameter> getParameters(IlrRulesetParameter[] params)
          Deprecated. As of ODM 8.5.1, replaced by getParameters(Collection rulesetParameters).
protected  Set<String> getParametersImports()
          Deprecated. As of ODM 8.5.1.
protected  org.eclipse.core.resources.IProject getProject()
          Gets the generated destination project if the destination project is not a Java project.
 IlrRuleAppProject getRuleAppProject()
          Gets the RuleApp project selected in the wizard.
protected  List<IlrFileGenerator.RulesetArchive> getRulesetArchives()
          Gets a list of ruleset archives.
protected  List<IlrFileGenerator.RulesetArchive> getRulesetArchives(IlrRulesetArchiveDescriptor archive)
          Gets a list of ruleset archives.
protected  String getRuleStudioHome()
          Gets the location of the ILOG_BR_STUDIO_HOME Eclipse variable.
 IlrSignature[] getSignatures()
          Gets the in and inout ruleset parameter names and values set in the wizard.
protected  String getUTF8CharsetAsString()
           
 org.eclipse.jface.wizard.IWizard getWizard()
          Returns the wizard that this node stands for.
protected  List<String> getXOMPath()
          Gets a list of paths (String) for all the necessary XOMs, for all rulesets in the RuleApp.
 void initialize(IlrRuleAppProject ruleappProject)
          Initializes the generator with the data specified in the wizard.
 boolean isAllowed()
          Returns true if the environment is correctly set to allow the generator to be run correctly.
 boolean isJavaProject()
          Tests if the project is a Java or a simple project.
protected  void setJavaNature(org.eclipse.core.resources.IProject ijProject)
           
 void setSignatures(IlrSignature[] signatures)
          Sets the in and inout ruleset parameter names and values in the wizard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.wizard.IWizardNode
dispose, getExtent, isContentCreated
 

Field Detail

contentCreated

protected boolean contentCreated
Constructor Detail

IlrFileGenerator

protected IlrFileGenerator()
Constructs a new generator. The class that extends this class must declare a public default constructor that calls this constructor. The default constructor is the only one called to create a generator.

Since:
JRules 6.6
Method Detail

isAllowed

public boolean isAllowed()
Returns true if the environment is correctly set to allow the generator to be run correctly. Return false otherwise. If false is returned, the getNotAllowedDescription() method is called to get the description to display instead of the generator's description. The default returned value is true.

Since:
JRules 6.5.1
Returns:
true if the generator is allowed to run, otherwise return false.

getNotAllowedDescription

public String getNotAllowedDescription()
Returns the message to display in the 'Client Project for RuleApps' wizard if the generator is not allowed to run to return the reason why. The method isAllowed() is used to control whether or not this message is displayed. The message will be displayed instead of the generator description.

Since:
JRules 6.5.1
Returns:
The message to display if the generator is not allowed to run.

initialize

public void initialize(IlrRuleAppProject ruleappProject)
Initializes the generator with the data specified in the wizard.

Parameters:
ruleappProject - The RuleApp project selected in the wizard.

getRuleAppProject

public IlrRuleAppProject getRuleAppProject()
Gets the RuleApp project selected in the wizard.

Returns:
The selected RuleApp project.

setSignatures

public void setSignatures(IlrSignature[] signatures)
Sets the in and inout ruleset parameter names and values in the wizard.

Parameters:
signatures - The in parameter names and values.

getSignatures

public IlrSignature[] getSignatures()
Gets the in and inout ruleset parameter names and values set in the wizard.

Returns:
The stored signatures.

isJavaProject

public boolean isJavaProject()
Tests if the project is a Java or a simple project. If the method returns true, the new project will be a Java project and src and bin directories will be created. The JRE and Rule Execution Server JARs will be included in the classpath. The method called is generateProjectContent(IJavaProject).

If the method returns false, a simple project is created without anything else. The method called is generateProjectContent(IProject).

Returns:
If the new project is a Java project, true is returned.

getJavaProject

protected org.eclipse.jdt.core.IJavaProject getJavaProject()
Gets the generated destination Java project.

Returns:
The generated destination Java project.

getLaunchConfigurationName

protected String getLaunchConfigurationName()
Gets the launch configuration name that was set during the execution of the generateLaunchConfigurationFile(String) method.

Since:
JRules 6.0.1
Returns:
The launch configuration name.

getJavaProjectNameAsClassName

protected String getJavaProjectNameAsClassName()
Gets the Java project name as a valid Java class name, with a capital letter as the first letter.

Returns:
The Java project name as a valid Java class name.

getProject

protected org.eclipse.core.resources.IProject getProject()
Gets the generated destination project if the destination project is not a Java project. If the destination project is a Java project, this method returns the IProject associated with this Java project.

Returns:
The generated destination project.

changeInClassName

protected String changeInClassName(String name)
Gets the name specified, with a capital letter as the first letter.

Parameters:
name - The name to change.
Returns:
The name specified, with a capital letter as the first letter.

changeInMethodName

protected String changeInMethodName(String name)
Gets the name specified, with a lower case letter as the first letter.

Since:
JRules 6.5
Parameters:
name - The name to change.
Returns:
The name specified, with a lower case letter as the first letter.

generateProjectContent

public void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject,
                                   org.eclipse.core.runtime.IProgressMonitor monitor)
Generates the content of the Java project. By default, this method calls the generateProjectContent(IJavaProject) method for compatibility reasons.

Since:
JRules 6.5
Parameters:
javaProject - The destination of the Java project files.
monitor - The progress monitor.

generateProjectContent

public void generateProjectContent(org.eclipse.jdt.core.IJavaProject javaProject)
Generates the content of the Java project. By default, this method only saves the javaProject which will be accessible through the getJavaProject() method.

Parameters:
javaProject - The destination of the Java project files.

generateProjectContent

public void generateProjectContent(org.eclipse.core.resources.IProject project,
                                   org.eclipse.core.runtime.IProgressMonitor monitor)
Generates the content of the simple project. By default, this method calls the generateProjectContent(IProject) method for compatibility reasons.

Since:
JRules 6.5
Parameters:
project - The destination of the project files.
monitor - The progress monitor.

generateProjectContent

public void generateProjectContent(org.eclipse.core.resources.IProject project)
Generates the content of the simple project.

Parameters:
project - The destination of the project files.

getRuleStudioHome

protected String getRuleStudioHome()
Gets the location of the ILOG_BR_STUDIO_HOME Eclipse variable.

Returns:
The location of the ILOG_BR_STUDIO_HOME Eclipse variable.

getExecutionServerHome

protected String getExecutionServerHome()
Gets the location of the ILOG_EXECUTION_SERVER_HOME Eclipse variable.

Returns:
The location of the ILOG_EXECUTION_SERVER_HOME Eclipse variable.

addVariableEntryInClasspath

protected void addVariableEntryInClasspath(String path)
Adds to the Java project build path the path specified as <EclipseVariable>/<relativePath>.


addLibraryEntryInClasspath

protected void addLibraryEntryInClasspath(String path)
Adds to the Java project build path the path specified as an absolute path.


addProjectEntryInClasspath

protected void addProjectEntryInClasspath(String path)
Adds to the Java project build path the path specified as <projectName>.


addContainerEntryInClasspath

protected void addContainerEntryInClasspath(String container)
Adds to the Java project build path the specified container.

Since:
JRules 7.0

getParametersImports

protected Set<String> getParametersImports()
Deprecated. As of ODM 8.5.1.

Returns a list of fully-qualified types for ruleset parameters that require import statements to be added in the generated code.


getInParametersImports

protected Set<String> getInParametersImports()
Deprecated. As of ODM 8.5.1.

Returns a list of fully-qualified types for input ruleset parameters that require import statements to be added in the generated code.


getInParametersImports

protected Set<String> getInParametersImports(IlrRulesetArchiveDescriptor archive)
Deprecated. As of ODM 8.5.1.

Returns a list of fully-qualified types for archive input ruleset parameters that require import statements to be added in the generated code.


getOutParametersImports

protected Set<String> getOutParametersImports()
Deprecated. As of ODM 8.5.1.

Returns a list of fully-qualified types for output ruleset parameters that require import statements to be added in the generated code.


getParameters

protected List<IlrFileGenerator.Parameter> getParameters(Collection<IlrRulesetParameter> rulesetParameters)
Transforms a collection of ilog.rules.res.model.IlrRulesetParameter objects into a list of IlrFileGenerator.Parameter instances.

Since:
ODM 8.5.1

getParameters

protected List<IlrFileGenerator.Parameter> getParameters(IlrRulesetParameter[] params)
Deprecated. As of ODM 8.5.1, replaced by getParameters(Collection rulesetParameters).

Transforms an array of ilog.rules.engine.IlrRulesetParameter objects into a list of IlrFileGenerator.Parameter instances.


getInParameters

protected List<IlrFileGenerator.Parameter> getInParameters(Collection<IlrRulesetParameter> rulesetParameters)
Returns a list of input ruleset parameters as IlrFileGenerator.Parameter instances extracted from a collection of ilog.rules.res.model.IlrRulesetParameter objects

Since:
ODM 8.5.1

getInParameters

protected List<IlrFileGenerator.Parameter> getInParameters(IlrRulesetParameter[] params)
Deprecated. As of ODM 8.5.1, replaced by getInParameters(Collection rulesetParameters).

Returns a list of input ruleset parameters as IlrFileGenerator.Parameter instances extracted from an array of ilog.rules.engine.IlrRulesetParameter objects.


getInParameters

protected List<IlrFileGenerator.Parameter> getInParameters()
Gets a list of the in/inout ruleset parameters for the RuleApp project.

Returns:
A list of the in/inout ruleset parameters for the RuleApp project.

getInParameters

protected List<IlrFileGenerator.Parameter> getInParameters(IlrRulesetArchiveDescriptor desc)
Gets a list of the in/inout ruleset parameters for a ruleset archive of the RuleApp project.

Returns:
A list of the in/inout ruleset parameters for a ruleset archive.

getOutParameters

protected List<IlrFileGenerator.Parameter> getOutParameters(Collection<IlrRulesetParameter> rulesetParameters)
Returns a list of output ruleset parameters as IlrFileGenerator.Parameter instances extracted from a collection of ilog.rules.res.model.IlrRulesetParameter objects.

Since:
ODM 8.5.1

getOutParameters

protected List<IlrFileGenerator.Parameter> getOutParameters(IlrRulesetParameter[] params)
Deprecated. As of ODM 8.5.1, replaced by getInParameters(Collection rulesetParameters).

Returns a list of output ruleset parameters as IlrFileGenerator.Parameter instances extracted from an array of ilog.rules.engine.IlrRulesetParameter objects.


getXOMPath

protected List<String> getXOMPath()
Gets a list of paths (String) for all the necessary XOMs, for all rulesets in the RuleApp. You can use this list in a generated build.xml file to fill the class path.

Returns:
A list of the XOM paths.

getRulesetArchives

protected List<IlrFileGenerator.RulesetArchive> getRulesetArchives()
Gets a list of ruleset archives.

Returns:
A list of ruleset archives.

getRulesetArchives

protected List<IlrFileGenerator.RulesetArchive> getRulesetArchives(IlrRulesetArchiveDescriptor archive)
Gets a list of ruleset archives.

Returns:
A list of ruleset archives.

copyFile

protected void copyFile(String source,
                        String destination)
Copies a file from a location (absolute path) in the generated Java project to a destination directory with a specific file name.

Parameters:
source - The location of the file to copy.
destination - The full path in the generated Java project.

generateLaunchConfigurationFile

public String generateLaunchConfigurationFile(String main)
Generates and saves a launch configuration file with the references to the Rule Project from the RuleApp project.

Parameters:
main - The main class to execute.
Returns:
The name of the configuration. Returns null if an error occurs during creation.

createPackage

protected String createPackage(org.eclipse.core.resources.IProject project,
                               String root,
                               String name)
Creates a package in the root directory (relative to the project) of the destination project.

Parameters:
project - The project where the package is created.
root - The relative path where the package is created.
name - The new package name.
Returns:
The relative path to the new package. The string ends with the path separator.

getNewRulesetArchive

protected IlrFileGenerator.RulesetArchive getNewRulesetArchive()
Returns a new object of type RulesetArchive. Redefine this method if you extend the RulesetArchive class and you want your class to be created instead of IlrFileGenerator.RulesetArchive.

Returns:
A new parameter.

getNewParameter

protected IlrFileGenerator.Parameter getNewParameter(String name,
                                                     String type)
Returns a new object of type Parameter. Redefine this method if you extend the Parameter class and you want your class to be created instead of IlrFileGenerator.Parameter.

Returns:
A new parameter.

getWizard

public org.eclipse.jface.wizard.IWizard getWizard()
Returns the wizard that this node stands for.

If no wizard is specified in the extension, this method returns null.

Specified by:
getWizard in interface org.eclipse.jface.wizard.IWizardNode
Returns:
The wizard.

getCompletionWizard

public org.eclipse.jface.wizard.IWizard getCompletionWizard()
Returns the completion wizard.

If no wizard is specified in the extension, this method returns the IlrDefaultCompletionWizard class.

Since:
JRules 6.5
Returns:
The wizard.

getCreationWizard

public org.eclipse.jface.wizard.IWizard getCreationWizard()
Returns the creation wizard.

If no wizard is specified in the extension, this method will return the IlrDefaultCreationWizard class.

Since:
JRules 6.5
Returns:
The wizard.

createProjectFromTemplate

public org.eclipse.core.resources.IProject createProjectFromTemplate(String projectname,
                                                                     org.eclipse.core.runtime.IPath location,
                                                                     IlrRuleAppProject sourceRuleAppProject,
                                                                     org.eclipse.core.runtime.IProgressMonitor monitor)
Creates the destination project and calls the generateProjectContent(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) method on the new project. Before the generateProjectContent(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) method is called, the class path is completed and the RuleApp archive is generated.

Since:
JRules 6.5
Parameters:
projectname - The name of the new project.
location - The location of the new project.
sourceRuleAppProject - The RuleApp project used to generate the files.
monitor - The progress monitor.
Returns:
The created project.

completeProjectFromTemplate

public org.eclipse.core.resources.IProject completeProjectFromTemplate(org.eclipse.core.resources.IProject iproject,
                                                                       IlrRuleAppProject sourceRuleAppProject,
                                                                       org.eclipse.core.runtime.IProgressMonitor monitor)
Completes the specified project with the required files by calling the generateProjectContent(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) method. If the project does not exist on disk, it is created. Before the generateProjectContent(org.eclipse.jdt.core.IJavaProject, org.eclipse.core.runtime.IProgressMonitor) method is called, the class path is completed and the RuleApp archive is generated.

Since:
JRules 6.5
Parameters:
iproject - The project to complete.
sourceRuleAppProject - The RuleApp project used to generate the files.
monitor - The progress monitor.
Returns:
The completed project.

setJavaNature

protected void setJavaNature(org.eclipse.core.resources.IProject ijProject)
                      throws org.eclipse.core.runtime.CoreException
Throws:
org.eclipse.core.runtime.CoreException

getUTF8CharsetAsString

protected String getUTF8CharsetAsString()

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013