1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.shopping.service.http;
16  
17  import com.liferay.portal.kernel.json.JSONArray;
18  import com.liferay.portal.kernel.json.JSONFactoryUtil;
19  import com.liferay.portal.kernel.json.JSONObject;
20  import com.liferay.portal.kernel.util.StringPool;
21  
22  import com.liferay.portlet.shopping.model.ShoppingOrder;
23  
24  import java.util.Date;
25  import java.util.List;
26  
27  /**
28   * <a href="ShoppingOrderJSONSerializer.java.html"><b><i>View Source</i></b></a>
29   *
30   * <p>
31   * ServiceBuilder generated this class. Modifications in this class will be
32   * overwritten the next time is generated.
33   * </p>
34   *
35   * <p>
36   * This class is used by {@link ShoppingOrderServiceJSON} to translate objects.
37   * </p>
38   *
39   * @author    Brian Wing Shun Chan
40   * @see       com.liferay.portlet.shopping.service.http.ShoppingOrderServiceJSON
41   * @generated
42   */
43  public class ShoppingOrderJSONSerializer {
44      public static JSONObject toJSONObject(ShoppingOrder model) {
45          JSONObject jsonObj = JSONFactoryUtil.createJSONObject();
46  
47          jsonObj.put("orderId", model.getOrderId());
48          jsonObj.put("groupId", model.getGroupId());
49          jsonObj.put("companyId", model.getCompanyId());
50          jsonObj.put("userId", model.getUserId());
51          jsonObj.put("userName", model.getUserName());
52  
53          Date createDate = model.getCreateDate();
54  
55          String createDateJSON = StringPool.BLANK;
56  
57          if (createDate != null) {
58              createDateJSON = String.valueOf(createDate.getTime());
59          }
60  
61          jsonObj.put("createDate", createDateJSON);
62  
63          Date modifiedDate = model.getModifiedDate();
64  
65          String modifiedDateJSON = StringPool.BLANK;
66  
67          if (modifiedDate != null) {
68              modifiedDateJSON = String.valueOf(modifiedDate.getTime());
69          }
70  
71          jsonObj.put("modifiedDate", modifiedDateJSON);
72          jsonObj.put("number", model.getNumber());
73          jsonObj.put("tax", model.getTax());
74          jsonObj.put("shipping", model.getShipping());
75          jsonObj.put("altShipping", model.getAltShipping());
76          jsonObj.put("requiresShipping", model.getRequiresShipping());
77          jsonObj.put("insure", model.getInsure());
78          jsonObj.put("insurance", model.getInsurance());
79          jsonObj.put("couponCodes", model.getCouponCodes());
80          jsonObj.put("couponDiscount", model.getCouponDiscount());
81          jsonObj.put("billingFirstName", model.getBillingFirstName());
82          jsonObj.put("billingLastName", model.getBillingLastName());
83          jsonObj.put("billingEmailAddress", model.getBillingEmailAddress());
84          jsonObj.put("billingCompany", model.getBillingCompany());
85          jsonObj.put("billingStreet", model.getBillingStreet());
86          jsonObj.put("billingCity", model.getBillingCity());
87          jsonObj.put("billingState", model.getBillingState());
88          jsonObj.put("billingZip", model.getBillingZip());
89          jsonObj.put("billingCountry", model.getBillingCountry());
90          jsonObj.put("billingPhone", model.getBillingPhone());
91          jsonObj.put("shipToBilling", model.getShipToBilling());
92          jsonObj.put("shippingFirstName", model.getShippingFirstName());
93          jsonObj.put("shippingLastName", model.getShippingLastName());
94          jsonObj.put("shippingEmailAddress", model.getShippingEmailAddress());
95          jsonObj.put("shippingCompany", model.getShippingCompany());
96          jsonObj.put("shippingStreet", model.getShippingStreet());
97          jsonObj.put("shippingCity", model.getShippingCity());
98          jsonObj.put("shippingState", model.getShippingState());
99          jsonObj.put("shippingZip", model.getShippingZip());
100         jsonObj.put("shippingCountry", model.getShippingCountry());
101         jsonObj.put("shippingPhone", model.getShippingPhone());
102         jsonObj.put("ccName", model.getCcName());
103         jsonObj.put("ccType", model.getCcType());
104         jsonObj.put("ccNumber", model.getCcNumber());
105         jsonObj.put("ccExpMonth", model.getCcExpMonth());
106         jsonObj.put("ccExpYear", model.getCcExpYear());
107         jsonObj.put("ccVerNumber", model.getCcVerNumber());
108         jsonObj.put("comments", model.getComments());
109         jsonObj.put("ppTxnId", model.getPpTxnId());
110         jsonObj.put("ppPaymentStatus", model.getPpPaymentStatus());
111         jsonObj.put("ppPaymentGross", model.getPpPaymentGross());
112         jsonObj.put("ppReceiverEmail", model.getPpReceiverEmail());
113         jsonObj.put("ppPayerEmail", model.getPpPayerEmail());
114         jsonObj.put("sendOrderEmail", model.getSendOrderEmail());
115         jsonObj.put("sendShippingEmail", model.getSendShippingEmail());
116 
117         return jsonObj;
118     }
119 
120     public static JSONArray toJSONArray(
121         com.liferay.portlet.shopping.model.ShoppingOrder[] models) {
122         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
123 
124         for (ShoppingOrder model : models) {
125             jsonArray.put(toJSONObject(model));
126         }
127 
128         return jsonArray;
129     }
130 
131     public static JSONArray toJSONArray(
132         com.liferay.portlet.shopping.model.ShoppingOrder[][] models) {
133         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
134 
135         for (ShoppingOrder[] model : models) {
136             jsonArray.put(toJSONArray(model));
137         }
138 
139         return jsonArray;
140     }
141 
142     public static JSONArray toJSONArray(
143         List<com.liferay.portlet.shopping.model.ShoppingOrder> models) {
144         JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
145 
146         for (ShoppingOrder model : models) {
147             jsonArray.put(toJSONObject(model));
148         }
149 
150         return jsonArray;
151     }
152 }