1
14
15 package com.liferay.portal.service.http;
16
17 import com.liferay.portal.kernel.json.JSONArray;
18 import com.liferay.portal.kernel.json.JSONFactoryUtil;
19 import com.liferay.portal.kernel.json.JSONObject;
20 import com.liferay.portal.model.Organization;
21
22 import java.util.List;
23
24
40 public class OrganizationJSONSerializer {
41 public static JSONObject toJSONObject(Organization model) {
42 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
43
44 jsonObj.put("organizationId", model.getOrganizationId());
45 jsonObj.put("companyId", model.getCompanyId());
46 jsonObj.put("parentOrganizationId", model.getParentOrganizationId());
47 jsonObj.put("leftOrganizationId", model.getLeftOrganizationId());
48 jsonObj.put("rightOrganizationId", model.getRightOrganizationId());
49 jsonObj.put("name", model.getName());
50 jsonObj.put("type", model.getType());
51 jsonObj.put("recursable", model.getRecursable());
52 jsonObj.put("regionId", model.getRegionId());
53 jsonObj.put("countryId", model.getCountryId());
54 jsonObj.put("statusId", model.getStatusId());
55 jsonObj.put("comments", model.getComments());
56
57 return jsonObj;
58 }
59
60 public static JSONArray toJSONArray(
61 com.liferay.portal.model.Organization[] models) {
62 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
63
64 for (Organization model : models) {
65 jsonArray.put(toJSONObject(model));
66 }
67
68 return jsonArray;
69 }
70
71 public static JSONArray toJSONArray(
72 com.liferay.portal.model.Organization[][] models) {
73 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
74
75 for (Organization[] model : models) {
76 jsonArray.put(toJSONArray(model));
77 }
78
79 return jsonArray;
80 }
81
82 public static JSONArray toJSONArray(
83 List<com.liferay.portal.model.Organization> models) {
84 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
85
86 for (Organization model : models) {
87 jsonArray.put(toJSONObject(model));
88 }
89
90 return jsonArray;
91 }
92 }