Jean,

   Answering your 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...
   As long as you implement a "front-end" for your customer service reps to use instead of writing rules manually (to help avoiding mistakes, etc), the approach would work. The engine can easily handle such load and is capable of expressing priorities, etc. The syntax in your samples have some mistakes though.

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?
Right now, extractors for fields are created at rule compilation time, so, no easy/performant way of doing such things in drools as it is. This would be an interesting exercise to play with, though, should I have the time to work on: implement an extension to handle dynamic, lazy field extraction. It would be optional, not core, because of performance implications, but it would be interesting to see running. Anyone up for the challenge? :) It would not be easy, but surelly would provide for a bunch of fun and learning.

3)  Is there another approach that would be better suited in this case that
you'd recommend?
Since your mapping rules are defined at application runtime (not implementation time), probably rules is a good approach. You can implement a data mapping/transformation engine from scratch, but it would surelly give you a good amount of work. Leveraging a rules engine would probably give you better results.

   []s
   Edson

2007/4/5, jdepaul <jjdepaul@us.ibm.com>:

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...-tf3532720.html#a9859805
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
  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