1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.calendar.model.impl;
21  
22  import com.liferay.portal.SystemException;
23  import com.liferay.portal.kernel.cal.TZSRecurrence;
24  import com.liferay.portal.kernel.json.JSONFactoryUtil;
25  import com.liferay.portal.kernel.util.Time;
26  import com.liferay.portal.kernel.util.Validator;
27  import com.liferay.portal.util.PortalUtil;
28  import com.liferay.portal.util.PropsKeys;
29  import com.liferay.portal.util.PropsUtil;
30  import com.liferay.portlet.calendar.model.CalEvent;
31  
32  /**
33   * <a href="CalEventImpl.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Brian Wing Shun Chan
36   *
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 String getUserUuid() throws SystemException {
71          return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
72      }
73  
74      public void setUserUuid(String userUuid) {
75          _userUuid = userUuid;
76      }
77  
78      public void setRecurrence(String recurrence) {
79          _recurrenceObj = null;
80  
81          super.setRecurrence(recurrence);
82      }
83  
84      public TZSRecurrence getRecurrenceObj() {
85          if (_recurrenceObj == null) {
86              String recurrence = getRecurrence();
87  
88              if (Validator.isNotNull(recurrence)) {
89                  _recurrenceObj = (TZSRecurrence)JSONFactoryUtil.deserialize(
90                      recurrence);
91              }
92          }
93  
94          return _recurrenceObj;
95      }
96  
97      public void setRecurrenceObj(TZSRecurrence recurrenceObj) {
98          _recurrenceObj = recurrenceObj;
99  
100         super.setRecurrence(JSONFactoryUtil.serialize(recurrenceObj));
101     }
102 
103     private String _userUuid;
104     private TZSRecurrence _recurrenceObj = null;
105 
106 }