001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.journal.service.http;
022:
023: import com.liferay.portlet.journal.model.JournalArticle;
024:
025: import com.liferay.util.JSONUtil;
026:
027: import org.json.JSONArray;
028: import org.json.JSONObject;
029:
030: import java.util.List;
031:
032: /**
033: * <a href="JournalArticleJSONSerializer.java.html"><b><i>View Source</i></b></a>
034: *
035: * <p>
036: * ServiceBuilder generated this class. Modifications in this class will be
037: * overwritten the next time is generated.
038: * </p>
039: *
040: * <p>
041: * This class is used by
042: * <code>com.liferay.portlet.journal.service.http.JournalArticleServiceJSON</code>
043: * to translate objects.
044: * </p>
045: *
046: * @author Brian Wing Shun Chan
047: *
048: * @see com.liferay.portlet.journal.service.http.JournalArticleServiceJSON
049: *
050: */
051: public class JournalArticleJSONSerializer {
052: public static JSONObject toJSONObject(JournalArticle model) {
053: JSONObject jsonObj = new JSONObject();
054:
055: JSONUtil.put(jsonObj, "uuid", model.getUuid());
056: JSONUtil.put(jsonObj, "id", model.getId());
057: JSONUtil.put(jsonObj, "resourcePrimKey", model
058: .getResourcePrimKey());
059: JSONUtil.put(jsonObj, "groupId", model.getGroupId());
060: JSONUtil.put(jsonObj, "companyId", model.getCompanyId());
061: JSONUtil.put(jsonObj, "userId", model.getUserId());
062: JSONUtil.put(jsonObj, "userName", model.getUserName());
063: JSONUtil.put(jsonObj, "createDate", model.getCreateDate());
064: JSONUtil.put(jsonObj, "modifiedDate", model.getModifiedDate());
065: JSONUtil.put(jsonObj, "articleId", model.getArticleId());
066: JSONUtil.put(jsonObj, "version", model.getVersion());
067: JSONUtil.put(jsonObj, "title", model.getTitle());
068: JSONUtil.put(jsonObj, "description", model.getDescription());
069: JSONUtil.put(jsonObj, "content", model.getContent());
070: JSONUtil.put(jsonObj, "type", model.getType());
071: JSONUtil.put(jsonObj, "structureId", model.getStructureId());
072: JSONUtil.put(jsonObj, "templateId", model.getTemplateId());
073: JSONUtil.put(jsonObj, "displayDate", model.getDisplayDate());
074: JSONUtil.put(jsonObj, "approved", model.getApproved());
075: JSONUtil.put(jsonObj, "approvedByUserId", model
076: .getApprovedByUserId());
077: JSONUtil.put(jsonObj, "approvedByUserName", model
078: .getApprovedByUserName());
079: JSONUtil.put(jsonObj, "approvedDate", model.getApprovedDate());
080: JSONUtil.put(jsonObj, "expired", model.getExpired());
081: JSONUtil.put(jsonObj, "expirationDate", model
082: .getExpirationDate());
083: JSONUtil.put(jsonObj, "reviewDate", model.getReviewDate());
084: JSONUtil.put(jsonObj, "indexable", model.getIndexable());
085: JSONUtil.put(jsonObj, "smallImage", model.getSmallImage());
086: JSONUtil.put(jsonObj, "smallImageId", model.getSmallImageId());
087: JSONUtil
088: .put(jsonObj, "smallImageURL", model.getSmallImageURL());
089:
090: return jsonObj;
091: }
092:
093: public static JSONArray toJSONArray(List models) {
094: JSONArray jsonArray = new JSONArray();
095:
096: for (int i = 0; i < models.size(); i++) {
097: JournalArticle model = (JournalArticle) models.get(i);
098:
099: jsonArray.put(toJSONObject(model));
100: }
101:
102: return jsonArray;
103: }
104: }
|