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  public class CalEventImpl extends CalEventModelImpl implements CalEvent {
39  
40      public static final String[] TYPES =
41          PropsUtil.getArray(PropsKeys.CALENDAR_EVENT_TYPES);
42  
43      public static final String BIRTHDAY = "birthday";
44  
45      public static final int REMIND_BY_AIM = 3;
46  
47      public static final int REMIND_BY_EMAIL = 1;
48  
49      public static final int REMIND_BY_ICQ = 4;
50  
51      public static final int REMIND_BY_MSN = 5;
52  
53      public static final int REMIND_BY_NONE = 0;
54  
55      public static final int REMIND_BY_SMS = 2;
56  
57      public static final int REMIND_BY_YM = 6;
58  
59      public static final long[] REMINDERS = {
60          Time.MINUTE * 5, Time.MINUTE * 15, Time.MINUTE * 30, Time.HOUR,
61          Time.HOUR * 2, Time.HOUR * 3, Time.HOUR * 6, Time.HOUR * 12, Time.DAY,
62          Time.DAY * 2, Time.DAY * 3, Time.DAY * 4, Time.DAY * 5, Time.DAY * 6,
63          Time.DAY * 7, Time.DAY * 8, Time.DAY * 9, Time.DAY * 10, Time.DAY * 11,
64          Time.DAY * 12, Time.DAY * 13, Time.DAY * 14
65      };
66  
67      public CalEventImpl() {
68      }
69  
70      public void setRecurrence(String recurrence) {
71          _recurrenceObj = null;
72  
73          super.setRecurrence(recurrence);
74      }
75  
76      public TZSRecurrence getRecurrenceObj() {
77          if (_recurrenceObj == null) {
78              String recurrence = getRecurrence();
79  
80              if (Validator.isNotNull(recurrence)) {
81                  _recurrenceObj = (TZSRecurrence)JSONFactoryUtil.deserialize(
82                      recurrence);
83              }
84          }
85  
86          return _recurrenceObj;
87      }
88  
89      public void setRecurrenceObj(TZSRecurrence recurrenceObj) {
90          _recurrenceObj = recurrenceObj;
91  
92          super.setRecurrence(JSONFactoryUtil.serialize(recurrenceObj));
93      }
94  
95      private TZSRecurrence _recurrenceObj = null;
96  
97  }