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.softwarecatalog.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.softwarecatalog.model.SCProductEntry;
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 SCProductEntryJSONSerializer {
032            public static JSONObject toJSONObject(SCProductEntry model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("productEntryId", model.getProductEntryId());
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    
051                    Date modifiedDate = model.getModifiedDate();
052    
053                    String modifiedDateJSON = StringPool.BLANK;
054    
055                    if (modifiedDate != null) {
056                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
057                    }
058    
059                    jsonObj.put("modifiedDate", modifiedDateJSON);
060                    jsonObj.put("name", model.getName());
061                    jsonObj.put("type", model.getType());
062                    jsonObj.put("tags", model.getTags());
063                    jsonObj.put("shortDescription", model.getShortDescription());
064                    jsonObj.put("longDescription", model.getLongDescription());
065                    jsonObj.put("pageURL", model.getPageURL());
066                    jsonObj.put("author", model.getAuthor());
067                    jsonObj.put("repoGroupId", model.getRepoGroupId());
068                    jsonObj.put("repoArtifactId", model.getRepoArtifactId());
069    
070                    return jsonObj;
071            }
072    
073            public static JSONArray toJSONArray(
074                    com.liferay.portlet.softwarecatalog.model.SCProductEntry[] models) {
075                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
076    
077                    for (SCProductEntry model : models) {
078                            jsonArray.put(toJSONObject(model));
079                    }
080    
081                    return jsonArray;
082            }
083    
084            public static JSONArray toJSONArray(
085                    com.liferay.portlet.softwarecatalog.model.SCProductEntry[][] models) {
086                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
087    
088                    for (SCProductEntry[] model : models) {
089                            jsonArray.put(toJSONArray(model));
090                    }
091    
092                    return jsonArray;
093            }
094    
095            public static JSONArray toJSONArray(
096                    List<com.liferay.portlet.softwarecatalog.model.SCProductEntry> models) {
097                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
098    
099                    for (SCProductEntry model : models) {
100                            jsonArray.put(toJSONObject(model));
101                    }
102    
103                    return jsonArray;
104            }
105    }