001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
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.kernel.util.StringPool;
021    import com.liferay.portal.model.MembershipRequest;
022    
023    import java.util.Date;
024    import java.util.List;
025    
026    /**
027     * @author    Brian Wing Shun Chan
028     * @generated
029     */
030    public class MembershipRequestJSONSerializer {
031            public static JSONObject toJSONObject(MembershipRequest model) {
032                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
033    
034                    jsonObj.put("membershipRequestId", model.getMembershipRequestId());
035                    jsonObj.put("companyId", model.getCompanyId());
036                    jsonObj.put("userId", model.getUserId());
037    
038                    Date createDate = model.getCreateDate();
039    
040                    String createDateJSON = StringPool.BLANK;
041    
042                    if (createDate != null) {
043                            createDateJSON = String.valueOf(createDate.getTime());
044                    }
045    
046                    jsonObj.put("createDate", createDateJSON);
047                    jsonObj.put("groupId", model.getGroupId());
048                    jsonObj.put("comments", model.getComments());
049                    jsonObj.put("replyComments", model.getReplyComments());
050    
051                    Date replyDate = model.getReplyDate();
052    
053                    String replyDateJSON = StringPool.BLANK;
054    
055                    if (replyDate != null) {
056                            replyDateJSON = String.valueOf(replyDate.getTime());
057                    }
058    
059                    jsonObj.put("replyDate", replyDateJSON);
060                    jsonObj.put("replierUserId", model.getReplierUserId());
061                    jsonObj.put("statusId", model.getStatusId());
062    
063                    return jsonObj;
064            }
065    
066            public static JSONArray toJSONArray(
067                    com.liferay.portal.model.MembershipRequest[] models) {
068                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
069    
070                    for (MembershipRequest model : models) {
071                            jsonArray.put(toJSONObject(model));
072                    }
073    
074                    return jsonArray;
075            }
076    
077            public static JSONArray toJSONArray(
078                    com.liferay.portal.model.MembershipRequest[][] models) {
079                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
080    
081                    for (MembershipRequest[] model : models) {
082                            jsonArray.put(toJSONArray(model));
083                    }
084    
085                    return jsonArray;
086            }
087    
088            public static JSONArray toJSONArray(
089                    List<com.liferay.portal.model.MembershipRequest> models) {
090                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
091    
092                    for (MembershipRequest model : models) {
093                            jsonArray.put(toJSONObject(model));
094                    }
095    
096                    return jsonArray;
097            }
098    }