001    /**
002     * Copyright (c) 2000-2012 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.shopping.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.shopping.model.ShoppingOrderItem;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing ShoppingOrderItem in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see ShoppingOrderItem
035     * @generated
036     */
037    public class ShoppingOrderItemCacheModel implements CacheModel<ShoppingOrderItem>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(21);
042    
043                    sb.append("{orderItemId=");
044                    sb.append(orderItemId);
045                    sb.append(", orderId=");
046                    sb.append(orderId);
047                    sb.append(", itemId=");
048                    sb.append(itemId);
049                    sb.append(", sku=");
050                    sb.append(sku);
051                    sb.append(", name=");
052                    sb.append(name);
053                    sb.append(", description=");
054                    sb.append(description);
055                    sb.append(", properties=");
056                    sb.append(properties);
057                    sb.append(", price=");
058                    sb.append(price);
059                    sb.append(", quantity=");
060                    sb.append(quantity);
061                    sb.append(", shippedDate=");
062                    sb.append(shippedDate);
063                    sb.append("}");
064    
065                    return sb.toString();
066            }
067    
068            public ShoppingOrderItem toEntityModel() {
069                    ShoppingOrderItemImpl shoppingOrderItemImpl = new ShoppingOrderItemImpl();
070    
071                    shoppingOrderItemImpl.setOrderItemId(orderItemId);
072                    shoppingOrderItemImpl.setOrderId(orderId);
073    
074                    if (itemId == null) {
075                            shoppingOrderItemImpl.setItemId(StringPool.BLANK);
076                    }
077                    else {
078                            shoppingOrderItemImpl.setItemId(itemId);
079                    }
080    
081                    if (sku == null) {
082                            shoppingOrderItemImpl.setSku(StringPool.BLANK);
083                    }
084                    else {
085                            shoppingOrderItemImpl.setSku(sku);
086                    }
087    
088                    if (name == null) {
089                            shoppingOrderItemImpl.setName(StringPool.BLANK);
090                    }
091                    else {
092                            shoppingOrderItemImpl.setName(name);
093                    }
094    
095                    if (description == null) {
096                            shoppingOrderItemImpl.setDescription(StringPool.BLANK);
097                    }
098                    else {
099                            shoppingOrderItemImpl.setDescription(description);
100                    }
101    
102                    if (properties == null) {
103                            shoppingOrderItemImpl.setProperties(StringPool.BLANK);
104                    }
105                    else {
106                            shoppingOrderItemImpl.setProperties(properties);
107                    }
108    
109                    shoppingOrderItemImpl.setPrice(price);
110                    shoppingOrderItemImpl.setQuantity(quantity);
111    
112                    if (shippedDate == Long.MIN_VALUE) {
113                            shoppingOrderItemImpl.setShippedDate(null);
114                    }
115                    else {
116                            shoppingOrderItemImpl.setShippedDate(new Date(shippedDate));
117                    }
118    
119                    shoppingOrderItemImpl.resetOriginalValues();
120    
121                    return shoppingOrderItemImpl;
122            }
123    
124            public void readExternal(ObjectInput objectInput) throws IOException {
125                    orderItemId = objectInput.readLong();
126                    orderId = objectInput.readLong();
127                    itemId = objectInput.readUTF();
128                    sku = objectInput.readUTF();
129                    name = objectInput.readUTF();
130                    description = objectInput.readUTF();
131                    properties = objectInput.readUTF();
132                    price = objectInput.readDouble();
133                    quantity = objectInput.readInt();
134                    shippedDate = objectInput.readLong();
135            }
136    
137            public void writeExternal(ObjectOutput objectOutput)
138                    throws IOException {
139                    objectOutput.writeLong(orderItemId);
140                    objectOutput.writeLong(orderId);
141    
142                    if (itemId == null) {
143                            objectOutput.writeUTF(StringPool.BLANK);
144                    }
145                    else {
146                            objectOutput.writeUTF(itemId);
147                    }
148    
149                    if (sku == null) {
150                            objectOutput.writeUTF(StringPool.BLANK);
151                    }
152                    else {
153                            objectOutput.writeUTF(sku);
154                    }
155    
156                    if (name == null) {
157                            objectOutput.writeUTF(StringPool.BLANK);
158                    }
159                    else {
160                            objectOutput.writeUTF(name);
161                    }
162    
163                    if (description == null) {
164                            objectOutput.writeUTF(StringPool.BLANK);
165                    }
166                    else {
167                            objectOutput.writeUTF(description);
168                    }
169    
170                    if (properties == null) {
171                            objectOutput.writeUTF(StringPool.BLANK);
172                    }
173                    else {
174                            objectOutput.writeUTF(properties);
175                    }
176    
177                    objectOutput.writeDouble(price);
178                    objectOutput.writeInt(quantity);
179                    objectOutput.writeLong(shippedDate);
180            }
181    
182            public long orderItemId;
183            public long orderId;
184            public String itemId;
185            public String sku;
186            public String name;
187            public String description;
188            public String properties;
189            public double price;
190            public int quantity;
191            public long shippedDate;
192    }