001
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.ShoppingCategory;
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
037 public class ShoppingCategoryCacheModel implements CacheModel<ShoppingCategory>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(21);
042
043 sb.append("{categoryId=");
044 sb.append(categoryId);
045 sb.append(", groupId=");
046 sb.append(groupId);
047 sb.append(", companyId=");
048 sb.append(companyId);
049 sb.append(", userId=");
050 sb.append(userId);
051 sb.append(", userName=");
052 sb.append(userName);
053 sb.append(", createDate=");
054 sb.append(createDate);
055 sb.append(", modifiedDate=");
056 sb.append(modifiedDate);
057 sb.append(", parentCategoryId=");
058 sb.append(parentCategoryId);
059 sb.append(", name=");
060 sb.append(name);
061 sb.append(", description=");
062 sb.append(description);
063 sb.append("}");
064
065 return sb.toString();
066 }
067
068 public ShoppingCategory toEntityModel() {
069 ShoppingCategoryImpl shoppingCategoryImpl = new ShoppingCategoryImpl();
070
071 shoppingCategoryImpl.setCategoryId(categoryId);
072 shoppingCategoryImpl.setGroupId(groupId);
073 shoppingCategoryImpl.setCompanyId(companyId);
074 shoppingCategoryImpl.setUserId(userId);
075
076 if (userName == null) {
077 shoppingCategoryImpl.setUserName(StringPool.BLANK);
078 }
079 else {
080 shoppingCategoryImpl.setUserName(userName);
081 }
082
083 if (createDate == Long.MIN_VALUE) {
084 shoppingCategoryImpl.setCreateDate(null);
085 }
086 else {
087 shoppingCategoryImpl.setCreateDate(new Date(createDate));
088 }
089
090 if (modifiedDate == Long.MIN_VALUE) {
091 shoppingCategoryImpl.setModifiedDate(null);
092 }
093 else {
094 shoppingCategoryImpl.setModifiedDate(new Date(modifiedDate));
095 }
096
097 shoppingCategoryImpl.setParentCategoryId(parentCategoryId);
098
099 if (name == null) {
100 shoppingCategoryImpl.setName(StringPool.BLANK);
101 }
102 else {
103 shoppingCategoryImpl.setName(name);
104 }
105
106 if (description == null) {
107 shoppingCategoryImpl.setDescription(StringPool.BLANK);
108 }
109 else {
110 shoppingCategoryImpl.setDescription(description);
111 }
112
113 shoppingCategoryImpl.resetOriginalValues();
114
115 return shoppingCategoryImpl;
116 }
117
118 public void readExternal(ObjectInput objectInput) throws IOException {
119 categoryId = objectInput.readLong();
120 groupId = objectInput.readLong();
121 companyId = objectInput.readLong();
122 userId = objectInput.readLong();
123 userName = objectInput.readUTF();
124 createDate = objectInput.readLong();
125 modifiedDate = objectInput.readLong();
126 parentCategoryId = objectInput.readLong();
127 name = objectInput.readUTF();
128 description = objectInput.readUTF();
129 }
130
131 public void writeExternal(ObjectOutput objectOutput)
132 throws IOException {
133 objectOutput.writeLong(categoryId);
134 objectOutput.writeLong(groupId);
135 objectOutput.writeLong(companyId);
136 objectOutput.writeLong(userId);
137
138 if (userName == null) {
139 objectOutput.writeUTF(StringPool.BLANK);
140 }
141 else {
142 objectOutput.writeUTF(userName);
143 }
144
145 objectOutput.writeLong(createDate);
146 objectOutput.writeLong(modifiedDate);
147 objectOutput.writeLong(parentCategoryId);
148
149 if (name == null) {
150 objectOutput.writeUTF(StringPool.BLANK);
151 }
152 else {
153 objectOutput.writeUTF(name);
154 }
155
156 if (description == null) {
157 objectOutput.writeUTF(StringPool.BLANK);
158 }
159 else {
160 objectOutput.writeUTF(description);
161 }
162 }
163
164 public long categoryId;
165 public long groupId;
166 public long companyId;
167 public long userId;
168 public String userName;
169 public long createDate;
170 public long modifiedDate;
171 public long parentCategoryId;
172 public String name;
173 public String description;
174 }