001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.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    
022    import com.liferay.portlet.blogs.model.BlogsEntry;
023    
024    import java.util.Date;
025    import java.util.List;
026    
027    /**
028     * @author    Brian Wing Shun Chan
029     * @generated
030     */
031    public class BlogsEntryJSONSerializer {
032            public static JSONObject toJSONObject(BlogsEntry model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("entryId", model.getEntryId());
037                    jsonObj.put("groupId", model.getGroupId());
038                    jsonObj.put("companyId", model.getCompanyId());
039                    jsonObj.put("userId", model.getUserId());
040                    jsonObj.put("userName", model.getUserName());
041    
042                    Date createDate = model.getCreateDate();
043    
044                    String createDateJSON = StringPool.BLANK;
045    
046                    if (createDate != null) {
047                            createDateJSON = String.valueOf(createDate.getTime());
048                    }
049    
050                    jsonObj.put("createDate", createDateJSON);
051    
052                    Date modifiedDate = model.getModifiedDate();
053    
054                    String modifiedDateJSON = StringPool.BLANK;
055    
056                    if (modifiedDate != null) {
057                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
058                    }
059    
060                    jsonObj.put("modifiedDate", modifiedDateJSON);
061                    jsonObj.put("title", model.getTitle());
062                    jsonObj.put("urlTitle", model.getUrlTitle());
063                    jsonObj.put("content", model.getContent());
064    
065                    Date displayDate = model.getDisplayDate();
066    
067                    String displayDateJSON = StringPool.BLANK;
068    
069                    if (displayDate != null) {
070                            displayDateJSON = String.valueOf(displayDate.getTime());
071                    }
072    
073                    jsonObj.put("displayDate", displayDateJSON);
074                    jsonObj.put("allowPingbacks", model.getAllowPingbacks());
075                    jsonObj.put("allowTrackbacks", model.getAllowTrackbacks());
076                    jsonObj.put("trackbacks", model.getTrackbacks());
077                    jsonObj.put("status", model.getStatus());
078                    jsonObj.put("statusByUserId", model.getStatusByUserId());
079                    jsonObj.put("statusByUserName", model.getStatusByUserName());
080    
081                    Date statusDate = model.getStatusDate();
082    
083                    String statusDateJSON = StringPool.BLANK;
084    
085                    if (statusDate != null) {
086                            statusDateJSON = String.valueOf(statusDate.getTime());
087                    }
088    
089                    jsonObj.put("statusDate", statusDateJSON);
090    
091                    return jsonObj;
092            }
093    
094            public static JSONArray toJSONArray(
095                    com.liferay.portlet.blogs.model.BlogsEntry[] models) {
096                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
097    
098                    for (BlogsEntry model : models) {
099                            jsonArray.put(toJSONObject(model));
100                    }
101    
102                    return jsonArray;
103            }
104    
105            public static JSONArray toJSONArray(
106                    com.liferay.portlet.blogs.model.BlogsEntry[][] models) {
107                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
108    
109                    for (BlogsEntry[] model : models) {
110                            jsonArray.put(toJSONArray(model));
111                    }
112    
113                    return jsonArray;
114            }
115    
116            public static JSONArray toJSONArray(
117                    List<com.liferay.portlet.blogs.model.BlogsEntry> models) {
118                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
119    
120                    for (BlogsEntry model : models) {
121                            jsonArray.put(toJSONObject(model));
122                    }
123    
124                    return jsonArray;
125            }
126    }