lib/openwfe/expressions/fe_sleep.rb in openwferu-0.9.7 vs lib/openwfe/expressions/fe_sleep.rb in openwferu-0.9.8
- old
+ new
@@ -39,74 +39,20 @@
# John Mettraux at openwfe.org
#
require 'openwfe/util/otime'
require 'openwfe/util/scheduler'
+require 'openwfe/expressions/time'
#
# just the 'sleep' expression
#
module OpenWFE
#
- # A parent class for CronExpression and SleepExpression, is never
- # used directly.
- # It contains a simple get_scheduler() method simplifying the scheduler
- # localization for <sleep/> and <cron/>.
- #
- class TimeExpression < FlowExpression
- include Schedulable
-
- attr_accessor \
- :applied_workitem,
- :scheduler_job_id
-
- #
- # Makes sure to cancel any scheduler job associated with this
- # expression
- #
- def cancel ()
- synchronize do
-
- ldebug { "cancel()..." }
-
- unschedule()
-
- return super()
- end
- end
-
- def unschedule ()
-
- ldebug { "unschedule() @scheduler_job_id is #{@scheduler_job_id}" }
-
- get_scheduler.unschedule(@scheduler_job_id) \
- if @scheduler_job_id
- end
-
- protected
-
- #
- # Will return true if this TimeExpression has a
- # 'scheduler_job_ib' and this job is this expression's job.
- #
- # The job_id is specifiable, so that this method can also be
- # used by the 'when' expression for example.
- #
- def already_scheduled? (job_id=nil)
-
- job_id = @scheduler_job_id unless job_id
-
- s = get_scheduler.get_schedulable job_id
-
- return (s and s.fei == self.fei)
- end
- end
-
- #
# The 'sleep' expression expects one attribute, either 'for', either
# 'until'.
#
# <sequence>
# <sleep for="10m12s" />
@@ -127,12 +73,11 @@
#synchronize do
sfor = lookup_attribute(:for, workitem)
suntil = lookup_attribute(:until, workitem)
- if sfor == nil and suntil == nil
- sfor = OpenWFE::fetch_text_content(self, workitem)
- end
+ sfor = fetch_text_content(workitem) \
+ if sfor == nil and suntil == nil
#ldebug { "apply() sfor is '#{sfor}'" }
#ldebug { "apply() suntil is '#{suntil}'" }
tuntil = nil