<div dir="ltr">Hello Droolers,<br><br>I'm a Drools novice and I'm stuck with a basic rule problem.<br><br>In my domain I use a list of abbreviations to describe the conditions of a system.<br>Before I can check the state of my system I have to verify all applied abbreviations.<br>
<br>The List of abbreviations is not a fixed list it's more like a combination of chars, combined in different ways on fixed positions.<br><br>This is a small cutout:<br><br>A cutout of possible chars at Position 1: A B C D F H<br>
A cutout of possible chars at Position 2: - A C s n b<br>A cutout of possible chars at Position 3: - A B E F M<br>A cutout of possible chars at Position 4: - H L O R U<br><br>Now it is allowed to combine the following abbreviations:<br>
(another small cutout)<br><br>A--O A--R A--U A--L<br>BAAO BAAR BAAU BAAL<br><br>but it is not allowed to combine this:<br><br>AA** B-** (* stands for all possible chars on a position)<br><br>Now I have 2 basic Questions:<br>
<br>1) How can I pick abbreviations that are NOT allowed?<br> I think it's easy to say:<br><br> rule "Rule 1"<br> when<br> a : Abbreviation( pos1 == 'A', pos2 == '-', pos3 == '-', pos4 == 'O' )<br>
then<br> # do something positiv<br> end<br><br> But how can I pick up all the wrong combinations without hardcoding them?<br> This would end up in a never-ending story.<br><br>2) Upgrading the "Rule 1" from my 1st Question I'm looking for a way to make the<br>
Rules more generic.<br> I don't want to hardcode all possible abbreviation combinations.<br> How can I realise something like this VERY INFORMAL notation:<br><br> rule "Rule 2"<br> when<br> a : Abbreviation( pos1 == 'A', pos2 == ['-','D','H'], pos3 == '-', pos4 == ['O', 'R', 'U', 'L'] )<br>
# If abbreviation looks like A--O, AD-O, AD-U, AH-R, etc. everything is fine.<br> # It's time for "Rule 2" to do something positiv<br> then<br> # do something positiv<br> end<br><br> "Rule 2" should find all the abbreviations that are build up according to a set of allowed char combinations.<br>
<br> OR<br><br> rule "Rule 3"<br> when<br> a : Abbreviation( pos1 == 'A', pos2 != ['-','D','H'], pos3 != '-', pos4 != ['O', 'R', 'U', 'L'] )<br>
# If abbreviation looks like AA-O, AB-U, A-AO, A--K, etc. something is wrong.<br> # It's time for "RULE 3" to announce something negative<br> then<br> # announce something negative<br> end<br>
<br> "Rule 3" should filter all the abbreviations that are violating a set of allowed char combinations.<br><br>Thanx 2 all droolers in advance.<br><br>Pete</div>