001
014
015 package com.liferay.portal.service.http;
016
017 import com.liferay.portal.kernel.json.JSONArray;
018 import com.liferay.portal.kernel.json.JSONFactoryUtil;
019 import com.liferay.portal.kernel.json.JSONObject;
020 import com.liferay.portal.model.Layout;
021
022 import java.util.List;
023
024
028 public class LayoutJSONSerializer {
029 public static JSONObject toJSONObject(Layout model) {
030 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
031
032 jsonObj.put("uuid", model.getUuid());
033 jsonObj.put("plid", model.getPlid());
034 jsonObj.put("groupId", model.getGroupId());
035 jsonObj.put("companyId", model.getCompanyId());
036 jsonObj.put("privateLayout", model.getPrivateLayout());
037 jsonObj.put("layoutId", model.getLayoutId());
038 jsonObj.put("parentLayoutId", model.getParentLayoutId());
039 jsonObj.put("name", model.getName());
040 jsonObj.put("title", model.getTitle());
041 jsonObj.put("description", model.getDescription());
042 jsonObj.put("type", model.getType());
043 jsonObj.put("typeSettings", model.getTypeSettings());
044 jsonObj.put("hidden", model.getHidden());
045 jsonObj.put("friendlyURL", model.getFriendlyURL());
046 jsonObj.put("iconImage", model.getIconImage());
047 jsonObj.put("iconImageId", model.getIconImageId());
048 jsonObj.put("themeId", model.getThemeId());
049 jsonObj.put("colorSchemeId", model.getColorSchemeId());
050 jsonObj.put("wapThemeId", model.getWapThemeId());
051 jsonObj.put("wapColorSchemeId", model.getWapColorSchemeId());
052 jsonObj.put("css", model.getCss());
053 jsonObj.put("priority", model.getPriority());
054 jsonObj.put("layoutPrototypeId", model.getLayoutPrototypeId());
055 jsonObj.put("dlFolderId", model.getDlFolderId());
056
057 return jsonObj;
058 }
059
060 public static JSONArray toJSONArray(
061 com.liferay.portal.model.Layout[] models) {
062 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
063
064 for (Layout model : models) {
065 jsonArray.put(toJSONObject(model));
066 }
067
068 return jsonArray;
069 }
070
071 public static JSONArray toJSONArray(
072 com.liferay.portal.model.Layout[][] models) {
073 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
074
075 for (Layout[] model : models) {
076 jsonArray.put(toJSONArray(model));
077 }
078
079 return jsonArray;
080 }
081
082 public static JSONArray toJSONArray(
083 List<com.liferay.portal.model.Layout> models) {
084 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
085
086 for (Layout model : models) {
087 jsonArray.put(toJSONObject(model));
088 }
089
090 return jsonArray;
091 }
092 }