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.Organization;
021
022 import java.util.List;
023
024
028 public class OrganizationJSONSerializer {
029 public static JSONObject toJSONObject(Organization model) {
030 JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
031
032 jsonObj.put("organizationId", model.getOrganizationId());
033 jsonObj.put("companyId", model.getCompanyId());
034 jsonObj.put("parentOrganizationId", model.getParentOrganizationId());
035 jsonObj.put("leftOrganizationId", model.getLeftOrganizationId());
036 jsonObj.put("rightOrganizationId", model.getRightOrganizationId());
037 jsonObj.put("name", model.getName());
038 jsonObj.put("type", model.getType());
039 jsonObj.put("recursable", model.getRecursable());
040 jsonObj.put("regionId", model.getRegionId());
041 jsonObj.put("countryId", model.getCountryId());
042 jsonObj.put("statusId", model.getStatusId());
043 jsonObj.put("comments", model.getComments());
044
045 return jsonObj;
046 }
047
048 public static JSONArray toJSONArray(
049 com.liferay.portal.model.Organization[] models) {
050 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
051
052 for (Organization model : models) {
053 jsonArray.put(toJSONObject(model));
054 }
055
056 return jsonArray;
057 }
058
059 public static JSONArray toJSONArray(
060 com.liferay.portal.model.Organization[][] models) {
061 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
062
063 for (Organization[] model : models) {
064 jsonArray.put(toJSONArray(model));
065 }
066
067 return jsonArray;
068 }
069
070 public static JSONArray toJSONArray(
071 List<com.liferay.portal.model.Organization> models) {
072 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
073
074 for (Organization model : models) {
075 jsonArray.put(toJSONObject(model));
076 }
077
078 return jsonArray;
079 }
080 }