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.JournalFeed;
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 JournalFeedJSONSerializer {
032            public static JSONObject toJSONObject(JournalFeed model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("id", model.getId());
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("feedId", model.getFeedId());
062                    jsonObj.put("name", model.getName());
063                    jsonObj.put("description", model.getDescription());
064                    jsonObj.put("type", model.getType());
065                    jsonObj.put("structureId", model.getStructureId());
066                    jsonObj.put("templateId", model.getTemplateId());
067                    jsonObj.put("rendererTemplateId", model.getRendererTemplateId());
068                    jsonObj.put("delta", model.getDelta());
069                    jsonObj.put("orderByCol", model.getOrderByCol());
070                    jsonObj.put("orderByType", model.getOrderByType());
071                    jsonObj.put("targetLayoutFriendlyUrl",
072                            model.getTargetLayoutFriendlyUrl());
073                    jsonObj.put("targetPortletId", model.getTargetPortletId());
074                    jsonObj.put("contentField", model.getContentField());
075                    jsonObj.put("feedType", model.getFeedType());
076                    jsonObj.put("feedVersion", model.getFeedVersion());
077    
078                    return jsonObj;
079            }
080    
081            public static JSONArray toJSONArray(
082                    com.liferay.portlet.journal.model.JournalFeed[] models) {
083                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
084    
085                    for (JournalFeed model : models) {
086                            jsonArray.put(toJSONObject(model));
087                    }
088    
089                    return jsonArray;
090            }
091    
092            public static JSONArray toJSONArray(
093                    com.liferay.portlet.journal.model.JournalFeed[][] models) {
094                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
095    
096                    for (JournalFeed[] model : models) {
097                            jsonArray.put(toJSONArray(model));
098                    }
099    
100                    return jsonArray;
101            }
102    
103            public static JSONArray toJSONArray(
104                    List<com.liferay.portlet.journal.model.JournalFeed> models) {
105                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
106    
107                    for (JournalFeed model : models) {
108                            jsonArray.put(toJSONObject(model));
109                    }
110    
111                    return jsonArray;
112            }
113    }