1
22
23 package com.liferay.portlet.journal.service.http;
24
25 import com.liferay.portlet.journal.model.JournalTemplate;
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 JournalTemplateJSONSerializer {
54 public static JSONObject toJSONObject(JournalTemplate model) {
55 JSONObject jsonObj = new JSONObject();
56
57 JSONUtil.put(jsonObj, "uuid", model.getUuid());
58 JSONUtil.put(jsonObj, "id", model.getId());
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, "templateId", model.getTemplateId());
66 JSONUtil.put(jsonObj, "structureId", model.getStructureId());
67 JSONUtil.put(jsonObj, "name", model.getName());
68 JSONUtil.put(jsonObj, "description", model.getDescription());
69 JSONUtil.put(jsonObj, "xsl", model.getXsl());
70 JSONUtil.put(jsonObj, "langType", model.getLangType());
71 JSONUtil.put(jsonObj, "cacheable", model.getCacheable());
72 JSONUtil.put(jsonObj, "smallImage", model.getSmallImage());
73 JSONUtil.put(jsonObj, "smallImageId", model.getSmallImageId());
74 JSONUtil.put(jsonObj, "smallImageURL", model.getSmallImageURL());
75
76 return jsonObj;
77 }
78
79 public static JSONArray toJSONArray(
80 List<com.liferay.portlet.journal.model.JournalTemplate> models) {
81 JSONArray jsonArray = new JSONArray();
82
83 for (JournalTemplate model : models) {
84 jsonArray.put(toJSONObject(model));
85 }
86
87 return jsonArray;
88 }
89 }