1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.calendar.model.impl;
16  
17  import com.liferay.portal.kernel.cal.TZSRecurrence;
18  import com.liferay.portal.kernel.json.JSONFactoryUtil;
19  import com.liferay.portal.kernel.util.PropsKeys;
20  import com.liferay.portal.kernel.util.Time;
21  import com.liferay.portal.kernel.util.Validator;
22  import com.liferay.portal.util.PropsUtil;
23  import com.liferay.portlet.calendar.model.CalEvent;
24  
25  /**
26   * <a href="CalEventImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class CalEventImpl extends CalEventModelImpl implements CalEvent {
31  
32      public static final String BIRTHDAY = "birthday";
33  
34      public static final int REMIND_BY_AIM = 3;
35  
36      public static final int REMIND_BY_EMAIL = 1;
37  
38      public static final int REMIND_BY_ICQ = 4;
39  
40      public static final int REMIND_BY_MSN = 5;
41  
42      public static final int REMIND_BY_NONE = 0;
43  
44      public static final int REMIND_BY_SMS = 2;
45  
46      public static final int REMIND_BY_YM = 6;
47  
48      public static final long[] REMINDERS = {
49          Time.MINUTE * 5, Time.MINUTE * 15, Time.MINUTE * 30, Time.HOUR,
50          Time.HOUR * 2, Time.HOUR * 3, Time.HOUR * 6, Time.HOUR * 12, Time.DAY,
51          Time.DAY * 2, Time.DAY * 3, Time.DAY * 4, Time.DAY * 5, Time.DAY * 6,
52          Time.DAY * 7, Time.DAY * 8, Time.DAY * 9, Time.DAY * 10, Time.DAY * 11,
53          Time.DAY * 12, Time.DAY * 13, Time.DAY * 14
54      };
55  
56      public static final String[] TYPES =
57          PropsUtil.getArray(PropsKeys.CALENDAR_EVENT_TYPES);
58  
59      public CalEventImpl() {
60      }
61  
62      public TZSRecurrence getRecurrenceObj() {
63          if (_recurrenceObj == null) {
64              String recurrence = getRecurrence();
65  
66              if (Validator.isNotNull(recurrence)) {
67                  _recurrenceObj = (TZSRecurrence)JSONFactoryUtil.deserialize(
68                      recurrence);
69              }
70          }
71  
72          return _recurrenceObj;
73      }
74  
75      public void setRecurrence(String recurrence) {
76          _recurrenceObj = null;
77  
78          super.setRecurrence(recurrence);
79      }
80  
81      public void setRecurrenceObj(TZSRecurrence recurrenceObj) {
82          _recurrenceObj = recurrenceObj;
83  
84          super.setRecurrence(JSONFactoryUtil.serialize(recurrenceObj));
85      }
86  
87      private TZSRecurrence _recurrenceObj = null;
88  
89  }