Is this the correct way to use RecurrenceRule?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Is this the correct way to use RecurrenceRule?

Wan Agus-3
Hi all,

My users would like to setup jobs that will run at specific times of the
month (e.g. every 10th, and 20th of the month), and my initial reaction
was to look at ofbiz's own JobManager/JobSandbox.   From the data model,
specifically Recurrence_Rule table, this looks supported by ofbiz, so I
created a little test case for it.

Below is a list of entity definition that theoretically will execute a
job to print "Hello world" every other minute:


------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<entity-engine-xml>

    <RecurrenceRule recurrenceRuleId="20000" untilDateTime="2008-06-19
00:00:00.000" frequency="MINUTELY" intervalNumber="1"
byMinuteList="42,44,46,48,50,52,54,56,58,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40"
countNumber="-1"/>

    <RecurrenceInfo recurrenceInfoId="20000" startDateTime="2007-06-19
00:00:00.000" recurrenceRuleId="20000" recurrenceCount="0"/>

    <RuntimeData runtimeDataId="20000">
        <runtimeInfo><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<ofbiz-ser>
  <map-HashMap>
    <map-Entry>
      <map-Key>
        <std-String value="testString"/>
      </map-Key>
      <map-Value>
        <std-String value="hello world"/>
      </map-Value>
    </map-Entry>
  </map-HashMap>
</ofbiz-ser>
        ]]></runtimeInfo>
    </RuntimeData>

    <JobSandbox jobId="20000" jobName="test job" runTime="2007-06-19
00:00:00.000" serviceName="printSomething" runtimeDataId="20000"
poolId="pool" runAsUser="system" recurrenceInfoId="20000"/>

</entity-engine-xml>
--------------------------------------------------------------------

I've tried running this job and it doesn't get executed even once.  
Looking through the code, I spotted these two lines in RecurrenceRule.java:

Line 137:
byMinuteList = StringUtil.split(rule.getString("byMinuteList"), ",");


Line 397:
if (!byMinuteList.contains(new Integer(cal.get(Calendar.MINUTE))))


The 2nd line will always return false since the list contains String
objects and Integer objects.

Is this a bug in RecurrenceRule?  or more likely, am I missing something
here?

Thanks for all your assistances!

wan