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.journal.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.journal.model.JournalStructure;
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 JournalStructureJSONSerializer {
032            public static JSONObject toJSONObject(JournalStructure model) {
033                    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
034    
035                    jsonObj.put("uuid", model.getUuid());
036                    jsonObj.put("id", model.getId());
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("structureId", model.getStructureId());
062                    jsonObj.put("parentStructureId", model.getParentStructureId());
063                    jsonObj.put("name", model.getName());
064                    jsonObj.put("description", model.getDescription());
065                    jsonObj.put("xsd", model.getXsd());
066    
067                    return jsonObj;
068            }
069    
070            public static JSONArray toJSONArray(
071                    com.liferay.portlet.journal.model.JournalStructure[] models) {
072                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
073    
074                    for (JournalStructure model : models) {
075                            jsonArray.put(toJSONObject(model));
076                    }
077    
078                    return jsonArray;
079            }
080    
081            public static JSONArray toJSONArray(
082                    com.liferay.portlet.journal.model.JournalStructure[][] models) {
083                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
084    
085                    for (JournalStructure[] model : models) {
086                            jsonArray.put(toJSONArray(model));
087                    }
088    
089                    return jsonArray;
090            }
091    
092            public static JSONArray toJSONArray(
093                    List<com.liferay.portlet.journal.model.JournalStructure> models) {
094                    JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
095    
096                    for (JournalStructure model : models) {
097                            jsonArray.put(toJSONObject(model));
098                    }
099    
100                    return jsonArray;
101            }
102    }