1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
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.kernel.util.StringPool;
21  import com.liferay.portal.model.MembershipRequest;
22  
23  import java.util.Date;
24  import java.util.List;
25  
26  /**
27   * <a href="MembershipRequestJSONSerializer.java.html"><b><i>View Source</i></b></a>
28   *
29   * <p>
30   * ServiceBuilder generated this class. Modifications in this class will be
31   * overwritten the next time is generated.
32   * </p>
33   *
34   * <p>
35   * This class is used by {@link MembershipRequestServiceJSON} to translate objects.
36   * </p>
37   *
38   * @author    Brian Wing Shun Chan
39   * @see       com.liferay.portal.service.http.MembershipRequestServiceJSON
40   * @generated
41   */
42  public class MembershipRequestJSONSerializer {
43      public static JSONObject toJSONObject(MembershipRequest model) {
44          JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
45  
46          jsonObj.put("membershipRequestId", model.getMembershipRequestId());
47          jsonObj.put("companyId", model.getCompanyId());
48          jsonObj.put("userId", model.getUserId());
49  
50          Date createDate = model.getCreateDate();
51  
52          String createDateJSON = StringPool.BLANK;
53  
54          if (createDate != null) {
55              createDateJSON = String.valueOf(createDate.getTime());
56          }
57  
58          jsonObj.put("createDate", createDateJSON);
59          jsonObj.put("groupId", model.getGroupId());
60          jsonObj.put("comments", model.getComments());
61          jsonObj.put("replyComments", model.getReplyComments());
62  
63          Date replyDate = model.getReplyDate();
64  
65          String replyDateJSON = StringPool.BLANK;
66  
67          if (replyDate != null) {
68              replyDateJSON = String.valueOf(replyDate.getTime());
69          }
70  
71          jsonObj.put("replyDate", replyDateJSON);
72          jsonObj.put("replierUserId", model.getReplierUserId());
73          jsonObj.put("statusId", model.getStatusId());
74  
75          return jsonObj;
76      }
77  
78      public static JSONArray toJSONArray(
79          com.liferay.portal.model.MembershipRequest[] models) {
80          JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
81  
82          for (MembershipRequest model : models) {
83              jsonArray.put(toJSONObject(model));
84          }
85  
86          return jsonArray;
87      }
88  
89      public static JSONArray toJSONArray(
90          com.liferay.portal.model.MembershipRequest[][] models) {
91          JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
92  
93          for (MembershipRequest[] model : models) {
94              jsonArray.put(toJSONArray(model));
95          }
96  
97          return jsonArray;
98      }
99  
100     public static JSONArray toJSONArray(
101         List<com.liferay.portal.model.MembershipRequest> models) {
102         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
103 
104         for (MembershipRequest model : models) {
105             jsonArray.put(toJSONObject(model));
106         }
107 
108         return jsonArray;
109     }
110 }