explanation on drl usage
by JLL
Hi all,
i'm quiet new in drools (a french speaking so i appologise for my english
mistakes) and i'm surprise by the folowing problem
in drools example i found this code ...
Example 3.14. Return Value operator
Person( girlAge : age, sex == "F" )
Person( age == ( new Integer(girlAge.intValue() + 2) ), sex == 'M' )
This let me think that i can use method of an assigned variable in the
equality test
this my rule file
package be.labocollard.server.rules ;
import java.lang.Integer;
import java.lang.Double;
import be.labocollard.server.types.HumanSexType;
import be.labocollard.server.entities.Result;
import be.labocollard.server.entities.Resultat;
import be.labocollard.server.entities.Prestation;
import be.labocollard.server.entities.PrestationFacturable;
import be.labocollard.server.entities.Utilisateur;
rule "asserteResultatAndPrestation"
when
PrestationFacturable ( $resultat : resultat , $prestation : prestation)
then
assert ( $resultat );
assert ($prestation);
end
rule "findRelevantResult"
when
$resultat : Resultat()
eval($resultat.getResults().size()>0)
then
assert($resultat.getResults().iterator().next());
end
rule "testPsaId"
when
$prestation : Prestation(id == "psaId")
$prestationFacturable : PrestationFacturable (prestation==$prestation,
$resultat : resultat)
$result : Result (doubleValue < (new Double(12)))
Resultat (id == $resultat.getId(), results contains $result )
>>> this sentence makes problem ...
>>> and i would like to avoid eval
>>> #eval ($resultat.getId()==id &&
$resultat.getResults().contains($result) )
Utilisateur (age < (new Integer(55))) || Utilisateur (sex !=
HumanSexType.MALE)
then
retract($prestationFacturable);
end
Is there a drools guru to explain my misunderstanding ????
thanks a lot
and thanks to drools developpers for those wonderfull tools
JLL
--
View this message in context: http://www.nabble.com/explanation-on-drl-usage-tf3535518.html#a9868635
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 7 months
RE: Re: drools help needed !
by Kumar, Parvesh
I am getting following error when I use drools *.drl file with in my EAR
APP . I have following
jars under app-inf/lib directory and other drools dependencies jars..
antlr-3.0ea8.jar; antlr-2.7.5H3.jar; stringtemplate-2.3b6.jar
I am using weblogic 8.1 sp4.
panic:ClassNotFoundException:org.antlr.stringtemplate.language.ChunkToke
n
and server dies,.
Any help on this matter greatly appreciated.
Thanks
Parvesh
17 years, 7 months
NullPointer in LHS dao calls ..
by Sanjay Singh - s0singh
Since i could not get the earlier code running i tried using eval in LHS
side for Dao calls but i keep on getting NullPointerException ..
rule "Item should have a valid status"
when
ItemVo (statusCode : itemStatusCode != null)
eval( !itemValidationDao.isValidItemStatus(statusCode) )
then
errors.addValidationError("invalidtemStatusCode","Item Status Code is
invalid ");
end
Exception data: org.drools.RuntimeDroolsException:
java.lang.NullPointerException
at org.drools.rule.EvalCondition.isAllowed(Unknown Source)
at org.drools.reteoo.EvalConditionNode.assertTuple(Unknown Source)
at org.drools.reteoo.LeftInputAdapterNode.createAndAssertTuple(Unknown
Source)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(Unknown Source)
at org.drools.reteoo.ObjectSource.propagateAssertObject(Unknown Source)
Can somebody please help .. thanks
________________________________
From: Sanjay Singh - s0singh
Sent: Tuesday, April 03, 2007 11:01 AM
To: 'Anstis, Michael (M.)'; Rules Users List
Subject: RE: Hi.
Thanks for getting back to me Mike and Edson and Sorry for the delayed
response.
I looked at your examples Mike and i felt better as you said that we can
make dao calls in LHS .. And Edson suggested not to be afraid of
suggesting the same constraint for more than one rule .. i guess i was
looking at it more procedural way and dint want any repetition of those
conditions as the top level IF block but looks like it won't hurt to
mention these constraints in all the rules related to this check ...so i
can include this check in all the rules .. hmm ..
Here is a quick test i was trying to do for calling the dao in LHS but
it fails .. what am i missing ..
package com.walmart.itemfile.item.rules
import com.walmart.itemfile.item.vo.ItemVo;
import com.walmart.itemfile.item.dao.ItemDao;
import com.walmart.itemfile.item.dao.ItemValidationDao;
import java.lang.String;
global com.walmart.itemfile.item.dao.ItemValidationDao
itemValidationDao;
global com.walmart.itemfile.rules.ValidationErrorMap errors;
rule "Item should have a valid status"
when
ItemVo( statusCode : itemStatusCode != null)
ItemVo( statusCode == true ) from
itemValidationDao.isValidItemStatus(statusCode) .. my isValidItemStatus
method returns a boolean (not collection of codes) and i need to check
if thats true than go to the RHS side .. is the line in green even right
... in any case it does not recognize itemValidationDao to begin with in
LHS side .. RHS same call works ..
then
errors.addValidationError("nullItemStatusCode","Item Status Code is
null");
System.out.println("Item Base Defaults Called" +
itemValidationDao.isValidItemStatus(statusCode));
System.out.println("Item Status Code is null");
end
Caused by: org.drools.rule.InvalidRulePackage: unknown:32:28 Unexpected
token 'itemValidationDao'
thanks for the help guys ..
Sanjay
________________________________
From: Anstis, Michael (M.) [mailto:manstis1@ford.com]
Sent: Monday, March 26, 2007 8:57 AM
To: Rules Users List
Cc: Sanjay Singh - s0singh
Subject: RE: Hi.
Hi Sanjay,
To firstly answer your questions (in my opinion):
1. You can't do nested whens in the LHS but you can do nested if / else
in the RHS (although you'd fore go the benefits of a RETE-based
inference engine; but possible if you've got very few rules and
facts...). I believe that there is work to have an "otherwise" statement
for rule syntax, how progressed this is and how it will work I don't
know - over to Mark and team?!?
2. Yes, take a look at the "from" statement (new for 3.1-M1, see
http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes)
3. Yes, take a look at rule-flow at
http://labs.jboss.com/portal/index.html?ctrl:cmd=render&ctrl:window=defa
ult.blog.PrjBlogPortletWindowDefaultBlog&project=jbossrules&from=1&link=
RuleFlow_%28Kris_Verlaenen%29#RuleFlow_%28Kris_Verlaenen%29 (although I
don't know if this is complete if 3.1-M1 - I think it's not). Although I
don't think your rules really need rule-flow; you just need to identify
and isolate the patterns (IF's) that would cause each "Do Something" to
be ran and create a rule for each - this has the benefit of separating
each action into a separate rule making maintenance a whole bunch
easier).
Anyway, I'd try some rules like the following examples (the rest are
based upon these):-
Rule "Rule 1"
when
NewItem ( itemStatusCode == null)
then
//do something
end
Rule "Rule 2"
when
$u : User( )
$ni : NewItem ( $isc : itemStatusCode != null )
not Codes ( codes contains $isc ) from
valDao.getValidItemStatusCodesForUser($u)
then
//Do something
end
Rule "Rule 3"
when
$u : User( )
$ni : NewItem( itemStatusCode == ItemVO.DELETED )
Codes ( codes contains $isc ) from
valDao.getValidCrossReferencePrimeCodesForUser($u)
then
//Do something
end
I've posted to the news group so everyone can contribute - don't be shy
;-)
With kind regards,
Mike
________________________________
From: Sanjay Singh - s0singh [mailto:Sanjay.Singh@wal-mart.com]
Sent: 26 March 2007 14:24
To: Anstis, Michael (M.)
Subject: Hi.
Hey Mike ... I am sorry to bother you but you seemed to be
pretty good with rules and i just could not think of anyone else to ask
abt it ... I am sorry if i am taking much of your time .. Here is my
problem if you can have a quick look ..
Look at this code once .. its very easy but it involves tons of
if else blocks conditions ..
if( newItem.getItemStatusCode() == null){
//do something
}
else{
if(
!valDao.isValidItemStatus(newItem.getItemStatusCode(),user) ){
//do something
}
if(
newItem.getItemStatusCode().equals(ItemVo.DELETED)||getItemStatusCode().
equals(ItemVo.INACTIVE) ){
if(
valDao.isCrossReferencePrime(newItem.getItemNbr(),user)){
//do something
}
else if(
valDao.isFutrCrossReferencePrimeOrSecond(newItem.getItemNbr(),user) ){
//do something
}
else if(
valDao.isComponentLink(newItem.getItemNbr(),user)){
//do something
}
else if(
valDao.hasWhseOnHandsOrOnOrders(newItem.getItemNbr(),user)&&CountryCode(
).equals("CA") ){
//do something
}
}
else{
if(
valDao.isUnlikeAsstParentWithNonActiveChildren(newItemNbr,user) ){
//do something;
}else if
(isLikeAssortmentBaby(newItemNbr,user)&&!alDao.isLikeAsstParentActive(ne
wItemNbr, user)){
//do something
}else{
//do something
}
}
}
}
What i am trying to understand is the right way of putting it in
drl files ..
1.What are the options for putting if else conditions ? Will i
have to write all the rules anyway and they will be called as well all
the time depending on the criteria ... or is there a way where when my
first if check which was if item number is null failed i should not go
for any other rules .. Is there a way where we could have like "when"
inside "when" .. kinda looping of conditions so if one does not meet you
dont go to the next .. jsut like in above blocks ? Whats the good way of
doing it ?
2.Is it possible to make database calls like from my dao
instance in LHS (condition) .. i know we can do it in RHS and i have
tested that as well but can we do it in LHS as sometimes we need to do
that ..like with null checks for the item status code we also want to
check something from the database like a boolean value and if that meets
the criteria we will run the rules ..as u can see above we have basic
state check with nulls etc plus we have some dao calls as well in the
condition part and then we //do something
3.Can i call rules within other rules .. so something like in
rule1 i want to call rule2 .. is that possible ?
Can you suggest a decent way of doing these if else blocks ..
this is the core stuff which we do for our rules here .. if i can handle
this kind of conditions i guess i can handle anything out here ...
Thanks for all the help ..
Sanjay
________________________________
*******************************************************************
*** This email and any files transmitted with it are
confidential
and intended solely for the individual or entity to whom they
are
addressed. If you have received this email in error destroy it
immediately.
******************************************************
**************** Wal-Mart Confidential
****************************
******************************************
-----------------------------------------
*******************************************************************
*** This email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they are
addressed. If you have received this email in error destroy it
immediately. ******************************************************
**************** Wal-Mart Confidential ****************************
******************************************
17 years, 7 months
JBoss Rules IDE Eclipse Update Site
by Ronald R. DiFrango
All,
It appears as though the JBoss Rules IDE Eclipse update site does not have
the latest version [3.0.6] installed on it. Any chance of it getting
update?
Thanks,
Ron
17 years, 7 months
RE: Need DRL authoring Help
by John.Tal@gxs.com
Drools developers,
In our specific use case we have customers who need to be able to write
validation rules and NOT have to resort to writing them in Java. Hence
our interest in using drools as an open source 'standard' to potentially
replace a proprietary rules engine we already have.
In the previous case I mentioned where I want to do this:
> *rule* "UCCnet_DVE_Depth_All"
> *when*
> catalogObject : CatalogObject( )
> String s = catalogObject.getElementValue("depth");
> *eval*( s == *null* || s == "" )
> *then*
> logWriter.logDebug("Package Depth is Blank");
> *end*
This is because potentially, in our use for data validation, there might
be 50 values we need to compare against. Those values need to be on the
drools (not java) side of the world. So getting the result of
catalogObject.getElementValue("depth") into a String variable and being
able to use String methods like indexOf or multiple || cases is much
more desirable than crossing from the rule back into the object by
having to call getElementValue 50 times. There are numerous, other
cases, where the result of catalogObject.getElementValue need to be
saved into a local drools variable and evaluated multiple times without
encurring the overhead of multiple calls back into java.
Please consider enhancing drl syntax to support this use case. Is there
a bug/enhancement process for me to follow to submit this functionality
request.
Thanks
John
Date: Thu, 5 Apr 2007 16:47:07 +1000
From: "Michael Neale" <michael.neale(a)gmail.com>
Subject: Re: [rules-users] RE: Need DRL authoring Help
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Message-ID:
<96ab3ced0704042347s130a4b46ma4a5b74fb45ef0d4(a)mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
OK you are really bending what you would use rules for, I really
wouldn't recommend that. flattening the object model would allow you to
write rules over it, but as it stands, its just going to be a bit
difficult for you.
catalogObject : CatalogObject( )
*eval*( catalogObject.getElementValue("depth") == *null* ||
catalogObject.getElementValue("depth") == "" )
On 4/5/07, John.Tal(a)gxs.com <John.Tal(a)gxs.com> wrote:
>
> Ok, Thanks for the help on the drl syntax.
>
> So this works.
>
> *rule* "UCCnet_DVE_Depth_All"
> *when*
> catalogObject : CatalogObject( )
> *eval*( catalogObject.getElementValue("depth") == *null* ||
> catalogObject.getElementValue("depth") == "" )
> *then*
> logWriter.logDebug("Package Depth is Blank");
> *end*
>
> But how do I get the drl parser to accept something like this:
>
> *rule* "UCCnet_DVE_Depth_All"
> *when*
> catalogObject : CatalogObject( )
> String s = catalogObject.getElementValue("depth");
> *eval*( s == *null* || s == "" )
> *then*
> logWriter.logDebug("Package Depth is Blank");
> *end*
>
> I am getting an Unexpected token 's' InvalidRulePackage
17 years, 7 months
Errors in running the HelloWorldExample
by Sudipta deb
Sir,
I want to run a simple drools example i.e. HelloWorldExample from command line
My HelloWorldExample.java--->
import java.io.InputStreamReader;
import java.io.Reader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.compiler.*;
import java.lang.String;
import java.io.*;
/**
* This is a sample file to launch a rule package from a rule source file.
*/
public class HelloWorldExample
{
public static final void main(final String[] args)
{
try
{
//load up the rulebase
final RuleBase ruleBase = loadRules();
final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
//go !
final Message message = new Message();
message.setMessage( "Hello World " );
message.setStatus( Message.HELLO );
workingMemory.assertObject( message );
workingMemory.fireAllRules();
}
catch ( final Throwable t )
{
t.printStackTrace();
}
}
public static RuleBase loadRules()
{
RuleBase ruleBase=null;
try
{
String [] ruleFiles = new String [1];
ruleFiles[0] = "HelloWorld.drl";
PackageBuilderConfiguration pkgBuilderCfg = new PackageBuilderConfiguration();
pkgBuilderCfg.setCompiler(PackageBuilderConfiguration.JANINO);
PackageBuilder builder = new PackageBuilder(pkgBuilderCfg);
for( int i = 0, j = ruleFiles.length; i<j; i++ )
{
builder.addPackageFromDrl(new InputStreamReader(HelloWorldExample.class.getResourceAsStream( ruleFiles[i] )) ); //HelloWorldExample.class.getResourceAsStream( "HelloWorld.drl" )
//new InputStreamReader(getClass().getResourceAsStream( ruleFiles[i] ) )
}
final Package pkg = builder.getPackage();
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
}
catch (Exception fe)
{
fe.printStackTrace();
}
return ruleBase;
}
/**
* Please note that this is the "low level" rule assembly API.
*/
private static RuleBase readRule() throws Exception
{
//read in the source
final Reader source = new InputStreamReader( HelloWorldExample.class.getResourceAsStream( "HelloWorld.drl" ) );
//optionally read in the DSL (if you are using it).
//Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/mylang.dsl" ) );
//Use package builder to build up a rule package.
//An alternative lower level class called "DrlParser" can also be used...
final PackageBuilder builder = new PackageBuilder();
//this wil parse and compile in one step
//NOTE: There are 2 methods here, the one argument one is for normal DRL.
builder.addPackageFromDrl( source );
//Use the following instead of above if you are using a DSL:
//builder.addPackageFromDrl( source, dsl );
//get the compiled package (which is serializable)
final Package pkg = builder.getPackage();
//add the package to a rulebase (deploy the rule package).
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
return ruleBase;
}
public static class Message
{
public static final int HELLO = 0;
public static final int GOODBYE = 1;
private String message;
private int status;
public String getMessage()
{
return this.message;
}
public void setMessage(final String message)
{
this.message = message;
}
public int getStatus()
{
return this.status;
}
public void setStatus(final int status)
{
this.status = status;
}
}
}
My HelloWorld.drl-->
package drools_test;
import HelloWorldExample.*;
rule "Hello World"
when
m : Message( status == Message.HELLO, message : message )
then
System.out.println( message );
m.setMessage( "Goodbye cruel world" );
m.setStatus( Message.GOODBYE );
modify( m );
end
rule "GoodBye"
no-loop true
when
m : Message( status == Message.GOODBYE, message : message )
then
System.out.println( message );
m.setMessage( message );
end
Now compilation works absolutely fine but when i am trying to run it some errors are coming
Warning: An error occurred compiling a semantic invoker. Errors should have been reported elsewhere.
Warning: An error occurred compiling a semantic invoker. Errors should have been reported elsewhere.
org.drools.rule.InvalidRulePackage: Rule Compilation error Class "HelloWorldExample.Message" not found Class "HelloWorldExample.Message" not found Class "java.lang.Object" has no method named "setMessage" Exception:0
Rule Compilation error Class "HelloWorldExample.Message" not found Class "HelloWorldExample.Message" not found Class "java.lang.Object" has no method named "setMessage" Exception:0
at org.drools.rule.Package.checkValidity(Unknown Source)
at org.drools.common.AbstractRuleBase.addPackage(Unknown Source)
at HelloWorldExample.loadRules(HelloWorldExample.java:68)
at HelloWorldExample.main(HelloWorldExample.java:29)
I put all the jar files in the classpath. Please help me.
With regards,
Sudipta Deb. (+919831606520)
Kolkata,India
---------------------------------
Heres a new way to find what you're looking for - Yahoo! Answers
17 years, 7 months
Re: drools help needed !
by Edson Tirelli
Hi Gaminda,
What you can't do in J2EE containers is to access the filesystem
directly. Doing a getResourceAsStream() as you are doing is allowed,
specially because your drl file may be inside the application jar/war/ear.
If you are having a NPE, the problem is that the container is not finding
your file in your classpath, so what you need to do is to fix the classpath.
The strategy, though, is a valid one and works.
Regards,
Edson
2007/4/6, Gaminda Jayakody <my_vista2007(a)yahoo.com>:
>
> Hi
> I wnat to implement drools at the Session Bean layer of a J2EE
> application. But reading .drl file as follows cause exceptin in the server.
> because of I/O operation
>
> final Reader source = new InputStreamReader(
> BaseRuleImpl.class.getResourceAsStream(rulefile.drl));
>
> could you kindly give me a solutin to this.
> Thank You
> Gaminda
>
>
> ------------------------------
> Finding fabulous fares is fun.
> Let Yahoo! FareChase search your favorite travel sites<http://farechase.yahoo.com/promo-generic-14795097;_ylc=X3oDMTFtNW45amVpBF...>to find flight and hotel bargains.
>
>
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com
17 years, 7 months
Rules Design Question
by Ronald R. DiFrango
All,
I have a rules design question for the community. I have 3 lists of
different types of objects that I need to sum if a certain attribute is
present on each one of them. Then after the summing has taken place execute
other rules based upon the results of the summation.
Is there a way that I can accomplish this via salience or agenda groups?
Thanks in advance,
Ron
17 years, 7 months
3.1 M Help Needed
by vista2007
I implement the following logic using 3.1M edition,
package com.software.warehouse.rules.impl;
#list any import classes here.
import com.software.warehouse.model.Item;
import com.software.warehouse.model.ItemCollect;
#declare any global variables here
global com.software.warehouse.model.ItemCollect itemCollect;
rule "Rule 1"
salience 20
when
# itemCollect.getItemList() method returns a List of objects
m : Item(status == Item.ACTIVE) from
itemCollect.getItemList()
then
m.setStatus(Item.INACTIVE);
System.out.println(m.getStatus());
end
It gave me the followin error.
ObjectAsserted:
handle=[fid:1:1:com.software.warehouse.model.ItemCollect@12a3722];
object=com.software.warehouse.model.ItemCollect@12a3722]
org.mvel.PropertyAccessException: null pointer exception in property:
itemCollect.getItemList().list()
at
org.mvel.optimizers.impl.refl.ReflectiveOptimizer.compileGetChain(ReflectiveOptimizer.java:137)
at
org.mvel.optimizers.impl.refl.ReflectiveOptimizer.optimize(ReflectiveOptimizer.java:92)
at org.mvel.Token.getReducedValueAccelerated(Token.java:302)
at org.mvel.ExecutableAccessor.getValue(ExecutableAccessor.java:46)
at org.mvel.MVEL.executeExpression(MVEL.java:173)
at
org.drools.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:43)
at org.drools.reteoo.FromNode.assertTuple(FromNode.java:61)
at
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:147)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:20)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:163)
at org.drools.reteoo.Rete.assertObject(Rete.java:121)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)
at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.propagate(ReteooWorkingMemory.java:157)
at
org.drools.common.AbstractWorkingMemory.propagateQueuedActions(AbstractWorkingMemory.java:998)
at
org.drools.common.AbstractWorkingMemory.assertObject(AbstractWorkingMemory.java:733)
Can anyone please help me to slove this problum. Thank You.
--
View this message in context: http://www.nabble.com/3.1-M-Help-Needed-tf3535402.html#a9868300
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 7 months
Dynamic property names?!
by jdepaul
Hi all -
I have the following challenge with data mapping. I'm trying to decide if
DROOLS is the appropriate solution to this problem - please help me decide.
I have a Source object and Target object. Both objects have the same field
names - the goal is to map data across from Source object to Target object
by apply a set of rules to object's fields. More than one rule may need to
be activated for each field. Results of previous mapping operation may
affect later mapping operations further 'downstream' - so it's important to
process fields in a specific sequence and for each field evaluate rules in a
specific order - (not sure, can rule Salience accomplish both?)
About the rules: There may be several rules in affect for each field -
which must be executed in specific order top to bottom. Rules should be
applied until the target field is mapped - until the target field is
non-blank. Same rule may be applied to more than one field from the Source
object. Rules will be maintain by a Customer Service Reps and will change
periodically.
I would envision the rule setup to be something like this:
Rule "Setup variables"
when
$source : SOURCE (rec_type == "PARTNER", $s_loc : location,
$s_op : operator, $s_wo : workorder)
$target : TARGET ($t_loc : location, $t_op : operator, $t_wo :
workorder)
then
<do nothing>
end
# Simple mapping for Location field...
rule "Location"
when
$target($t_loc == "") // if blank
then
$target.setLocation($s_loc);
modify($target);
end
# Simple mapping for Operator field...
rule "Operator"
when
$target($t_op == "") // if blank...
then
$target.setLocation($s_op);
modify($target);
end
... rules continue for the rest of the fields... There are about 150-200
fields to map. Some rules will define simple straight across mappings,
other rules will need to fetch values from objects from DB (using 'from'
keyword). Here are some questions:
1) Opinion please: Would the outlined approach work in this case given the
number of fields to process and the required sequence for processing. Seems
that rule management may be a bit difficult...
2) Is there a way to define functions that could take field names, and then
apply common operations using dynamic field names - i.e. function
simple_map(fieldName) would source data from Source.fieldName and map it to
Tartget.fieldName - this would require that get/set methods be dynamic - is
that possible?
3) Is there another approach that would be better suited in this case that
you'd recommend?
Thanks,
James
--
View this message in context: http://www.nabble.com/Dynamic-property-names-%21-tf3532721.html#a9859806
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 8 months