1
22
23 package com.liferay.portlet.calendar.service.http;
24
25 import com.liferay.portlet.calendar.model.CalEvent;
26
27 import com.liferay.util.JSONUtil;
28
29 import org.json.JSONArray;
30 import org.json.JSONObject;
31
32 import java.util.List;
33
34
53 public class CalEventJSONSerializer {
54 public static JSONObject toJSONObject(CalEvent model) {
55 JSONObject jsonObj = new JSONObject();
56
57 JSONUtil.put(jsonObj, "uuid", model.getUuid());
58 JSONUtil.put(jsonObj, "eventId", model.getEventId());
59 JSONUtil.put(jsonObj, "groupId", model.getGroupId());
60 JSONUtil.put(jsonObj, "companyId", model.getCompanyId());
61 JSONUtil.put(jsonObj, "userId", model.getUserId());
62 JSONUtil.put(jsonObj, "userName", model.getUserName());
63 JSONUtil.put(jsonObj, "createDate", model.getCreateDate());
64 JSONUtil.put(jsonObj, "modifiedDate", model.getModifiedDate());
65 JSONUtil.put(jsonObj, "title", model.getTitle());
66 JSONUtil.put(jsonObj, "description", model.getDescription());
67 JSONUtil.put(jsonObj, "startDate", model.getStartDate());
68 JSONUtil.put(jsonObj, "endDate", model.getEndDate());
69 JSONUtil.put(jsonObj, "durationHour", model.getDurationHour());
70 JSONUtil.put(jsonObj, "durationMinute", model.getDurationMinute());
71 JSONUtil.put(jsonObj, "allDay", model.getAllDay());
72 JSONUtil.put(jsonObj, "timeZoneSensitive", model.getTimeZoneSensitive());
73 JSONUtil.put(jsonObj, "type", model.getType());
74 JSONUtil.put(jsonObj, "repeating", model.getRepeating());
75 JSONUtil.put(jsonObj, "recurrence", model.getRecurrence());
76 JSONUtil.put(jsonObj, "remindBy", model.getRemindBy());
77 JSONUtil.put(jsonObj, "firstReminder", model.getFirstReminder());
78 JSONUtil.put(jsonObj, "secondReminder", model.getSecondReminder());
79
80 return jsonObj;
81 }
82
83 public static JSONArray toJSONArray(
84 List<com.liferay.portlet.calendar.model.CalEvent> models) {
85 JSONArray jsonArray = new JSONArray();
86
87 for (CalEvent model : models) {
88 jsonArray.put(toJSONObject(model));
89 }
90
91 return jsonArray;
92 }
93 }