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.portlet.wiki.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.wiki.model.WikiNode;
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 WikiNodeJSONSerializer {
032            public static JSONObject toJSONObject(WikiNode model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("nodeId", model.getNodeId());
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("name", model.getName());
062                    jsonObj.put("description", model.getDescription());
063    
064                    Date lastPostDate = model.getLastPostDate();
065    
066                    String lastPostDateJSON = StringPool.BLANK;
067    
068                    if (lastPostDate != null) {
069                            lastPostDateJSON = String.valueOf(lastPostDate.getTime());
070                    }
071    
072                    jsonObj.put("lastPostDate", lastPostDateJSON);
073    
074                    return jsonObj;
075            }
076    
077            public static JSONArray toJSONArray(
078                    com.liferay.portlet.wiki.model.WikiNode[] models) {
079                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
080    
081                    for (WikiNode model : models) {
082                            jsonArray.put(toJSONObject(model));
083                    }
084    
085                    return jsonArray;
086            }
087    
088            public static JSONArray toJSONArray(
089                    com.liferay.portlet.wiki.model.WikiNode[][] models) {
090                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
091    
092                    for (WikiNode[] model : models) {
093                            jsonArray.put(toJSONArray(model));
094                    }
095    
096                    return jsonArray;
097            }
098    
099            public static JSONArray toJSONArray(
100                    List<com.liferay.portlet.wiki.model.WikiNode> models) {
101                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
102    
103                    for (WikiNode model : models) {
104                            jsonArray.put(toJSONObject(model));
105                    }
106    
107                    return jsonArray;
108            }
109    }