<br>&nbsp;&nbsp; Jean,<br><br>&nbsp;&nbsp; Answering your questions:<br><br>1)&nbsp;&nbsp;Opinion please:&nbsp;&nbsp;Would the outlined approach work in this case given the<br>number of fields to process and the required sequence for processing.&nbsp;&nbsp;Seems<br>that rule management may be a bit difficult...
<br>&nbsp;&nbsp; As long as you implement a &quot;front-end&quot; 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.
<br><br>2)&nbsp;&nbsp;Is there a way to define functions that could take field names, and then<br>apply common operations using dynamic field names - i.e. function<br>simple_map(fieldName) would source data from Source.fieldName and map it to
<br>Tartget.fieldName&nbsp;&nbsp;- this would require that get/set methods be dynamic - is<br>that possible?<br>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.
<br><br>3)&nbsp;&nbsp;Is there another approach that would be better suited in this case that<br>you&#39;d recommend?<br>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.
<br><br>&nbsp;&nbsp; []s<br>&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/4/5, jdepaul &lt;<a href="mailto:jjdepaul@us.ibm.com">jjdepaul@us.ibm.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi all -<br><br>I have the following challenge with data mapping.&nbsp;&nbsp;I&#39;m trying to decide if<br>DROOLS is the appropriate solution to this problem - please help me decide.<br><br>I have a Source object and Target object.&nbsp;&nbsp;Both objects have the same field
<br>names - the goal is to map data across from Source object to Target object<br>by apply a set of rules to object&#39;s fields.&nbsp;&nbsp;More than one rule may need to<br>be activated for each field.&nbsp;&nbsp;Results of previous mapping operation may
<br>affect later mapping operations further &#39;downstream&#39; - so it&#39;s important to<br>process fields in a specific sequence and for each field evaluate rules in a<br>specific order - (not sure, can rule Salience accomplish both?)
<br><br>About the rules:&nbsp;&nbsp;There may be several rules in affect for each field -<br>which must be executed in specific order top to bottom.&nbsp;&nbsp;Rules should be<br>applied until the target field is mapped - until the target field is
<br>non-blank.&nbsp;&nbsp;Same rule may be applied to more than one field from the Source<br>object.&nbsp;&nbsp;Rules will be maintain by a Customer Service Reps and will change<br>periodically.<br><br>I would envision the rule setup to be something like this:
<br><br>Rule &quot;Setup variables&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$source : SOURCE (rec_type == &quot;PARTNER&quot;, $s_loc : location,<br>$s_op : operator, $s_wo : workorder)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$target : TARGET&nbsp;&nbsp;($t_loc : location, $t_op : operator, $t_wo :
<br>workorder)<br>&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;do nothing&gt;<br>end<br><br># Simple mapping for Location field...<br>rule &quot;Location&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $target($t_loc == &quot;&quot;)&nbsp;&nbsp;// if blank<br>&nbsp;&nbsp;&nbsp;&nbsp;then
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $target.setLocation($s_loc);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modify($target);<br>end<br><br># Simple mapping for Operator field...<br>rule &quot;Operator&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $target($t_op == &quot;&quot;)&nbsp;&nbsp;// if blank...
<br>&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $target.setLocation($s_op);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modify($target);<br>end<br><br>... rules continue for the rest of the fields...&nbsp;&nbsp;There are about 150-200<br>fields to map.&nbsp;&nbsp;Some rules will define simple straight across mappings,
<br>other rules will need to fetch values from objects from DB (using &#39;from&#39;<br>keyword).&nbsp;&nbsp; Here are some questions:<br><br>1)&nbsp;&nbsp;Opinion please:&nbsp;&nbsp;Would the outlined approach work in this case given the<br>number of fields to process and the required sequence for processing.&nbsp;&nbsp;Seems
<br>that rule management may be a bit difficult...<br><br>2)&nbsp;&nbsp;Is there a way to define functions that could take field names, and then<br>apply common operations using dynamic field names - i.e. function<br>simple_map(fieldName) would source data from 
Source.fieldName and map it to<br>Tartget.fieldName&nbsp;&nbsp;- this would require that get/set methods be dynamic - is<br>that possible?<br><br>3)&nbsp;&nbsp;Is there another approach that would be better suited in this case that<br>you&#39;d recommend?
<br><br>Thanks,<br>James<br><br><br><br><br><br><br><br><br><br>--<br>View this message in context: <a href="http://www.nabble.com/Dynamic-property-names...-tf3532720.html#a9859805">http://www.nabble.com/Dynamic-property-names...-tf3532720.html#a9859805
</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">
rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>&nbsp;&nbsp;Edson Tirelli
<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3124-6000<br>&nbsp;&nbsp;Mobile: +55 11 9218-4151<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>