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.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.SCFrameworkVersion;
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 SCFrameworkVersionJSONSerializer {
032            public static JSONObject toJSONObject(SCFrameworkVersion model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("frameworkVersionId", model.getFrameworkVersionId());
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("url", model.getUrl());
062                    jsonObj.put("active", model.getActive());
063                    jsonObj.put("priority", model.getPriority());
064    
065                    return jsonObj;
066            }
067    
068            public static JSONArray toJSONArray(
069                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion[] models) {
070                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
071    
072                    for (SCFrameworkVersion model : models) {
073                            jsonArray.put(toJSONObject(model));
074                    }
075    
076                    return jsonArray;
077            }
078    
079            public static JSONArray toJSONArray(
080                    com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion[][] models) {
081                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
082    
083                    for (SCFrameworkVersion[] model : models) {
084                            jsonArray.put(toJSONArray(model));
085                    }
086    
087                    return jsonArray;
088            }
089    
090            public static JSONArray toJSONArray(
091                    List<com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion> models) {
092                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
093    
094                    for (SCFrameworkVersion model : models) {
095                            jsonArray.put(toJSONObject(model));
096                    }
097    
098                    return jsonArray;
099            }
100    }