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.