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