Rule Execution Server API

ilog.rules.archive
Class IlrRulesetArchiveBuilderBase

java.lang.Object
  extended by ilog.rules.archive.IlrRulesetArchiveBuilderBase
Direct Known Subclasses:
IlrRulesetArchiveBuilder

public class IlrRulesetArchiveBuilderBase
extends Object

Builder of a simple ruleset archive. This class builds an archive without having the engine.jar in the classpath. Therefore, the signature of the ruleset is not computed. The hierarchical property, property type declaration, and rule overriding declaration cannot be managed by this class. The ilog.rules.engine.IlrRulesetArchiveBuilder provides such an API.

Since:
JRules 6.0

Constructor Summary
IlrRulesetArchiveBuilderBase()
          Creates an IlrRulesetArchiveBuilderBase.
 
Method Summary
 void addBusinessModelEntry(String businessModelName, InputStream businessModelStream)
          Adds a business object model to the archive.
 void addDynamicModelEntry(String modelName, InputStream modelStream)
          Adds a dynamic object model to the archive.
 void addFunctionEntry(String pkgName, String fctName, InputStream inputStream)
          Adds a function to the ruleset archive.
 void addFunctionEntry(String pkgName, String fctName, String code)
          Adds a function to the ruleset archive.
 void addIRLEntry(String irlName, InputStream inputStream)
          Stores the given IRL code in a single archive entry in the archive.
 void addMappingEntry(String b2XPath, InputStream bom2XomStream)
          Adds a mapping "Business to Execution" to the archive.
 void addRuleEntry(String pkgName, String ruleName, InputStream inputStream)
          Adds a rule to the ruleset archive.
 void addRuleEntry(String pkgName, String ruleName, String code)
          Adds a rule to the ruleset archive.
 void addRuleflowEntry(String pkgName, String flowName, InputStream inputStream)
          Adds a flow to the ruleset archive.
 void addRuleflowEntry(String pkgName, String flowName, String code)
          Adds a flow to the ruleset archive.
 void addSchema(String schemaNamespace, String name, InputStream inputStream)
          Adds an XSD document to the archive.
 void addSchema(String schemaNamespace, String name, URL location)
          Adds an XSD document URL to the archive.
 void addUserDataEntry(String userDataName, InputStream userDataStream)
          Adds a user data content to the archive.
 void addWsdlEntry(String wsdlName, InputStream wsdlStream)
          Adds a WSDL content to the archive.
 void addXsdEntry(String xsdName, InputStream xsdStream)
          Adds an XSD file to the archive.
protected  void defineCurrentArchiveBusiness(boolean isBusiness)
           
 void enableBusinessXMLService(boolean enable)
           
 IlrRulesetArchive generate()
          Generates the ruleset archive with the contents given through the IlrRulesetArchiveBuilderBase API.
 String getEncoding()
          Returns the encoding used to generate the archive for the archive elements that contain data provided by the user.
 String[] getErrors()
          Returns the errors resulting from the archive building.
 void printErrors()
          Prints errors on the message writer.
 void reset()
          Resets the archive builder.
 void setBusinessModelPath(ArrayList businessModelPath)
          Sets the business object model path.
 void setEncoding(String encoding)
          Sets the encoding used to generate the archive for the archive elements that contain data provided by the user.
 void setEngineConfEntry(InputStream config)
          Sets the engine configuration.
 void setMessageWriter(PrintWriter writer)
          Sets the error message writer of the ruleset archive parser.
 void setVersion(int major, int minor)
          Sets the ruleset archive version with a major and minor version number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlrRulesetArchiveBuilderBase

public IlrRulesetArchiveBuilderBase()
Creates an IlrRulesetArchiveBuilderBase.

Method Detail

setEncoding

public void setEncoding(String encoding)
Sets the encoding used to generate the archive for the archive elements that contain data provided by the user. UTF-8 encoding is used for the XML generated parts.

Parameters:
encoding - The encoding used for the archive.

getEncoding

public String getEncoding()
Returns the encoding used to generate the archive for the archive elements that contain data provided by the user. UTF-8 encoding is used for the XML generated parts.

Returns:
The encoding used for the archive.

reset

public void reset()
Resets the archive builder. It can be used again to generate a new archive with another content.


setMessageWriter

public void setMessageWriter(PrintWriter writer)
Sets the error message writer of the ruleset archive parser.

Parameters:
writer - The writer to which error messages are printed.

addIRLEntry

public void addIRLEntry(String irlName,
                        InputStream inputStream)
Stores the given IRL code in a single archive entry in the archive. This API is specifically provided to store IRL code in the archive that contains different kinds of artifacts. The given stream is closed after its contents have been archived.

Parameters:
irlName - The IRL name used as the entry in the archive.
inputStream - The IRL code as a stream.

addRuleEntry

public void addRuleEntry(String pkgName,
                         String ruleName,
                         String code)
Adds a rule to the ruleset archive. The rule is stored in the archive in the path formed from the package name. For example, for a given package credit.analysis and a given entry name ComputeBenefits, the code is stored in the archive in the path credit/analysis/ComputeBenefits.irl. The given code can contain several rules. The entry name is not used by the engine during parsing. Therefore, there is no obligation to give the rule name as an entry name.

Parameters:
pkgName - The name of the package to which the rule belongs.
ruleName - The entry name.
code - The IRL rule code.

addRuleEntry

public void addRuleEntry(String pkgName,
                         String ruleName,
                         InputStream inputStream)
Adds a rule to the ruleset archive. The rule is stored in the archive in the path formed from the package name. For example, for a given package credit.analysis and a given entry name ComputeBenefits, the code is stored in the archive in the path credit/analysis/ComputeBenefits.irl. The given code can contain several rules. The entry name is not used by the engine during parsing. Therefore, there is no obligation to give the rule name as an entry name. The given stream is closed after its contents have been archived.

Parameters:
pkgName - The name of the package to which the rule belongs.
ruleName - The entry name.
inputStream - The IRL rule code as a stream.

addFunctionEntry

public void addFunctionEntry(String pkgName,
                             String fctName,
                             String code)
Adds a function to the ruleset archive. The function is stored in the archive in the path formed from the package name. For example, for a given package credit.analysis and a given entry identifier computeRate, the code is stored in the archive in the path credit/analysis/computeRate.irl. The given code can contain several functions. The entry name is not used by the engine during parsing. Therefore, there is no obligation to give the function name as an entry name.

Note that the identifier must identify the function without ambiguity; therefore, in most cases this identifier cannot be the function name, but it may be the function signature because you can have several functions with the same name.

Parameters:
pkgName - The name of the package to which the function belongs.
fctName - The entry identifier.
code - The IRL function code.

addFunctionEntry

public void addFunctionEntry(String pkgName,
                             String fctName,
                             InputStream inputStream)
Adds a function to the ruleset archive. The function is stored in the archive in the path formed from the package name. For example, for a given package credit.analysis and a given entry identifier computeRate, the code is stored in the archive in the path credit/analysis/computeRate.irl. The given code can contain several functions. The entry name is not used by the engine during parsing. Therefore, there is no obligation to give the function name as an entry name.

Note that the identifier must identify the function without ambiguity; therefore, in most cases this identifier cannot be the function name, but it may be the function signature because you can have several functions with the same name.

The given stream is closed after its contents have been archived.

Parameters:
pkgName - The name of the package to which the function belongs.
fctName - The entry identifier.
inputStream - The IRL function code as a stream.

addRuleflowEntry

public void addRuleflowEntry(String pkgName,
                             String flowName,
                             String code)
Adds a flow to the ruleset archive. The flow is stored in the archive in the path formed from the package name. The flow can be reduced to only one task or may contain several tasks. There is no constraint on the task type (flowtask, ruletask or functiontask) stored in the archive. For a given package credit.analysis and a given entry identifier ComputeCredit, the code is stored in the archive in the path credit/analysis/ComputeCredit.irl. The entry name is not used by the engine during parsing. Therefore, there is no obligation to give a task name as an entry name.

Parameters:
pkgName - The name of the package to which the ruleflow belongs.
flowName - The entry name.
code - The IRL task code.

addRuleflowEntry

public void addRuleflowEntry(String pkgName,
                             String flowName,
                             InputStream inputStream)
Adds a flow to the ruleset archive. The flow is stored in the archive in the path formed from the package name. The flow can be reduced to only one task or may contain several tasks. There is no constraint on the task type (flowtask, ruletask or functiontask) stored in the archive. For a given package credit.analysis and a given entry identifier ComputeCredit, the code is stored in the archive in the path credit/analysis/ComputeCredit.irl. The entry name is not used by the engine during parsing. Therefore, there is no obligation to give a task name as an entry name. The given stream is closed after its contents have been archived.

Parameters:
pkgName - The name of the package to which the ruleflow belongs.
flowName - The entry name.
inputStream - The IRL task code as a stream.

setVersion

public void setVersion(int major,
                       int minor)
Sets the ruleset archive version with a major and minor version number.

Parameters:
major - The major number of the version.
minor - The minor number of the version.

setEngineConfEntry

public void setEngineConfEntry(InputStream config)
Sets the engine configuration. The given stream is closed after its contents have been archived.

Parameters:
config - The stream that contains the engine configuration.

defineCurrentArchiveBusiness

protected void defineCurrentArchiveBusiness(boolean isBusiness)

setBusinessModelPath

public void setBusinessModelPath(ArrayList businessModelPath)
Sets the business object model path. This path is composed of a list of java.lang.Strings. It indicates the order in which the business models are loaded. Providing this information is mandatory as soon as there is at least one business model, to ensure the model loading.

Parameters:
businessModelPath - The business object model path to set.

addBusinessModelEntry

public void addBusinessModelEntry(String businessModelName,
                                  InputStream businessModelStream)
Adds a business object model to the archive. The business object model is characterized by its name and contents in a stream. There is a strong relationship between the business object names and the business object model path: the path elements are considered to be object model names. The given stream is closed after its contents have been archived.

Parameters:
businessModelName - The business object model name.
businessModelStream - The stream that contains the business object model.

addMappingEntry

public void addMappingEntry(String b2XPath,
                            InputStream bom2XomStream)
Adds a mapping "Business to Execution" to the archive. The mapping is characterized by its name and contents in a stream. There is a strong relationship between the business object model name and the mapping name. For example, for a given model.bom business object model name, the mapping name must be model.b2x. The mappings are loaded in the order defined by the business object model path. The given stream is closed after its contents have been archived.

Parameters:
b2XPath - The mapping name.
bom2XomStream - The stream that contains the BOM to XOM mapping.

addDynamicModelEntry

public void addDynamicModelEntry(String modelName,
                                 InputStream modelStream)
Adds a dynamic object model to the archive. The model is characterized by its name and contents in a stream. The given stream is closed after its contents have been archived.

Parameters:
modelName - The model name.
modelStream - The stream that contains the model.

enableBusinessXMLService

public void enableBusinessXMLService(boolean enable)

addXsdEntry

public void addXsdEntry(String xsdName,
                        InputStream xsdStream)
Adds an XSD file to the archive. The content of the XSD is not used during the archive parsing; they are just stored in the archive for user access. The XSD is characterized by its name and contents in a stream. The given stream is closed after its contents have been archived.

Parameters:
xsdName - The XSD name.
xsdStream - The stream that contains the XSD.

addSchema

public void addSchema(String schemaNamespace,
                      String name,
                      InputStream inputStream)
Adds an XSD document to the archive. The content of the XSD is not used during the archive parsing; they are just stored in the archive for user access.

Since:
JRules 6.5
Parameters:
schemaNamespace - of the XSD document
name - name used to identified the document.
inputStream - open stream to the document.

addSchema

public void addSchema(String schemaNamespace,
                      String name,
                      URL location)
Adds an XSD document URL to the archive. The content of the XSD is not inserted inside the archive.

Since:
JRules 6.5
Parameters:
schemaNamespace - of the XSD document.
name - name used to identified the document.
location - URL to the XSD document.

addWsdlEntry

public void addWsdlEntry(String wsdlName,
                         InputStream wsdlStream)
Adds a WSDL content to the archive. The content of the WSDL is not used during the archive parsing; it is just stored in the archive for user access. The WSDL is characterized by its name and contents in the stream. The given stream is closed after its contents have been archived.

Parameters:
wsdlName - The WSDL name.
wsdlStream - The stream that contains the WSDL.

addUserDataEntry

public void addUserDataEntry(String userDataName,
                             InputStream userDataStream)
Adds a user data content to the archive. The content is not used during the archive parsing; they are just stored in the archive for user access. The data is characterized by its name and contents in the stream. The given stream is closed after its contents have been archived.

Parameters:
userDataName - The user data name.
userDataStream - The stream that contains the user data

generate

public IlrRulesetArchive generate()
Generates the ruleset archive with the contents given through the IlrRulesetArchiveBuilderBase API. The data is stored with the specified encoding; in case no encoding has been specified, UTF-8 is used by default.

Returns:
An IlrRulesetArchive that contains all artifacts, models, and configurations passed by the API.

getErrors

public String[] getErrors()
Returns the errors resulting from the archive building.

Returns:
An array containing the errors stored during the archive building.

printErrors

public void printErrors()
Prints errors on the message writer. In case no message writer has been specified, System.out is taken by default.


Rule Execution Server API

© Copyright IBM Corp. 1987, 2013