I didn't get any feedback when I posted earlier today, so I went ahead and implemented what I thought would work ... and I figured I should share it here since it seems to be working pretty well.
I created a Rule Flow as follows: A Rule-Flow-Group that validates the arrays. Unfortunately I sometimes get multiple related arrays of records instead of a single array of records. I confirm that records with mandatory values have arrays with at least one element, and confirm that the related arrays are of equal length. Errors are logged. A subsequent Rule-Flow-Group that manages inserts. The data actually comes to me as one data structure comprised of sub-records of various types, and I have DRL files for each record type. Some of the sub-records are optional, and since subsequent rules would erroneously flag empty sub-records as errors I have rules here which only allow optional records containing values to be inserted into the system. I am currently using for-loops in the THEN section of some rules to deal with the array problem and would like to know if there is a better way. No errors are generated here. A subsequent Rule-Flow-Group that validates data. The data is all sent to me as Strings, even though many of the values are numbers, dates, etc. This Rule-Flow group tests the various fields using regular expressions, and if a regular expression fails then the record is flagged as having an error. Optional fields are dealt with by the regular expression allowing a blank. Errors are logged. A Diverging Gateway that splits the data into two ... records without validation errors are allowed to progress to the value-checking Rule-Flow group ... those with errors have nothing more done to them. I realize that I could, for instance, let records with bogus numbers thru as long as my string-to-integer routine is robust, however I don't want to flag the same record multiple times (once by reg-ex and then again by the next Rule-Flow-Group). A subsequent Rule-Flow-Group that checks the values and ranges of the numbers, dates, etc, and does other types of validation (e.g. if fieldA has a value greater than 20 then fieldB must be set to "XYZ"). Errors are logged. This Rule-Flow approach currently seems to be solving all of my problems, and it allows me to keep the rules simple and well structured such that most of them are reusable in other parts of our system. I'm interested in getting feedback on this approach ... it seems to be working pretty well for me. It allows me to deal with ordering issues and many of the if/else issues, while keeping the rules simple enough for our non-technical analysts to review without needing a developer to sit next to them. I realize this is a pretty mundane application for a powerful rules system, but it seems like a good fit nonetheless. Thanks Ron -- View this message in context: http://drools.46999.n3.nabble.com/This-ordered-record-validation-approach-is-working-tp3568933p3568933.html Sent from the Drools: User forum mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
