Oracle Fusion Middleware Java API Reference for Oracle Business Rules
11g Release 1 (11.1.1.7)

E10663-11

oracle.rules.sdk2.dictionary
Class RuleDictionary

java.lang.Object
  extended by oracle.rules.sdk2.dictionary.DictionaryObject
      extended by oracle.rules.sdk2.dictionary.DictionaryComponent
          extended by oracle.rules.sdk2.dictionary.DictionaryName
              extended by oracle.rules.sdk2.dictionary.RuleDictionary
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.String,java.lang.Object>

public class RuleDictionary
extends DictionaryName

The RuleDictionary class is used to access and modify a rule dictionary in memory. A rule dictionary contains a data model, rule sets, and links to other rule dictionaries.

RuleDictionary does not provide any concurrency properties. Multiple threads may access a single RuleDictionary instance, but each thread must use its own handle.

Transactions

A transaction consists of all changes made to DictionaryObjects in between invocations of RuleDictionary.update(java.util.List). Transactions can be undone and redone using the UndoableEdit instance returned from a call to update.

A handle can be created using the RuleDictionary.createHandle() method. An application would have a single RuleDictionary instance which was newly created or read from a persistent store. This is then shared among shared among different readers or writers by providing each with a RuleDictionary handle created from calling RuleDictionary.createHandle(). Note that both the instance and handles use the same RuleDictionary class. The changes in a transaction are stored in the local RuleDictionary handle and then moved to the shared RuleDictionary instance when RuleDictionary.update(java.util.List) is called. Note:When multiple threads are modifying their handle, an SDKException will be thrown if update is called and another handle has called update since the current handle's last call to update.

It also means that an update may fail with a ConcurrentUpdateException if two updates happen nearly simultaneously. In either case, the transaction should be rolled back using RuleDictionary.rollback().

If concurrent editing is desired, it is recommended that applications implement their own concurrent editing semantics on top of the provided primitives. Take note that allowing truly concurrent editing is very difficult because users can make incompatible changes to a dictionary. In many cases, allowing exclusive access to only one writer at a time is easier to implement and easier to manage in practice.

Note that a thread that only reads from it's handle must periodically call RuleDictionary.rollback() or RuleDictionary.update(java.util.List) in order to see the latest contents of the main dictionary(even though it has made no changes).

A transaction only covers updates to the main RuleDictionary instance. It does not cover saving the dictionary to a persistent store. In particular, do not save more than one in-memory rule dictionary to the same persistent store. The second save will overwrite the first.

Dictionary Links

Rule dictionaries can link to other rule dictionaries. These links allow a large dictionary to be partitioned into several smaller dictionaries. This affords reuse of a shared data model, or partitioning sensitive rules into a dictionary with stricter access control. For more information see DictionaryLink.

DictionaryObject references and removing DictionaryObjects from the Dictionary

The RuleDictionary is a container for the dictionary objects it contains, e.g., the RuleDictionary.getRuleSet(String) method returns a RuleSet object, and then RuleSet.getRuleByName(String) is a factory that returns a Rule object, and so forth.

DictionaryComponentTable implements List methods like remove. When a DictionaryObject is removed, subsequent attempts to access properties of the dictionary object will result in a RuntimeException.

Usage Examples

The following examples show how to use the RuleDictionary.

create a new rule dictionary in memory

 RuleDictionary dic = RuleDictionary.createDictionary("MyDic");
 

create a ruleset in the dictionary

The example assumes that multiple handles may be updating the Dictionary concurrently. Because the concurrency control is optimistic and does not use locks, the RuleDictionary users must be prepared to retry their updates. Below is a naive example of doing this, using a while(true) loop.
 RuleDictionary.UndoableEdit undo = null;
 List warnings = new ArrayList();
 while (true) {
   RuleSet rs = dic.createEmptyRuleSet("newRuleSet");
   rs.setDescription("my favorite rules");
   try {
      undo = dic.update(warnings);
   }
   catch (ConcurrentUpdateException e) {
      dic.rollback();
      continue;
   }
   catch (SDKException e) {
      dic.rollback();
      continue;
   }
   break;
 }
 

Get a ruleset from the dictionary

Readers should begin with an update, commit, or rollback to ensure they see the latest dictionary updates.
 UndoableEdit undo = dic.update(warnings); // even if we haven't modified the dictionary, update returns unresolved prior warnings...
 RuleSet rs = dic.getRuleSet("newRuleSet");
 assert rs != null;
 

Undo the addition of newRuleSet

 undo.undo();
 

The dictionary has no rulesets now

 dic.rollback(); // another way to sync up with the latest in-memory dictionary content
 RuleSet rs = dic.getRuleSet("newRuleSet");
 assert rs == null;
 

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class oracle.rules.sdk2.dictionary.DictionaryComponent
DictionaryComponent.Diff, DictionaryComponent.DiffType
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class oracle.rules.sdk2.dictionary.DictionaryComponent
PROP_ACCESS, PROP_ACTION_SELECTED, PROP_ACTION_TABLE, PROP_ACTIVE, PROP_ADVANCED_MODE, PROP_AGGREGATE, PROP_AGGREGATE_TABLE, PROP_ALIAS, PROP_ALLOW_GAPS, PROP_ALWAYS_SELECTED, PROP_ARRAY, PROP_ARRAY_COMPONENT_TYPE, PROP_ARRAY_COMPONENT_TYPE_ID, PROP_ARRAY_FACT_TYPE_TABLE, PROP_AUTO_CONFLICT_RESOLUTION, PROP_AUTO_PATTERN_PROPERTY, PROP_BODY, PROP_BUCKET_ID_TABLE, PROP_BUCKET_SET, PROP_BUCKET_SET_ID, PROP_BUCKET_SET_TABLE, PROP_BUCKET_TABLE, PROP_CALENDAR_FORM, PROP_CHECK_RULE_FLOW, PROP_CHILD_DIMENSION_NODES, PROP_CONFLICT, PROP_CONFLICT_POLICY, PROP_CONNECTIVE, PROP_CONSTANT, PROP_CONSTRUCTOR, PROP_CONSTRUCTOR_TABLE, PROP_CREATION_UPDATE_NUMBER, PROP_CURSOR_POSITION, PROP_CUSTOM_BINDING, PROP_CUSTOMIZABLE, PROP_CUSTOMIZABLE_TEMPLATE, PROP_DATA_MODEL, PROP_DATA_SOURCE, PROP_DECISION_FUNCTION, PROP_DECISION_FUNCTION_INPUT_TABLE, PROP_DECISION_FUNCTION_OUTPUT_TABLE, PROP_DECISION_FUNCTION_RULESET_TABLE, PROP_DECISION_FUNCTION_TABLE, PROP_DESCRIPTION, PROP_DICTIONARY_LINK_TABLE, PROP_DIMENSION_NODE_TABLE, PROP_DIMENSION_TABLE, PROP_DT_ACTION_NODE_TABLE, PROP_DT_ACTION_PARAMETER_NAME, PROP_DTACTION_TABLE, PROP_DTRULE_TABLE, PROP_EFFECTIVE_END_DATE, PROP_EFFECTIVE_START_DATE, PROP_ENUM, PROP_ENUM_BUCKET_SET, PROP_ENUM_BUCKET_SET_ID, PROP_ENUM_TYPE, PROP_EXCEPTION_IDS, PROP_EXCEPTIONS, PROP_EXCLUDED, PROP_EXPRESSION, PROP_EXPRESSION_TABLE, PROP_FACT_PATH, PROP_FACT_PATH_IDS, PROP_FACT_TYPE, PROP_FACT_TYPE_ID, PROP_FACT_TYPE_TABLE, PROP_FIELD_TABLE, PROP_FINAL, PROP_FORM, PROP_FORMAL_PARAMETER_TABLE, PROP_FUNCTION, PROP_FUNCTION_ID, PROP_FUNCTION_SIGNATURE, PROP_FUNCTION_TABLE, PROP_GENERATED_FROM, PROP_ID, PROP_INCLUDED, PROP_INTERFACE, PROP_INTERFACE_IDS, PROP_INTERFACES, PROP_IS_ABSTRACT, PROP_IS_CONSTANT, PROP_IS_ENUM, PROP_IS_FINAL, PROP_IS_JAXB2, PROP_IS_PRIMARY_KEY, PROP_IS_STATIC, PROP_IS_TOPLEVEL_VIEW_OBJECT, PROP_LEFT, PROP_LIFECYCLE, PROP_LIFECYCLE_DESCRIPTION, PROP_LIST, PROP_LIST_CONTENT_TYPE, PROP_LIST_CONTENT_TYPE_ID, PROP_LOCAL, PROP_LOGICAL, PROP_METHOD_TABLE, PROP_MODIFIERS, PROP_NAME, PROP_NAMESPACE, PROP_NESTED_TABLE, PROP_NO_CONFLICT, PROP_NODE_NAME, PROP_OPERATOR, PROP_OPERATOR_ID, PROP_ORDER_RULES_BY_BUCKET, PROP_OTHERWISE, PROP_OUTPUT_TYPES, PROP_OVERLOADED_PARAMETER_TABLE, PROP_OVERRIDDEN_BY, PROP_OVERRIDE, PROP_PACKAGE, PROP_PARAMETER_ALIAS, PROP_PARAMETER_ID, PROP_PARAMETER_LIST, PROP_PARAMETER_NAME, PROP_PARAMETER_REQUIRED, PROP_PARAMETER_TYPE_IDS, PROP_PARAMETER_TYPES, PROP_PARENT_DIMENSION_NODE, PROP_PATTERN_TABLE, PROP_PREFIX_LINKED_NAMES, PROP_PRIORITY, PROP_PRIVATE_BUCKET_SET, PROP_PROPERTIES, PROP_PROPERTY_TABLE, PROP_READABLE, PROP_REF_ID, PROP_REPORT_BYUSE_NAMES, PROP_REPORT_PATTERNS, PROP_RESOLVED_TARGET, PROP_RESOLVED_VALUE, PROP_RESOURCE_BUNDLE, PROP_RETURN_TYPE, PROP_RIGHT, PROP_RIGHT_SEPARATOR, PROP_RULE_FIRING_LIMIT, PROP_RULE_FIRING_LIMIT_ERROR, PROP_RULE_REPORT_TABLE, PROP_RULE_SET_TABLE, PROP_RULE_SHEET_TABLE, PROP_RULE_TABLE, PROP_RULESET, PROP_RUN_AFTER, PROP_RUN_BEFORE, PROP_SERVICE_CONFIGURATION, PROP_SERVICE_NAME, PROP_SERVICE_NAMESPACE, PROP_SHARED_BUCKET_SET, PROP_SHARED_BUCKET_SET_ID, PROP_SHOW_CONSTANTS, PROP_SHOW_FUNCTIONS, PROP_SHOW_VARIABLES, PROP_SIMPLE_TEST_TABLE, PROP_SOURCE, PROP_STATELESS, PROP_STATIC, PROP_SUPER_CLASS, PROP_SUPER_CLASS_ID, PROP_SUPPORT_XPATH, PROP_SUPPORTS_XPATH_ENABLED, PROP_SYSTEM, PROP_TARGET, PROP_TARGET_PACKAGE, PROP_TEST_FORM, PROP_TIMESTAMP, PROP_TOKEN_UNDER_CURSOR, PROP_TRANSLATED_ALIAS, PROP_TRANSLATED_DESCRIPTION, PROP_TRANSLATED_PARAMETER_LIST, PROP_TRANSLATED_VARIABLE, PROP_TREE, PROP_TREE_MODE, PROP_TYPE, PROP_TYPE_ID, PROP_TYPE_IDS, PROP_TYPES, PROP_UNSAVED_TRANSLATED_ALIAS, PROP_UNSAVED_TRANSLATED_DESCRIPTION, PROP_UPDATE_NUMBER, PROP_UPDATE_TIME, PROP_VALIDATION_UPDATE_NUMBER, PROP_VALUE, PROP_VALUES, PROP_VARIABLE, PROP_VARIABLE_TABLE, PROP_VERSION, PROP_VISIBILITY_FILTER, PROP_VISIBILITY_FILTER_ENABLED, PROP_VISIBLE, PROP_WEB_SERVICE, PROP_WRITABLE, PROP_XML_NAME
 
Method Summary
 java.lang.Object addDictionaryChangeListener(DictionaryChangeListener listener)
          Add a DictionaryChangeListener to receive notifications of dictionary changes via DictionaryChangeEvents.
 void copyTo(RuleDictionary from)
          copy to this dictionary
static RuleDictionary createDictionary(java.lang.String name, DictionaryFinder finder)
          Create a new rule dictionary.
 DictionaryLink createDictionaryLink(java.lang.String pkg, java.lang.String name)
          Create a DictionaryLink and add it into the rule dictionary.
 RuleSet createEmptyRuleSet(java.lang.String name)
          Create and return an empty RuleSet with the given name.
 RuleDictionary createHandle()
          Get a handle to access the dictionary.
 java.lang.String dataModelRL()
          Generate the RL for the data model in this dictionary and in linked dictionaries.
 void diff(RuleDictionary that, java.lang.Object versionInfo)
          Compute the difference between this dictionary and that one, identified by versionInfo.
 java.lang.String formatNumber(java.lang.Number n)
           
 java.lang.String getAliasByID(DOID id)
          Get alias of DictionaryComponent by its ID.
 java.lang.String getAliasByID(DOID id, boolean translate)
          Get (translated) alias by ID
static RuleDictionary getBuiltinDictionary()
          get builtin rule dictionary
 CombinedDataModel getCombinedDataModel()
          Get accessor for data model components in the combined dictionary DO NOT CACHE the result of this method across RuleDictionary.update(java.util.List) calls.
 DataModel getDataModel()
          Get the datamodel from this dictionary.
 DictionaryProperty<DataModel> getDataModelProperty()
          Get DataModel Property.
 java.util.List<RuleDictionary> getDictionaries()
          get this dictionary and all linked dictionaries.
 RuleDictionary getDictionary(java.lang.String alias)
          Get Dictionary from all linked dictionaries by alias
 java.lang.String getDictionaryDescription()
          Get description of the dictionary.
 DictionaryFinder getDictionaryFinder()
          get the finder for linked dictionaries
 DictionaryLink getDictionaryLink(java.lang.String alias)
          Get the dictionary link by alias.
 DictionaryLink getDictionaryLink(java.lang.String pkg, java.lang.String name)
          Get the dictionary link by fully qualified name.
 java.util.List<java.lang.String> getDictionaryLinkAliases()
          Get a List of DictionaryLink Aliases that are currently stored in in the RuleDictionary (in-memory copy).
 DictionaryLinkTable getDictionaryLinkTable()
          Get the dictionary link table
 TableProperty<DictionaryLink> getDictionaryLinkTableProperty()
          Get DictionaryLinkTable Property.
 java.lang.String getFullyQualifiedNameByID(DOID id)
          Get fully qualified name of DictionaryComponent by its ID.
 java.lang.String getLifeCycle()
          Get the dictionary life cycle
 java.lang.String getLifeCycleDescription()
          Get the dictionary life cycle description
 java.util.List<RuleDictionary> getLinkedDictionaries()
          get all linked dictionaries (recursively) but not this one.
 java.util.Locale getLocale()
          get the locale that was set for this dictionary.
 java.lang.String getNameByID(DOID id)
          Get name of DictionaryComponent by its ID.
 java.text.NumberFormat getNumberFormat()
          Get the NumberFormat for this RuleDictionary instance.
 DictionaryObject getObjectByID(DOID id)
          Get dictionary object by its ID.
 java.lang.String getResourceBundle()
          Get the name of the user resource bundle for UserTranslatedPropertys.
 java.util.ResourceBundle.Control getResourceBundleControl()
          Get the user resource bundle control for TranslatedPropertys.
 RuleSet getRuleSet(java.lang.String alias)
          Get the ruleset by alias from this dictionary
 java.util.List<java.lang.String> getRuleSetAliases(boolean combined)
          Get a List of RuleSet Aliases that are currently stored in in the RuleDictionary.
 java.lang.String[] getRuleSetOptions()
          Get rulesets in dictionary (and linked dictionaries) as an option list
 java.util.List<RuleSet> getRuleSets(boolean combined)
          Get a List of RuleSets that are currently stored in in the RuleDictionary.
 java.util.List<RuleSet> getRuleSets(java.lang.String alias)
          Get the rulesets by alias from this dictionary and linked dictionaries.
 RuleSetTable getRuleSetTable()
          Get the ruleset table.
 TableProperty<RuleSet> getRuleSetTableProperty()
          Get RuleSetTable Property.
 java.lang.String getServiceConfiguration()
           
 java.lang.String getServiceName()
          get name of decision service exposing this dictionary's decision functions
 java.lang.String getServiceNamespace()
           
 java.lang.String[][] getSynopsis()
          Get a synopsis of the dictionary contents.
 java.lang.String getTranslatedAliasByID(DOID id)
          Get translated alias by ID
 java.util.List<SDKWarning> getWarnings(boolean includeDescendants)
          get Warnings associated with this dictionary object or its descendants.
 boolean isCustomizationMode()
          Is customization mode turned on?
 boolean isTransactionInProgress()
           
 boolean isValid()
          is the dictionary valid?
 java.lang.Number parseNumber(java.lang.String value)
          Parse a number.
 boolean processDecisionTrace(DecisionTrace trace)
           
static boolean processDecisionTrace(DecisionTrace trace, RuleDictionary dict)
           
static RuleDictionary readDictionary(java.io.Reader reader, DictionaryFinder finder)
          Read a RuleDictionary from a Reader.
 java.lang.Object removeDictionaryChangeListener(DictionaryChangeListener listener)
          Remove DictionaryChangeListener.
 DictionaryLink removeDictionaryLink(java.lang.String alias)
          Remove dictionary link by name.
 boolean removeDiff(java.lang.Object versionInfo)
          Remove all the Diff information associated with versionInfo.
 RuleSet removeRuleSet(java.lang.String name)
          Remove ruleset by name.
 void resourceBundleChanged()
          If the resource bundle file is changed, call this method, followed by RuleDictionary.update(java.util.List), to cause the SDK to re-read the bundle
 void rollback()
          rollback the current update transaction.
 java.lang.String ruleSetRL(java.lang.String alias)
          Generate the RL for the given rule set in this dictionary and in linked dictionaries.
 void setCustomizationMode(boolean flag)
          Set customization mode.
 void setDictionaryDescription(java.lang.String desc)
          Set description to the dictionary.
 void setDictionaryFinder(DictionaryFinder finder)
          set the finder for linked dictionaries
 void setLifeCycle(java.lang.String lifecycle)
          Set the dictionary life cycle
 void setLifeCycleDescription(java.lang.String description)
          Set the dictionary life cycle description
 void setLocale(java.util.Locale locale)
          set the locale.
 void setResourceBundle(java.lang.String name)
          Set the name of the user resource bundle for UserTranslatedPropertys.
 void setResourceBundleControl(java.util.ResourceBundle.Control control)
          Set the user resource bundle control for TranslatedPropertys.
 void setServiceConfiguration(java.lang.String sc)
           
 void setServiceName(java.lang.String sn)
           
 void setServiceNamespace(java.lang.String sn)
           
 UndoableEdit update(java.util.List<SDKWarning> exceptions)
          Update the RuleDictionary.
 void validate(java.util.List<SDKException> errors, java.util.List<SDKWarning> warnings)
          Validate and append errors and warnings.
 void writeDictionary(java.io.Writer writer)
          Write a RuleDictionary to a Writer.
 
Methods inherited from class oracle.rules.sdk2.dictionary.DictionaryName
getFullyQualifiedName, getPackage, getPackageProperty, isFullyQualifiedName, setPackage
 
Methods inherited from class oracle.rules.sdk2.dictionary.DictionaryComponent
clear, containsKey, containsValue, entrySet, get, getAlias, getAlias, getAlias, getAlias, getAliasProperty, getAllReferences, getCustom, getDependents, getDescription, getDescription, getDescriptionProperty, getDiff, getDiffProperties, getDiffs, getFullyQualifiedAlias, getIndex, getIndex, getName, getNameProperty, getNext, getObjectPath, getOptions, getPrevious, getProperties, getProperty, getReferences, getSelected, getTranslatedAlias, getTranslatedAlias, getTranslatedDescription, hasDiff, init, init, isAliasDistinct, isEmpty, isNameDistinct, isSystemProperty, isUnsavedTranslatedAlias, isUnsavedTranslatedDescription, keySet, put, putAll, remove, setAlias, setAlias, setCustom, setDescription, setDescription, setName, setTranslatedAlias, setTranslatedDescription, size, validate, values
 
Methods inherited from class oracle.rules.sdk2.dictionary.DictionaryObject
equals, exists, getAEReferences, getContainedIDs, getContainedIDs, getDictionary, getID, getIndent, getLevel, getObjectType, getParentByClass, getParentComponent, getParentComponentTable, getParentObject, getRuleSet, getState, hashCode, isModified, validate
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Method Detail

isCustomizationMode

public boolean isCustomizationMode()
Is customization mode turned on? In this mode, only the following properties may be edited


setCustomizationMode

public void setCustomizationMode(boolean flag)
Set customization mode. See RuleDictionary.isCustomizationMode().


getDictionaryFinder

public DictionaryFinder getDictionaryFinder()
get the finder for linked dictionaries

Returns:
DictionaryFinder

setDictionaryFinder

public void setDictionaryFinder(DictionaryFinder finder)
set the finder for linked dictionaries


getLocale

public java.util.Locale getLocale()
get the locale that was set for this dictionary. The locale controls nls specific behavior of any methods that return a language specific String (e.g., FunctionTemplates).


setLocale

public void setLocale(java.util.Locale locale)
set the locale. The locale controls which nls specific version of Strings and formatted numbers will be used


parseNumber

public java.lang.Number parseNumber(java.lang.String value)
Parse a number. If in double quotes, parse according to the dictionary Locale

Parameters:
value - to parse
Returns:
Number or null

formatNumber

public java.lang.String formatNumber(java.lang.Number n)

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Get the NumberFormat for this RuleDictionary instance. One could use this to change the decimal separator, e.g. if (dictionary.getNumberFormat() instanceof DecimalFormat) { DecimalFormat df = (DecimalFormat)dictionary.getNumberFormat(); DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); dfs.setDecimalSeparator(','); df.setDecimalFormatSymbols(dfs); }

The number format will change when the dictionary locale is changed. Changes to decimal format symbols will be overwritten when the locale is changed.

Returns:
NumberFormat

getObjectByID

public DictionaryObject getObjectByID(DOID id)
Get dictionary object by its ID. Every DictionaryComponent has a persistent ID. DictionaryObjects have a temporary ID that is stable across transactions but not across save/load from file.

If ID is global (starts with "G"), then linked dictionaries are searched as well. If ID is builtin (starts with "B"), then only the builtin dictionary is searched.

Parameters:
id - the ID of the DictionaryObject
Returns:
the Dictionary Object, or null if no object with the ID is in the dictionary

getAliasByID

public final java.lang.String getAliasByID(DOID id)
Get alias of DictionaryComponent by its ID. Prepends containing dictionary alias if not this. A null parameter will throw a NullPointerException.

Parameters:
id - String
Returns:
alias, or Java name if id does not map to DictionaryComponent and isJavaID, else ""

getAliasByID

public final java.lang.String getAliasByID(DOID id,
                                           boolean translate)
Get (translated) alias by ID

Parameters:
id - of DictionaryComponent
translate - flag
Returns:
alias, optionally translated, or Java name if that's all we have

getTranslatedAliasByID

public final java.lang.String getTranslatedAliasByID(DOID id)
Get translated alias by ID

Parameters:
id - of DictionaryComponent
Returns:
translated alias or "" if none

getNameByID

public java.lang.String getNameByID(DOID id)
Get name of DictionaryComponent by its ID. A null parameter will throw a NullPointerException.

Parameters:
id - String
Returns:
name, or "" if id does not map to DictionaryComponent

getFullyQualifiedNameByID

public java.lang.String getFullyQualifiedNameByID(DOID id)
Get fully qualified name of DictionaryComponent by its ID. A null parameter will throw a NullPointerException

Parameters:
id - String
Returns:
name, or "" if id does not map to DictionaryComponent

readDictionary

public static RuleDictionary readDictionary(java.io.Reader reader,
                                            DictionaryFinder finder)
                                     throws SDKException,
                                            java.io.IOException
Read a RuleDictionary from a Reader.

The content of the Reader should have been produced by a prior call to RuleDictionary.writeDictionary(java.io.Writer). Warning: The returned RuleDictionary has not been updated or validated, and therefore some information may be missing or incorrect. Most users should immediately invoke RuleDictionary.update(List) on the returned RuleDictionary.

The Reader parameter should be configured to read the UTF-8 character set. For example, if the dictionary is being read from a file, a common construction would look like:

     Reader reader = new BufferedReader( 
                       new InputStreamReader( 
                           new FileInputStream( 
                               new File(DICT_LOCATION)), "UTF-8"));
 

This method does not close the Reader instance passed to it. It is the responsibility of the caller to close the Reader (typically in a finally block) to prevent a resource leak.

Parameters:
reader - containing a rule dictionary document
finder - to find linked dictionaries
Returns:
RuleDictionary
Throws:
SDKException - if the dictionary can't be deserialized
java.io.IOException - if can't read from Reader

createDictionary

public static RuleDictionary createDictionary(java.lang.String name,
                                              DictionaryFinder finder)
                                       throws SDKException
Create a new rule dictionary.

Parameters:
name - dictionary name
finder - finder for linked dictionaries
Throws:
SDKException

writeDictionary

public void writeDictionary(java.io.Writer writer)
                     throws SDKException,
                            java.io.IOException
Write a RuleDictionary to a Writer.

Warning: Rule dictionaries containing validation warnings can be written, just as Java source files with compilation errors can be saved. It is the responsibility of user to ensure a dictionary is valid before it is deployed in an application.

The Writer parameter should be configured to write the UTF-8 character set.

For example, if the dictionary was to be written to the same file it was read from, a common construction would look like:

     StringWriter swriter = new StringWriter();
     rd.writeDictionary(swriter);
     Writer writer = null;
     try {
         writer = new OutputStreamWriter(new FileOutputStream(new File(fileName)),"UTF-8");
         writer.write(swriter.toString());
     } finally {
         if (writer != null) try { writer.close(); } catch (IOException e) {}
     }
 

Here we first write the dictionary to a StringWriter to ensure no SDKExceptions are thrown; If instead we first opened the File for writing and an SDKException was thrown, the file would have already been truncated on most platforms. With the above code, this will only happen if an IOException is thrown in the the call to write. If this method is to be used in production code, it is recommended that the user first makes a backup copy of the file before attempting to write to it in order to prevent losing the file if an IOException occurs.

This method does not close the Writer instance passed to it. It is the responsibility of the caller to close the Writer (typically in a finally block) to prevent a resource leak.

Parameters:
writer - write the dictionary here
Throws:
SDKException - if the dictionary can't be serialized
java.io.IOException - if can't write to writer

createHandle

public RuleDictionary createHandle()
                            throws SDKException
Get a handle to access the dictionary. Every concurrent thread should have its own handle. Usually, there is only 1 concurrent thread, so this is not a frequently used method. If 2 or more concurrent threads, all but one should be read-only. A handle is a clone of the original dictionary.

Returns:
RuleDictionary
Throws:
SDKException - if the dictionary is invalid
See Also:
RuleDictionary.clone()

getDictionaryDescription

public java.lang.String getDictionaryDescription()
Get description of the dictionary.

Returns:
Description of the dictionary. "" if the dictionary does not have a description.

setDictionaryDescription

public void setDictionaryDescription(java.lang.String desc)
Set description to the dictionary.

Parameters:
desc - description of the dictionary.

isTransactionInProgress

public boolean isTransactionInProgress()
Returns:
true if a transaction is in progress (modifications have occurred)

update

public UndoableEdit update(java.util.List<SDKWarning> exceptions)
                    throws SDKException,
                           ConcurrentUpdateException
Update the RuleDictionary. If exceptions is not null, validation exceptions that can be tolerated in the dictionary are returned rather than thrown, and the update succeeds. The update is atomic. If exceptions are thrown, no updates are performed. Note that readers must call update() to see updates that occur after their first read.

Parameters:
exceptions - a List of exceptions to append to.
Returns:
UndoableEdit object that can be used to undo/redo the update.
Throws:
SDKException - if invalid and exceptions is null.
ConcurrentUpdateException - if this dictionary version was updated by another thread.

validate

public void validate(java.util.List<SDKException> errors,
                     java.util.List<SDKWarning> warnings)
Description copied from class: DictionaryComponent
Validate and append errors and warnings.

Overrides:
validate in class DictionaryComponent
Parameters:
errors - a List of error exceptions to append to.
warnings - a List of warning exceptions to append to.
See Also:
DictionaryObject.validate(List,List,int,int)

getDictionaries

public java.util.List<RuleDictionary> getDictionaries()
get this dictionary and all linked dictionaries. the main (builtin) dictionary is last.

Returns:
List of RuleDictionary

getDictionary

public RuleDictionary getDictionary(java.lang.String alias)
Get Dictionary from all linked dictionaries by alias

Parameters:
alias - of dictionary
Returns:
RuleDictionary

getLinkedDictionaries

public java.util.List<RuleDictionary> getLinkedDictionaries()
get all linked dictionaries (recursively) but not this one. the main dictionary is last.

Returns:
List of RuleDictionary

getDataModelProperty

public DictionaryProperty<DataModel> getDataModelProperty()
Get DataModel Property.

Returns:
DataModel DictionaryProperty

getDataModel

public DataModel getDataModel()
Get the datamodel from this dictionary.

Overrides:
getDataModel in class DictionaryObject
Returns:
DataModel

getCombinedDataModel

public CombinedDataModel getCombinedDataModel()
Get accessor for data model components in the combined dictionary DO NOT CACHE the result of this method across RuleDictionary.update(java.util.List) calls.

Overrides:
getCombinedDataModel in class DictionaryObject
Returns:
CombinedDataModel

createEmptyRuleSet

public RuleSet createEmptyRuleSet(java.lang.String name)
Create and return an empty RuleSet with the given name.

Parameters:
name - of ruleset to create
Returns:
new empty ruleset or null if ruleset already exists

getRuleSetAliases

public java.util.List<java.lang.String> getRuleSetAliases(boolean combined)
Get a List of RuleSet Aliases that are currently stored in in the RuleDictionary.

The list is ordered by Java String comparison.

Parameters:
combined - whether to get rule set aliases from linked dictionaries
Returns:
Array of RuleSet aliases

getRuleSets

public java.util.List<RuleSet> getRuleSets(boolean combined)
Get a List of RuleSets that are currently stored in in the RuleDictionary. If combined, then several dictionaries can contain a ruleset with the same alias. Only the first ruleset encountered is returned, so that all the returned rulesets have distinct aliases.

The list is ordered by Java String comparison.

Parameters:
combined - whether to get rule sets from linked dictionaries
Returns:
List of RuleSets

getRuleSet

public RuleSet getRuleSet(java.lang.String alias)
Get the ruleset by alias from this dictionary

Parameters:
alias - ruleset alias

getRuleSets

public java.util.List<RuleSet> getRuleSets(java.lang.String alias)
Get the rulesets by alias from this dictionary and linked dictionaries.

Parameters:
alias - ruleset alias

getRuleSetTableProperty

public TableProperty<RuleSet> getRuleSetTableProperty()
Get RuleSetTable Property.

Returns:
RuleSet TableProperty

getRuleSetTable

public RuleSetTable getRuleSetTable()
Get the ruleset table.

Returns:
RuleSetTable

removeRuleSet

public RuleSet removeRuleSet(java.lang.String name)
Remove ruleset by name.

Parameters:
name - ruleset to remove
Returns:
RuleSet removed

createDictionaryLink

public DictionaryLink createDictionaryLink(java.lang.String pkg,
                                           java.lang.String name)
Create a DictionaryLink and add it into the rule dictionary.

Parameters:
pkg - package of the linked dictionary
name - name of the linked dictionary
Returns:
the newly created DictionaryLink

getDictionaryLink

public DictionaryLink getDictionaryLink(java.lang.String pkg,
                                        java.lang.String name)
Get the dictionary link by fully qualified name.

Parameters:
name - name

getDictionaryLink

public DictionaryLink getDictionaryLink(java.lang.String alias)
Get the dictionary link by alias.

Parameters:
alias - dictionary link alias

getDictionaryLinkTableProperty

public TableProperty<DictionaryLink> getDictionaryLinkTableProperty()
Get DictionaryLinkTable Property.

Returns:
DictionaryLink TableProperty

getDictionaryLinkTable

public DictionaryLinkTable getDictionaryLinkTable()
Get the dictionary link table

Returns:
OptionsSetTable

removeDictionaryLink

public DictionaryLink removeDictionaryLink(java.lang.String alias)
Remove dictionary link by name.

Parameters:
alias - of linked dictionary to remove
Returns:
RuleSet removed

isValid

public boolean isValid()
is the dictionary valid?

Returns:
boolean result

getDictionaryLinkAliases

public java.util.List<java.lang.String> getDictionaryLinkAliases()
Get a List of DictionaryLink Aliases that are currently stored in in the RuleDictionary (in-memory copy).

Returns:
List of DictionaryLink names

dataModelRL

public java.lang.String dataModelRL()
                             throws SDKException
Generate the RL for the data model in this dictionary and in linked dictionaries. The RL will be contained in a rule set with the same name as the immediately containing dictionary. In order to execute a rule set from the dictionary, it is first necessary to execute the data model generated code first in the RuleSession.

Returns:
the RL for the data model rule set
Throws:
SDKException

ruleSetRL

public java.lang.String ruleSetRL(java.lang.String alias)
                           throws SDKException
Generate the RL for the given rule set in this dictionary and in linked dictionaries. In order to execute a rule set from the dictionary, it is first necessary to execute the data model generated code first in the RuleSession.

Parameters:
alias - alias of the ruleSet for which to generate code
Returns:
the RL for the data model rule set
Throws:
SDKException

addDictionaryChangeListener

public java.lang.Object addDictionaryChangeListener(DictionaryChangeListener listener)
Add a DictionaryChangeListener to receive notifications of dictionary changes via DictionaryChangeEvents.

Parameters:
listener - a DictionaryChangeListener
Returns:
always null

removeDictionaryChangeListener

public java.lang.Object removeDictionaryChangeListener(DictionaryChangeListener listener)
Remove DictionaryChangeListener.

Parameters:
listener - a DictionaryChangeListener
Returns:
always null
See Also:
RuleDictionary.addDictionaryChangeListener(oracle.rules.sdk2.dictionary.DictionaryChangeListener)

rollback

public void rollback()
rollback the current update transaction. Discard any updated DictionaryObjects!


getBuiltinDictionary

public static RuleDictionary getBuiltinDictionary()
get builtin rule dictionary


getLifeCycle

public java.lang.String getLifeCycle()
Get the dictionary life cycle

Returns:
the life cycle name

setLifeCycle

public void setLifeCycle(java.lang.String lifecycle)
Set the dictionary life cycle

Parameters:
lifecycle - the life cycle

getLifeCycleDescription

public java.lang.String getLifeCycleDescription()
Get the dictionary life cycle description

Returns:
the life cycle description

setLifeCycleDescription

public void setLifeCycleDescription(java.lang.String description)
Set the dictionary life cycle description

Parameters:
description - the life cycle description

copyTo

public void copyTo(RuleDictionary from)
copy to this dictionary

Parameters:
from - dictionary to copy from

getResourceBundle

public java.lang.String getResourceBundle()
Get the name of the user resource bundle for UserTranslatedPropertys. This is the first argument to ResourceBundle.getBundle(String,Locale)

Returns:
name of bundle

setResourceBundle

public void setResourceBundle(java.lang.String name)
Set the name of the user resource bundle for UserTranslatedPropertys. This is the first argument to ResourceBundle.getBundle(String,Locale)


resourceBundleChanged

public void resourceBundleChanged()
If the resource bundle file is changed, call this method, followed by RuleDictionary.update(java.util.List), to cause the SDK to re-read the bundle


getResourceBundleControl

public java.util.ResourceBundle.Control getResourceBundleControl()
Get the user resource bundle control for TranslatedPropertys. This is the third argument to ResourceBundle.getBundle(String,Locale,ResourceBundle.Control)

Returns:
name of bundle

setResourceBundleControl

public void setResourceBundleControl(java.util.ResourceBundle.Control control)
Set the user resource bundle control for TranslatedPropertys. This is the third argument to ResourceBundle.getBundle(String,Locale,ResourceBundle.Control)

Parameters:
control - must be serializable

getWarnings

public java.util.List<SDKWarning> getWarnings(boolean includeDescendants)
Description copied from class: DictionaryObject
get Warnings associated with this dictionary object or its descendants. Note that no validation is performed. Only a subset of warnings from the last RuleDictionary.update(java.util.List) are returned.

Overrides:
getWarnings in class DictionaryObject
Parameters:
includeDescendants - whether to include warnings bound to this object's descendants.
Returns:
list of warnings

getRuleSetOptions

public java.lang.String[] getRuleSetOptions()
Get rulesets in dictionary (and linked dictionaries) as an option list

Returns:
String[] of ruleset names

getServiceName

public java.lang.String getServiceName()
get name of decision service exposing this dictionary's decision functions

Returns:
String

setServiceName

public void setServiceName(java.lang.String sn)

getServiceNamespace

public java.lang.String getServiceNamespace()

setServiceNamespace

public void setServiceNamespace(java.lang.String sn)

getServiceConfiguration

public java.lang.String getServiceConfiguration()

setServiceConfiguration

public void setServiceConfiguration(java.lang.String sc)

processDecisionTrace

public boolean processDecisionTrace(DecisionTrace trace)

processDecisionTrace

public static boolean processDecisionTrace(DecisionTrace trace,
                                           RuleDictionary dict)

diff

public void diff(RuleDictionary that,
                 java.lang.Object versionInfo)
Compute the difference between this dictionary and that one, identified by versionInfo. Differences will be dynamically recomputed each time this dictionary is RuleDictionary.update(java.util.List)d, until RuleDictionary.removeDiff(Object) is called.

Parameters:
that - RuleDictionary
versionInfo -
See Also:
DictionaryComponent.Diff, DictionaryProperty, SettableProperty, TableProperty

removeDiff

public boolean removeDiff(java.lang.Object versionInfo)
Remove all the Diff information associated with versionInfo.

Parameters:
versionInfo -
Returns:
whether a diff was removed
See Also:
RuleDictionary.diff(RuleDictionary, Object)

getSynopsis

public java.lang.String[][] getSynopsis()
Get a synopsis of the dictionary contents. The synopsis is an array of pairs of strings. The first in the pair is a decision function name, and the second is a ruleset name. The decision function name may be blank (empty String).

Returns:
synopsis as array of pairs of Strings (String[][2])

Oracle Fusion Middleware Java API Reference for Oracle Business Rules
11g Release 1 (11.1.1.7)

E10663-11

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.