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.documentlibrary.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.documentlibrary.model.DLFileVersion;
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 DLFileVersionJSONSerializer {
032            public static JSONObject toJSONObject(DLFileVersion model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("fileVersionId", model.getFileVersionId());
036                    jsonObj.put("groupId", model.getGroupId());
037                    jsonObj.put("companyId", model.getCompanyId());
038                    jsonObj.put("userId", model.getUserId());
039                    jsonObj.put("userName", model.getUserName());
040    
041                    Date createDate = model.getCreateDate();
042    
043                    String createDateJSON = StringPool.BLANK;
044    
045                    if (createDate != null) {
046                            createDateJSON = String.valueOf(createDate.getTime());
047                    }
048    
049                    jsonObj.put("createDate", createDateJSON);
050                    jsonObj.put("folderId", model.getFolderId());
051                    jsonObj.put("name", model.getName());
052                    jsonObj.put("extension", model.getExtension());
053                    jsonObj.put("title", model.getTitle());
054                    jsonObj.put("description", model.getDescription());
055                    jsonObj.put("changeLog", model.getChangeLog());
056                    jsonObj.put("extraSettings", model.getExtraSettings());
057                    jsonObj.put("version", model.getVersion());
058                    jsonObj.put("size", model.getSize());
059                    jsonObj.put("status", model.getStatus());
060                    jsonObj.put("statusByUserId", model.getStatusByUserId());
061                    jsonObj.put("statusByUserName", model.getStatusByUserName());
062    
063                    Date statusDate = model.getStatusDate();
064    
065                    String statusDateJSON = StringPool.BLANK;
066    
067                    if (statusDate != null) {
068                            statusDateJSON = String.valueOf(statusDate.getTime());
069                    }
070    
071                    jsonObj.put("statusDate", statusDateJSON);
072    
073                    return jsonObj;
074            }
075    
076            public static JSONArray toJSONArray(
077                    com.liferay.portlet.documentlibrary.model.DLFileVersion[] models) {
078                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
079    
080                    for (DLFileVersion model : models) {
081                            jsonArray.put(toJSONObject(model));
082                    }
083    
084                    return jsonArray;
085            }
086    
087            public static JSONArray toJSONArray(
088                    com.liferay.portlet.documentlibrary.model.DLFileVersion[][] models) {
089                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
090    
091                    for (DLFileVersion[] model : models) {
092                            jsonArray.put(toJSONArray(model));
093                    }
094    
095                    return jsonArray;
096            }
097    
098            public static JSONArray toJSONArray(
099                    List<com.liferay.portlet.documentlibrary.model.DLFileVersion> models) {
100                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
101    
102                    for (DLFileVersion model : models) {
103                            jsonArray.put(toJSONObject(model));
104                    }
105    
106                    return jsonArray;
107            }
108    }