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.journal.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.journal.model.JournalArticle;
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 JournalArticleJSONSerializer {
032            public static JSONObject toJSONObject(JournalArticle model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("id", model.getId());
037                    jsonObj.put("resourcePrimKey", model.getResourcePrimKey());
038                    jsonObj.put("groupId", model.getGroupId());
039                    jsonObj.put("companyId", model.getCompanyId());
040                    jsonObj.put("userId", model.getUserId());
041                    jsonObj.put("userName", model.getUserName());
042    
043                    Date createDate = model.getCreateDate();
044    
045                    String createDateJSON = StringPool.BLANK;
046    
047                    if (createDate != null) {
048                            createDateJSON = String.valueOf(createDate.getTime());
049                    }
050    
051                    jsonObj.put("createDate", createDateJSON);
052    
053                    Date modifiedDate = model.getModifiedDate();
054    
055                    String modifiedDateJSON = StringPool.BLANK;
056    
057                    if (modifiedDate != null) {
058                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
059                    }
060    
061                    jsonObj.put("modifiedDate", modifiedDateJSON);
062                    jsonObj.put("articleId", model.getArticleId());
063                    jsonObj.put("version", model.getVersion());
064                    jsonObj.put("title", model.getTitle());
065                    jsonObj.put("urlTitle", model.getUrlTitle());
066                    jsonObj.put("description", model.getDescription());
067                    jsonObj.put("content", model.getContent());
068                    jsonObj.put("type", model.getType());
069                    jsonObj.put("structureId", model.getStructureId());
070                    jsonObj.put("templateId", model.getTemplateId());
071    
072                    Date displayDate = model.getDisplayDate();
073    
074                    String displayDateJSON = StringPool.BLANK;
075    
076                    if (displayDate != null) {
077                            displayDateJSON = String.valueOf(displayDate.getTime());
078                    }
079    
080                    jsonObj.put("displayDate", displayDateJSON);
081    
082                    Date expirationDate = model.getExpirationDate();
083    
084                    String expirationDateJSON = StringPool.BLANK;
085    
086                    if (expirationDate != null) {
087                            expirationDateJSON = String.valueOf(expirationDate.getTime());
088                    }
089    
090                    jsonObj.put("expirationDate", expirationDateJSON);
091    
092                    Date reviewDate = model.getReviewDate();
093    
094                    String reviewDateJSON = StringPool.BLANK;
095    
096                    if (reviewDate != null) {
097                            reviewDateJSON = String.valueOf(reviewDate.getTime());
098                    }
099    
100                    jsonObj.put("reviewDate", reviewDateJSON);
101                    jsonObj.put("indexable", model.getIndexable());
102                    jsonObj.put("smallImage", model.getSmallImage());
103                    jsonObj.put("smallImageId", model.getSmallImageId());
104                    jsonObj.put("smallImageURL", model.getSmallImageURL());
105                    jsonObj.put("status", model.getStatus());
106                    jsonObj.put("statusByUserId", model.getStatusByUserId());
107                    jsonObj.put("statusByUserName", model.getStatusByUserName());
108    
109                    Date statusDate = model.getStatusDate();
110    
111                    String statusDateJSON = StringPool.BLANK;
112    
113                    if (statusDate != null) {
114                            statusDateJSON = String.valueOf(statusDate.getTime());
115                    }
116    
117                    jsonObj.put("statusDate", statusDateJSON);
118    
119                    return jsonObj;
120            }
121    
122            public static JSONArray toJSONArray(
123                    com.liferay.portlet.journal.model.JournalArticle[] models) {
124                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
125    
126                    for (JournalArticle model : models) {
127                            jsonArray.put(toJSONObject(model));
128                    }
129    
130                    return jsonArray;
131            }
132    
133            public static JSONArray toJSONArray(
134                    com.liferay.portlet.journal.model.JournalArticle[][] models) {
135                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
136    
137                    for (JournalArticle[] model : models) {
138                            jsonArray.put(toJSONArray(model));
139                    }
140    
141                    return jsonArray;
142            }
143    
144            public static JSONArray toJSONArray(
145                    List<com.liferay.portlet.journal.model.JournalArticle> models) {
146                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
147    
148                    for (JournalArticle model : models) {
149                            jsonArray.put(toJSONObject(model));
150                    }
151    
152                    return jsonArray;
153            }
154    }