Geoffrey, go ahead and open it. The only thing important is to note
that a "||" field constraint is semantically different from "||" pattern
(column) constraint.
Thanks
Edson
Geoffrey De Smet wrote:
Edson Tirelli wrote, On 2006-11-10 12:37 AM:
Hey Geoffrey,
You guys are doing a great job testing things. Thanks.
The correct syntax would be like that:
query "multipleMatchesPerTeamPerDay"
$team : Team()
Match( $id : id, homeTeam == $team, $day : day ) ||
Match( $id : id, awayTeam == $team, $day : day )
exists Match( id > $id, homeTeam == $team, day == $day ) ||
exists Match(id > $id, awayTeam == $team, day == $day )
end
Although, seems there is a regression as it is raising an error
saying variables are being declared twice. Although, when using "||"
(or), variables MUST be bound in each logical outcome.
Do you mind opening a JIRA for that?
I will and I 'll add a testcase patch us usual :)
Still I believe something like
Match($id : id, homeTeam == $team || awayTeam == $team, $day : day)
should be possible in the long term, because:
- it avoids duplicating the id and day constraints, which makes the
rule a lot easier to read
- drools could be smart enough to compile that in a way to reuse the
beta nodes of id and day maybe? - if it doesn't already
Do you mind if I open a second (long-term feature request) JIRA for
that too?
Thank you,
Regards,
Edson
Geoffrey De Smet wrote:
I got a simple domain model:
public class Match {
private Long id;
private Team homeTeam;
private Team awayTeam;
private Day day;
// getter, setters, ...
}
And a rule (query) that checks if a team has 2 matches on the same
day (no matter if they are the home or the away team):
query "multipleMatchesPerTeamPerDay"
$team : Team();
Match($id : id, homeTeam == $team || awayTeam == $team, $day :
day);
exists Match(id > $id, homeTeam == $team || awayTeam == $team,
day == $day);
end
But apparently I can't do this?
unknown:12:50 Unexpected token '=='
unknown:13:39 Unexpected token '$team'
unknown:13:57 Unexpected token '=='
unknown:18:33 Unexpected token 'day'
Line 12 is: Match($id : id, homeTeam == $team || awayTeam == $team,
$day : day);
Is there any way to avoid having to write a separate rule (query)
for every combination (home-home, away-home, home-away, away-away)?
Thanks for any help/advice.
--
---
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
IT executives: Red Hat still #1 for value
http://www.redhat.com/promo/vendor/
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email