You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Temporal Expressions Tutorial

This tutorial is intended to be used with the current trunk version of Apache Open For Business.

Log into your local copy of OFBiz as admin. To create or modify temporal expressions, you will need to go to Web Tools -> Configuration -> Temporal Expression. To create calendar events based on temporal expressions, you will need to go to Work Effort -> Work Effort -> Create Work Effort. You should locate these screens and familiarize yourself with these applications before starting the tutorial.

Create A Frequency Expression

Let's say you want to keep track of your pay days - which occur every two weeks on Friday. To do that you will need a Frequency temporal expression.

In the Find Temporal Expression screen, click Create. In the Temporal Expression Maintenance screen, find the Frequency section. Type PAYDAY in the Expression ID field. Click the Calendar icon next to the From field to bring up a popup calendar. Select January 8, 2010 08:00. Click OK. Select Day Frequency Type and select 14 in the Frequency Count field. Click the Save button.

In the Create Work Effort screen, type "Pay Day" in the Name field. Select Event for the Type, select Confirmed for the Status, select General for the Scope, and use the Calendar icon to set Estimated Start Date to January 1, 2010. Scroll down the screen to find the Temporal Expression field. Select PAYDAY. Click Save. The Pay Day calendar event has been created. To view it, click the Calendar tab, then select Month View. You will see the pay day appear every two weeks on Friday.

Create A Day Of Month Event

Now that you have your pay days appearing on your calendar, you decide you would also like to see the days your car payment is due - which is the 15th of the month. There is no need to create a temporal expression for that - the OFBiz temporal expression demo data includes every day of the month.

In the Create Work Effort screen, type "Car Payment" in the Name field. Select Event for the Type, select Confirmed for the Status, select General for the Scope, and use the Calendar icon to set Estimated Start Date to January 1, 2010. Scroll down the screen to find the Temporal Expression field. Select DAYOFMONTH_15. Click Save. The Car Payment calendar event has been created. To view it, click the Calendar tab, then select Month View. You will see the the car payment due date appear every 15th of the month.

Create A Complicated Recurring Event

You like to play soccer. You like to play soccer so much you practice four days a week - Monday, Tuesday, Wednesday, and Saturday. The Monday through Wednesday practices are at 6 PM, and the Saturday practice is at 10 AM. On the last Saturday of the month a lacrosse team uses the field you practice on, so your teammates agreed to reschedule that practice to 1 PM Sunday. [Having a soccer team surrender a field to a lacrosse team is a supreme act of charity - one that your team is immensely proud of.] There is one other exception to the schedule your teammates agreed on: If a practice falls on Saint Patrick's Day, the practice is canceled (since it is very unlikely anyone would show up).

Now, you have no problem remembering your soccer practice schedule. The problem is, no one else can remember it - so you decide to add it to your calendar. If anyone wants to know when you are at soccer practice, all they have to do is check your calendar.

It would be best to start off by writing out the schedule using the temporal expression notation:

  Difference:
    Include:
      Substitution:
        Include:
          Union:
            Intersection:
              MinuteRange(0, 0)
              HourRange(18, 18)
              DayOfWeekRange(Monday, Wednesday)
            Intersection:
              MinuteRange(0, 0)
              HourRange(10, 10)
              DayOfWeekRange(Saturday, Saturday)
        Exclude:
          DayInMonth(Saturday, -1)
        Substitute:
          Intersection:
            MinuteRange(0, 0)
            HourRange(13, 13)
            DayOfWeekRange(Sunday, Sunday)
    Exclude:
      Intersection:
        DayOfMonthRange(17, 17)
        MonthRange(3, 3)

Complicated temporal expressions like this need to be built from the inside out. So, to start off you will create the Monday through Wednesday intersection, the Saturday intersection, the Sunday intersection, and the Saint Patrick's Day intersection. Finally, you will assemble the intersections into the Union, Substitution, and Difference collections.

  • No labels