public class DecisionEngine
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
_BLANK_OUTPUT |
| Constructor and Description |
|---|
DecisionEngine(DataProvider provider)
Construct the decision engine with the passed data provider
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Integer |
findMatchingTableRow(Table table,
java.util.Map<java.lang.String,java.lang.String> context)
Return the matching table row index based on the passed context
|
static java.lang.Integer |
findMatchingTableRow(Table table,
java.util.Map<java.lang.String,java.lang.String> context,
java.util.Set<java.lang.String> keysToMatch)
Return the matching table row index based on the passed context
|
java.util.Set<java.lang.String> |
getInputs(Definition definition)
Looks at all tables involved in all the mappings in the definition and returns a list of inputs that are used.
|
java.util.Set<java.lang.String> |
getInputs(Mapping mapping,
java.util.Set<java.lang.String> excludedInputs)
Looks at all tables involved in the mapping and returns a list of inputs that are used.
|
java.util.Set<java.lang.String> |
getInputs(TablePath path)
Returns a list of inputs that are required for the specified TablePath.
|
java.util.Set<java.lang.String> |
getInputs(TablePath path,
java.util.Set<java.lang.String> excludedInputs)
Returns a list of inputs that are required for the specified TablePath.
|
java.util.List<Mapping> |
getInvolvedMappings(Definition definition,
java.util.Map<java.lang.String,java.lang.String> context)
Given a definition and context, return a list of mappings that match inclusion and exclusion criteria
|
java.util.Set<java.lang.String> |
getInvolvedTables(Definition definition)
Return a list of tables involved in an definition.
|
java.util.Set<java.lang.String> |
getInvolvedTables(java.lang.String definitionId)
Return a list of tables involved in a definition
|
java.util.Set<java.lang.String> |
getOutputs(Definition definition)
Looks at all tables involved in all the mappings in the definition and returns a list of outputs produced.
|
java.util.Set<java.lang.String> |
getOutputs(Mapping mapping)
Looks at all tables involved in the mapping and returns a list of outputs that are produced.
|
java.util.Set<java.lang.String> |
getOutputs(TablePath path)
Return a list of outputs that are produced form the specified TablePath.
|
DataProvider |
getProvider()
Returns the internal data provider
|
boolean |
isMappingInvolved(Mapping mapping,
java.util.Map<java.lang.String,java.lang.String> context)
Given a mapping and a context, check the inclusion/exclusion tables to see if mapping should be processed
|
static boolean |
isReferenceVariable(java.lang.String value)
Checked whether the value is a reference to another variable or context
|
static java.util.List<? extends Endpoint> |
matchTable(Table table,
java.util.Map<java.lang.String,java.lang.String> context)
Return the list of endpoints for the matching row in the table; returns null if there is no match
|
static java.util.List<? extends Endpoint> |
matchTable(Table table,
java.util.Map<java.lang.String,java.lang.String> context,
java.util.Set<java.lang.String> keysToMatch)
Return the list of endpoints for the matching row in the table; returns null if there is no match
|
Result |
process(Definition definition,
java.util.Map<java.lang.String,java.lang.String> context)
Using the supplied context, process a definition.
|
Result |
process(java.lang.String definitionId,
java.util.Map<java.lang.String,java.lang.String> context)
Using the supplied context, process an definition.
|
protected boolean |
process(java.lang.String mappingId,
java.lang.String tableId,
TablePath path,
Result result,
java.util.Deque<java.lang.String> stack)
Internal method to recursively process a table
|
void |
setProvider(DataProvider provider)
Sets the provider and initiaizes all definitions and tables
|
static boolean |
testMatch(java.util.List<? extends Range> values,
java.lang.String value,
java.util.Map<java.lang.String,java.lang.String> context)
Tests that a value is contained in a list of ranges; if the list of ranges is missing or empty, then all values will match to it
|
static java.lang.String |
translateValue(java.lang.String value,
java.util.Map<java.lang.String,java.lang.String> context)
Translates a value.
|
static java.lang.String |
trimBraces(java.lang.String value)
Takes a key reference, like {{key}} and returns just the key ("key" in this example)
|
public static final java.lang.String _BLANK_OUTPUT
public DecisionEngine(DataProvider provider)
provider - a DataProviderpublic static boolean isReferenceVariable(java.lang.String value)
value - String valuepublic static java.lang.String trimBraces(java.lang.String value)
value - a key refrerencepublic static java.util.List<? extends Endpoint> matchTable(Table table, java.util.Map<java.lang.String,java.lang.String> context)
table - a Tablecontext - a Map containing the contextpublic static java.util.List<? extends Endpoint> matchTable(Table table, java.util.Map<java.lang.String,java.lang.String> context, java.util.Set<java.lang.String> keysToMatch)
table - a Tablecontext - a Map containing the contextkeysToMatch - if not null, only keys in this set will be matched againstpublic static java.lang.Integer findMatchingTableRow(Table table, java.util.Map<java.lang.String,java.lang.String> context)
table - a Tablecontext - a Map containing the contextpublic static java.lang.Integer findMatchingTableRow(Table table, java.util.Map<java.lang.String,java.lang.String> context, java.util.Set<java.lang.String> keysToMatch)
table - a Tablecontext - a Map containing the contextkeysToMatch - if not null, only keys in this set will be matched againstpublic static boolean testMatch(java.util.List<? extends Range> values, java.lang.String value, java.util.Map<java.lang.String,java.lang.String> context)
values - a List of Range objectsvalue - a value to look forcontext - the context will be used to do key lookups when values are in the format of {{var}}public static java.lang.String translateValue(java.lang.String value,
java.util.Map<java.lang.String,java.lang.String> context)
value - String valuecontext - Context for handling variable referencespublic DataProvider getProvider()
public void setProvider(DataProvider provider)
provider - a DataProviderpublic boolean isMappingInvolved(Mapping mapping, java.util.Map<java.lang.String,java.lang.String> context)
mapping - a Mappingcontext - a Map containing the contextpublic java.util.List<Mapping> getInvolvedMappings(Definition definition, java.util.Map<java.lang.String,java.lang.String> context)
definition - a Definitioncontext - a Map containing the contextpublic java.util.Set<java.lang.String> getInvolvedTables(java.lang.String definitionId)
definitionId - an Definition identifierpublic java.util.Set<java.lang.String> getInvolvedTables(Definition definition)
definition - a Definitionpublic java.util.Set<java.lang.String> getInputs(TablePath path)
path - a TablePathpublic java.util.Set<java.lang.String> getInputs(TablePath path, java.util.Set<java.lang.String> excludedInputs)
path - a TablePathexcludedInputs - a list of keys that should not be included in the inputspublic java.util.Set<java.lang.String> getInputs(Mapping mapping, java.util.Set<java.lang.String> excludedInputs)
mapping - a MappingexcludedInputs - a list of keys that should not be included in the inputspublic java.util.Set<java.lang.String> getInputs(Definition definition)
definition - a Definitionpublic java.util.Set<java.lang.String> getOutputs(TablePath path)
path - a TablePathpublic java.util.Set<java.lang.String> getOutputs(Mapping mapping)
mapping - a Mappingpublic java.util.Set<java.lang.String> getOutputs(Definition definition)
definition - a Definitionpublic Result process(java.lang.String definitionId, java.util.Map<java.lang.String,java.lang.String> context)
definitionId - an Definition identifiercontext - a Map containing the contextpublic Result process(Definition definition, java.util.Map<java.lang.String,java.lang.String> context)
definition - a Definitioncontext - a Map containing the contextprotected boolean process(java.lang.String mappingId,
java.lang.String tableId,
TablePath path,
Result result,
java.util.Deque<java.lang.String> stack)
mappingId - a Mapping identifiertableId - a Table identifierpath - a TablePathresult - a Resultstack - a stack which tracks the path and makes sure the path doesn't enter an infinite recusive state