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.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.AssetCategoryProperty;
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 AssetCategoryPropertyJSONSerializer {
032            public static JSONObject toJSONObject(AssetCategoryProperty model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("categoryPropertyId", model.getCategoryPropertyId());
036                    jsonObj.put("companyId", model.getCompanyId());
037                    jsonObj.put("userId", model.getUserId());
038                    jsonObj.put("userName", model.getUserName());
039    
040                    Date createDate = model.getCreateDate();
041    
042                    String createDateJSON = StringPool.BLANK;
043    
044                    if (createDate != null) {
045                            createDateJSON = String.valueOf(createDate.getTime());
046                    }
047    
048                    jsonObj.put("createDate", createDateJSON);
049    
050                    Date modifiedDate = model.getModifiedDate();
051    
052                    String modifiedDateJSON = StringPool.BLANK;
053    
054                    if (modifiedDate != null) {
055                            modifiedDateJSON = String.valueOf(modifiedDate.getTime());
056                    }
057    
058                    jsonObj.put("modifiedDate", modifiedDateJSON);
059                    jsonObj.put("categoryId", model.getCategoryId());
060                    jsonObj.put("key", model.getKey());
061                    jsonObj.put("value", model.getValue());
062    
063                    return jsonObj;
064            }
065    
066            public static JSONArray toJSONArray(
067                    com.liferay.portlet.asset.model.AssetCategoryProperty[] models) {
068                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
069    
070                    for (AssetCategoryProperty model : models) {
071                            jsonArray.put(toJSONObject(model));
072                    }
073    
074                    return jsonArray;
075            }
076    
077            public static JSONArray toJSONArray(
078                    com.liferay.portlet.asset.model.AssetCategoryProperty[][] models) {
079                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
080    
081                    for (AssetCategoryProperty[] model : models) {
082                            jsonArray.put(toJSONArray(model));
083                    }
084    
085                    return jsonArray;
086            }
087    
088            public static JSONArray toJSONArray(
089                    List<com.liferay.portlet.asset.model.AssetCategoryProperty> models) {
090                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
091    
092                    for (AssetCategoryProperty model : models) {
093                            jsonArray.put(toJSONObject(model));
094                    }
095    
096                    return jsonArray;
097            }
098    }