I am working in ilog and I have a decision table in which say I have 5 rules. I have some input field as condition say name and age (dummy data) and have some action part related to it. When I pass the input with some condition value as null, exception handler is called in which i have handled the exception and returned false. But problem is if exception occurred in first row then it should throw exception and program should directly reach final action, but in my case all 5 rules are executed and I am getting 5 values for exception which equals the number of rows in table.
public boolean handleexception(IRLruntimeexception ex)
{
errorcode=ex.getmessage();
return false;
}
I am getting 5 times error code value which is incorrect
This is maybe because RetePlus algorithm matches all conditions before executing actions
Try to change the algorithm of your ruletask to sequential.
The exception handler is called for each rule, since each row in a decision table is actually an independent rule. The conditions for each rule will be evaluated for the data provided.
You should approach rule programming just like you would approach programming in any other language, and validate the data/check for null values before passing the data into the rules. So for example, the first task in your ruleflow or initial actions would check for any null or invalid data. If the data passes the null check, the other tasks in the ruleflow are invoked.
See the document Check for null values in rules for additional recommendations on how to handle null values for input data into rules.
Related
I am trying to make some Business rules using DMN on kie Server.
There I have structure data object and its list which is my input. I am using rule to validate my structure list and get only those who passes my condition.
I am using BusinessKnowledgeModel which has actual condition for each object and I have decision logic which iterated through my list and calls the BusinessKnowledgeModel function.
Decision Iterator Feel language code:
for inputParam in InputList return BusinessKnowledgeModel(inputParam)
In the BusinessKnowledgeMode, I have my function which consists of decision table that checks my condition through Feels expression.
Instead of getting null as otput from function, I just want to skip it.
My efforts:
I did try to explore trying to find various approaches; like finding if continue keyword can be used in for loop. Even tried adding constraint on Data objects, but not null constraint can't be added on Structures.
There is no equivalent of continue; operator which is typical in procedural languages as FEEL is an expression language. The closes analogy you can draw if you are familiar with say, Java, is that you need something equivalent of what you could do with the JDK Stream, e.g.: filtering in this case sounds appropriate.
It is likely you can achieve what you need by having your expression filtered:
(for inputParam in InputList return BusinessKnowledgeModel(inputParam))[item!=null]
Demonstration
In this example DMN model I have inputList as a list of numbers, and bkm() is a function returning the same number if it's divisible by 2, otherwise null:
if (modulo(p1, 2) = 0) then p1 else null
The Decision-1 node:
is filtering from the returned list of the for, only the numeric element, as you can see input list size is 10 element, Decision-1 list size is only 5 element, filtered out of the nulls
The complete example:
please notice the output column shows the list elements with indexing,
element index 0 is the value 2,
element index 1 is the value 4,
etc.
I get the following message when I try to validate the mapping (see Warning attached):
...Joiner jnr_Normal_jnr_Master_ZC_OR_Delay_Reason must have exactly two inputs.
WARNING: Joiner transformation jnr_Normal_jnr_Master_ZC_OR_Delay_Reason Condition field OR_CASE_ID1 is unconnected.
I have a joiner (jnr_Master_ZC_OR_Delay_Reason) and expression (exp_Text) that I would like to join. I tried to do this with a normal joiner (jnr_Normal_jnr_Master_ZC_OR_Delay_Reason). However, the data from the jnr_Master_ZC_OR_Delay_Reason does not connect to this jnr_Normal_jnr_Master_ZC_OR_Delay_Reason. See Joiners-Two Inputs attached.
Should I be using a different transformation to join the joiner and expression?
I tried to use Sorting but I still get the same error message. Am I using the Sorting correctly? Please see the attached images.enter image description here
enter image description here
If you want to join flows that originate from the same source (let's call that a self-join), you need to have the data sorted on both branches of the flow and check the Sorted Input property on the Joiner Transformation (jnr_Normal_jnr_Master_ZC_OR_Delay_Reason in this case).
A self-join is only allowed if both flows are sorted. Depending on your flow, it may be enough to sort data only once, before the flow gets split.
Now, if you enable the Sorted Input property but the data will not be sorted, you will get an error while session execution.
I want to search nodes by value only, which can be in any of node properties. I know that this is an expensive operation, but nodes will be cut off by some relationship conditions.
I want something like this:
MATCH (n: {*:"Search value"})
RETURN n
Where * imply "any property".
Is there a way to do this?
interesting tidbits can be found in this abstract regarding this topic and why it might not be implemented
https://docs.google.com/document/d/1FPfGkgzhcRXVkleBLBsA92U94Mx4yafu3nO-Xf-NzsE/edit#heading=h.pyvdg2rbofq
Semantics of dynamic key expressions
Using a dynamic key expression like <mapExpr>[<keyExpr>] requires that <mapExpr> evaluates to a map or an entity, and that <keyExpr> evaluates to a string. If this is not the case, a type error is produced either at compile time or at runtime.
If this is given, evaluating <mapExpr>[<keyExpr>] first evaluates keyExpr to a string value (the key), and then evaluates <mapExpr> to a map-like value (the map). Finally the result of <mapExpr>[<keyExpr>] is computed by performing a lookup of the key in the map. If the key is found, the associated value becomes the result. If the key is not found, <mapExpr>[<keyExpr>] evaluates to NULL.
Thus the result of evaluating <mapExpr>[<keyExpr>] can be any value (including NULL
Caveats
Dynamic property lookup might entice users to encode information in property key names. This is bad practice as it interferes with planning, leads to unnatural data models, and might lead to exhausting the available property key id space. This is addressed by issuing a warning when a query uses a dynamic property lookup with a dynamic property key name.
To my knowledge, no. Seems to me that what you really are trying to do would be better achieved by creating a search index over the graph using something like elasticsearch or solr. This would give you the ability to search over all properties. Your choice of analyzer whilst indexing would give you the option of exact or partial value matches.
In EF4 I am doing a function import of a stored procedure that returns a collection of string scalars. However, sometimes the stored procedure may not return any values. I do not own the stored procedure and cannot change it. If the stored procedure returns no values, my code throws an exception "The data reader returned by the data store provider does not have enough columns for the query requested". Is there any more graceful way of handling this situation than to attempt to catch the exception and assume that the no rows condition is what caused it?
One workaround could be returning a dummy row if there are no matching records.
I am trying to filter some records from a TADOQuery. I set the filtered property to true and when I set the filter to field='value', all works fine. I would like to dynamically build this filter by appending
<space>AND field='value'
to a value always true, and I thought 1=1 would do the trick. So I would have 1=1 as the default filter and then just append AND field='value' to it as necessary.
This, however, does not work. The error message reads:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Could anyone please tell me what could I use as a versatile always-true expression for this filter?
I suppose it goes without saying, but it depends on the OLE DB provider whether or not this works. When you set a filter on an existing record set, it ends up going through a different OLE DB interface (IViewFilter if I remember correctly). So even if a filter works in a WHERE clause on an SQL statement, it does not necessarily mean that it will work as a filter. The filter that you set ends up getting parsed apart into the component pieces and then passed to the OLE DB interface. It may be that the provider's implementation is not expecting a filter of the form "constant = constant". As a workaround, you might try setting it all in the WHERE clause of the SQL statement.
You have to set the 'Filtered' property to False if you are not filtering something, and set it True and your condition when you want the resultset to be filtered.
I would dynamically build the correct SQL property though so that you always exactly know what is being send to the database (and you are sure that only those records you want is received by your program).
The 1=1 trick works fine in the where clause of a query, but not in the filtered property. If you want to disable the filter, set filtered to false and all records will be returned.
The problem with filtering is that it is done client side. If you are using a database engine such as SQL Server and expect to have a large set of records to filter, then your better served by changing the SQL Query which will allow the database server to return only the records requested. Just remember to close your TAdoQuery first, change the SQL then re-open.
A trick I use to avoid returning the entire dataset (used for large datasets) is to consider a maximum number of records I want to display, then use the TOP SQL Syntax to return one more than the number of records I wanted to display 'n' ...if I reach that number, then I notify the user that there were more than n-1 records returned and to adjust the search/filter criteria.