1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.calendar.model.impl;
24  
25  import com.liferay.portal.kernel.cal.TZSRecurrence;
26  import com.liferay.portal.kernel.json.JSONFactoryUtil;
27  import com.liferay.portal.kernel.util.Time;
28  import com.liferay.portal.kernel.util.Validator;
29  import com.liferay.portal.util.PropsKeys;
30  import com.liferay.portal.util.PropsUtil;
31  import com.liferay.portlet.calendar.model.CalEvent;
32  
33  /**
34   * <a href="CalEventImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class CalEventImpl extends CalEventModelImpl implements CalEvent {
40  
41      public static final String[] TYPES =
42          PropsUtil.getArray(PropsKeys.CALENDAR_EVENT_TYPES);
43  
44      public static final String BIRTHDAY = "birthday";
45  
46      public static final int REMIND_BY_AIM = 3;
47  
48      public static final int REMIND_BY_EMAIL = 1;
49  
50      public static final int REMIND_BY_ICQ = 4;
51  
52      public static final int REMIND_BY_MSN = 5;
53  
54      public static final int REMIND_BY_NONE = 0;
55  
56      public static final int REMIND_BY_SMS = 2;
57  
58      public static final int REMIND_BY_YM = 6;
59  
60      public static final long[] REMINDERS = {
61          Time.MINUTE * 5, Time.MINUTE * 15, Time.MINUTE * 30, Time.HOUR,
62          Time.HOUR * 2, Time.HOUR * 3, Time.HOUR * 6, Time.HOUR * 12, Time.DAY,
63          Time.DAY * 2, Time.DAY * 3, Time.DAY * 4, Time.DAY * 5, Time.DAY * 6,
64          Time.DAY * 7, Time.DAY * 8, Time.DAY * 9, Time.DAY * 10, Time.DAY * 11,
65          Time.DAY * 12, Time.DAY * 13, Time.DAY * 14
66      };
67  
68      public CalEventImpl() {
69      }
70  
71      public void setRecurrence(String recurrence) {
72          _recurrenceObj = null;
73  
74          super.setRecurrence(recurrence);
75      }
76  
77      public TZSRecurrence getRecurrenceObj() {
78          if (_recurrenceObj == null) {
79              String recurrence = getRecurrence();
80  
81              if (Validator.isNotNull(recurrence)) {
82                  _recurrenceObj = (TZSRecurrence)JSONFactoryUtil.deserialize(
83                      recurrence);
84              }
85          }
86  
87          return _recurrenceObj;
88      }
89  
90      public void setRecurrenceObj(TZSRecurrence recurrenceObj) {
91          _recurrenceObj = recurrenceObj;
92  
93          super.setRecurrence(JSONFactoryUtil.serialize(recurrenceObj));
94      }
95  
96      private TZSRecurrence _recurrenceObj = null;
97  
98  }