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.asset.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.asset.model.AssetEntry;
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 AssetEntryJSONSerializer {
032            public static JSONObject toJSONObject(AssetEntry model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("entryId", model.getEntryId());
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("classNameId", model.getClassNameId());
061                    jsonObj.put("classPK", model.getClassPK());
062                    jsonObj.put("classUuid", model.getClassUuid());
063                    jsonObj.put("visible", model.getVisible());
064    
065                    Date startDate = model.getStartDate();
066    
067                    String startDateJSON = StringPool.BLANK;
068    
069                    if (startDate != null) {
070                            startDateJSON = String.valueOf(startDate.getTime());
071                    }
072    
073                    jsonObj.put("startDate", startDateJSON);
074    
075                    Date endDate = model.getEndDate();
076    
077                    String endDateJSON = StringPool.BLANK;
078    
079                    if (endDate != null) {
080                            endDateJSON = String.valueOf(endDate.getTime());
081                    }
082    
083                    jsonObj.put("endDate", endDateJSON);
084    
085                    Date publishDate = model.getPublishDate();
086    
087                    String publishDateJSON = StringPool.BLANK;
088    
089                    if (publishDate != null) {
090                            publishDateJSON = String.valueOf(publishDate.getTime());
091                    }
092    
093                    jsonObj.put("publishDate", publishDateJSON);
094    
095                    Date expirationDate = model.getExpirationDate();
096    
097                    String expirationDateJSON = StringPool.BLANK;
098    
099                    if (expirationDate != null) {
100                            expirationDateJSON = String.valueOf(expirationDate.getTime());
101                    }
102    
103                    jsonObj.put("expirationDate", expirationDateJSON);
104                    jsonObj.put("mimeType", model.getMimeType());
105                    jsonObj.put("title", model.getTitle());
106                    jsonObj.put("description", model.getDescription());
107                    jsonObj.put("summary", model.getSummary());
108                    jsonObj.put("url", model.getUrl());
109                    jsonObj.put("height", model.getHeight());
110                    jsonObj.put("width", model.getWidth());
111                    jsonObj.put("priority", model.getPriority());
112                    jsonObj.put("viewCount", model.getViewCount());
113    
114                    return jsonObj;
115            }
116    
117            public static JSONArray toJSONArray(
118                    com.liferay.portlet.asset.model.AssetEntry[] models) {
119                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
120    
121                    for (AssetEntry model : models) {
122                            jsonArray.put(toJSONObject(model));
123                    }
124    
125                    return jsonArray;
126            }
127    
128            public static JSONArray toJSONArray(
129                    com.liferay.portlet.asset.model.AssetEntry[][] models) {
130                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
131    
132                    for (AssetEntry[] model : models) {
133                            jsonArray.put(toJSONArray(model));
134                    }
135    
136                    return jsonArray;
137            }
138    
139            public static JSONArray toJSONArray(
140                    List<com.liferay.portlet.asset.model.AssetEntry> models) {
141                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
142    
143                    for (AssetEntry model : models) {
144                            jsonArray.put(toJSONObject(model));
145                    }
146    
147                    return jsonArray;
148            }
149    }