From 95ec3bb684de853de179a991a3d0a79723a64a1c Mon Sep 17 00:00:00 2001 From: Toshiya Kobayashi Date: Thu, 19 Dec 2024 18:01:04 +0900 Subject: [PATCH] [incubator-kie-drools-6199] Clean up quartz related docs (#6202) --- .../_drl-timers-calendars-con.adoc | 16 +++++++++++----- .../_decision-tables-attributes-ref.adoc | 2 +- .../pages/language-reference/_drl-rules.adoc | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc index efa902d226c..3a3b886d244 100644 --- a/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc +++ b/drools-docs/src/modules/ROOT/pages/language-reference-traditional/_drl-timers-calendars-con.adoc @@ -133,7 +133,7 @@ In this example, the rule is scheduled for every hour, after a delay of 30 secon If the system is paused (for example, the session is serialized and then later deserialized), the rule is scheduled only one time to recover from missing activations regardless of how many activations were missed during the pause, and then the rule is subsequently scheduled again to continue in sync with the timer setting. -The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling a rule and supports the following format: +The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] style cron expression for scheduling a rule and supports the following format: .Calendar attribute format [source] @@ -151,18 +151,24 @@ calendars "* * 0-7,18-23 ? * *" calendars "weekday" ---- -You can adapt a Quartz calendar based on the Quartz calendar API and then register the calendar in the KIE session, as shown in the following example: +You can define a custom calendar and then register it in the KIE session, as shown in the following example: -.Adapting a Quartz Calendar +.Defining a Calendar [source,java] ---- -Calendar weekDayCal = QuartzHelper.quartzCalendarAdapter(org.quartz.Calendar quartzCal) +private static final org.kie.api.time.Calendar WEEKDAY = timestamp -> { + final Calendar c = Calendar.getInstance(); + c.setTimeInMillis(timestamp); + + final int day = c.get(Calendar.DAY_OF_WEEK); + return day != Calendar.SATURDAY && day != Calendar.SUNDAY; +}; ---- .Registering the calendar in the KIE session [source,java] ---- -ksession.getCalendars().set( "weekday", weekDayCal ); +ksession.getCalendars().set( "weekday", WEEKDAY ); ---- You can use calendars with standard rules and with rules that use timers. The calendar attribute can contain one or more comma-separated calendar names written as `String` literals. diff --git a/drools-docs/src/modules/ROOT/pages/language-reference/_decision-tables-attributes-ref.adoc b/drools-docs/src/modules/ROOT/pages/language-reference/_decision-tables-attributes-ref.adoc index 1f634675351..c893221c5db 100644 --- a/drools-docs/src/modules/ROOT/pages/language-reference/_decision-tables-attributes-ref.adoc +++ b/drools-docs/src/modules/ROOT/pages/language-reference/_decision-tables-attributes-ref.adoc @@ -81,7 +81,7 @@ Example: `TIMER "*/5 * * * *"` (every 5 minutes) |`CALENDAR` |E -|A Quartz calendar definition for scheduling the rule. +|A calendar definition for scheduling the rule. Example: `CALENDAR "* * 0-7,18-23 ? * *"` (exclude non-business hours) diff --git a/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc b/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc index 7aa0957a94c..f2a8288f73f 100644 --- a/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc +++ b/drools-docs/src/modules/ROOT/pages/language-reference/_drl-rules.adoc @@ -953,7 +953,7 @@ Example: `timer ( int: 30s 5m )` (every 5 minutes after a 30-second delay) `timer ( cron:* 0/15 * * * ? )` (every 15 minutes) |`calendar` -|A http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling the rule. +|A calendar definition for scheduling the rule. Example: `calendars "* * 0-7,18-23 ? * *"` (exclude non-business hours) @@ -1090,7 +1090,7 @@ In this example, the rule is scheduled for every hour, after a delay of 30 secon If the system is paused (for example, the session is serialized and then later deserialized), the rule is scheduled only one time to recover from missing internalMatches regardless of how many internalMatches were missed during the pause, and then the rule is subsequently scheduled again to continue in sync with the timer setting. -The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] calendar definition for scheduling a rule and supports the following format: +The `calendar` attribute in DRL rules is a http://www.quartz-scheduler.org/[Quartz] style cron expression for scheduling a rule and supports the following format: .Calendar attribute format [source,subs="+quotes"] @@ -1108,18 +1108,24 @@ calendars "* * 0-7,18-23 ? * *" calendars "weekday" ---- -You can adapt a Quartz calendar based on the Quartz calendar API and then register the calendar in the KIE session, as shown in the following example: +You can define a custom calendar and then register it in the KIE session, as shown in the following example: -.Adapting a Quartz Calendar +.Defining a Calendar [source,java] ---- -Calendar weekDayCal = QuartzHelper.quartzCalendarAdapter(org.quartz.Calendar quartzCal) +private static final org.kie.api.time.Calendar WEEKDAY = timestamp -> { + final Calendar c = Calendar.getInstance(); + c.setTimeInMillis(timestamp); + + final int day = c.get(Calendar.DAY_OF_WEEK); + return day != Calendar.SATURDAY && day != Calendar.SUNDAY; +}; ---- .Registering the calendar in the KIE session [source,java] ---- -ksession.getCalendars().set( "weekday", weekDayCal ); +ksession.getCalendars().set( "weekday", WEEKDAY ); ---- You can use calendars with standard rules and with rules that use timers. The calendar attribute can contain one or more comma-separated calendar names written as `String` literals.