001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.HashUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023
024 import com.liferay.portlet.asset.model.AssetCategory;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031 import java.util.Date;
032
033
040 @ProviderType
041 public class AssetCategoryCacheModel implements CacheModel<AssetCategory>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof AssetCategoryCacheModel)) {
050 return false;
051 }
052
053 AssetCategoryCacheModel assetCategoryCacheModel = (AssetCategoryCacheModel)obj;
054
055 if (categoryId == assetCategoryCacheModel.categoryId) {
056 return true;
057 }
058
059 return false;
060 }
061
062 @Override
063 public int hashCode() {
064 return HashUtil.hash(0, categoryId);
065 }
066
067 @Override
068 public String toString() {
069 StringBundler sb = new StringBundler(33);
070
071 sb.append("{uuid=");
072 sb.append(uuid);
073 sb.append(", categoryId=");
074 sb.append(categoryId);
075 sb.append(", groupId=");
076 sb.append(groupId);
077 sb.append(", companyId=");
078 sb.append(companyId);
079 sb.append(", userId=");
080 sb.append(userId);
081 sb.append(", userName=");
082 sb.append(userName);
083 sb.append(", createDate=");
084 sb.append(createDate);
085 sb.append(", modifiedDate=");
086 sb.append(modifiedDate);
087 sb.append(", parentCategoryId=");
088 sb.append(parentCategoryId);
089 sb.append(", leftCategoryId=");
090 sb.append(leftCategoryId);
091 sb.append(", rightCategoryId=");
092 sb.append(rightCategoryId);
093 sb.append(", name=");
094 sb.append(name);
095 sb.append(", title=");
096 sb.append(title);
097 sb.append(", description=");
098 sb.append(description);
099 sb.append(", vocabularyId=");
100 sb.append(vocabularyId);
101 sb.append(", lastPublishDate=");
102 sb.append(lastPublishDate);
103 sb.append("}");
104
105 return sb.toString();
106 }
107
108 @Override
109 public AssetCategory toEntityModel() {
110 AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
111
112 if (uuid == null) {
113 assetCategoryImpl.setUuid(StringPool.BLANK);
114 }
115 else {
116 assetCategoryImpl.setUuid(uuid);
117 }
118
119 assetCategoryImpl.setCategoryId(categoryId);
120 assetCategoryImpl.setGroupId(groupId);
121 assetCategoryImpl.setCompanyId(companyId);
122 assetCategoryImpl.setUserId(userId);
123
124 if (userName == null) {
125 assetCategoryImpl.setUserName(StringPool.BLANK);
126 }
127 else {
128 assetCategoryImpl.setUserName(userName);
129 }
130
131 if (createDate == Long.MIN_VALUE) {
132 assetCategoryImpl.setCreateDate(null);
133 }
134 else {
135 assetCategoryImpl.setCreateDate(new Date(createDate));
136 }
137
138 if (modifiedDate == Long.MIN_VALUE) {
139 assetCategoryImpl.setModifiedDate(null);
140 }
141 else {
142 assetCategoryImpl.setModifiedDate(new Date(modifiedDate));
143 }
144
145 assetCategoryImpl.setParentCategoryId(parentCategoryId);
146 assetCategoryImpl.setLeftCategoryId(leftCategoryId);
147 assetCategoryImpl.setRightCategoryId(rightCategoryId);
148
149 if (name == null) {
150 assetCategoryImpl.setName(StringPool.BLANK);
151 }
152 else {
153 assetCategoryImpl.setName(name);
154 }
155
156 if (title == null) {
157 assetCategoryImpl.setTitle(StringPool.BLANK);
158 }
159 else {
160 assetCategoryImpl.setTitle(title);
161 }
162
163 if (description == null) {
164 assetCategoryImpl.setDescription(StringPool.BLANK);
165 }
166 else {
167 assetCategoryImpl.setDescription(description);
168 }
169
170 assetCategoryImpl.setVocabularyId(vocabularyId);
171
172 if (lastPublishDate == Long.MIN_VALUE) {
173 assetCategoryImpl.setLastPublishDate(null);
174 }
175 else {
176 assetCategoryImpl.setLastPublishDate(new Date(lastPublishDate));
177 }
178
179 assetCategoryImpl.resetOriginalValues();
180
181 return assetCategoryImpl;
182 }
183
184 @Override
185 public void readExternal(ObjectInput objectInput) throws IOException {
186 uuid = objectInput.readUTF();
187 categoryId = objectInput.readLong();
188 groupId = objectInput.readLong();
189 companyId = objectInput.readLong();
190 userId = objectInput.readLong();
191 userName = objectInput.readUTF();
192 createDate = objectInput.readLong();
193 modifiedDate = objectInput.readLong();
194 parentCategoryId = objectInput.readLong();
195 leftCategoryId = objectInput.readLong();
196 rightCategoryId = objectInput.readLong();
197 name = objectInput.readUTF();
198 title = objectInput.readUTF();
199 description = objectInput.readUTF();
200 vocabularyId = objectInput.readLong();
201 lastPublishDate = objectInput.readLong();
202 }
203
204 @Override
205 public void writeExternal(ObjectOutput objectOutput)
206 throws IOException {
207 if (uuid == null) {
208 objectOutput.writeUTF(StringPool.BLANK);
209 }
210 else {
211 objectOutput.writeUTF(uuid);
212 }
213
214 objectOutput.writeLong(categoryId);
215 objectOutput.writeLong(groupId);
216 objectOutput.writeLong(companyId);
217 objectOutput.writeLong(userId);
218
219 if (userName == null) {
220 objectOutput.writeUTF(StringPool.BLANK);
221 }
222 else {
223 objectOutput.writeUTF(userName);
224 }
225
226 objectOutput.writeLong(createDate);
227 objectOutput.writeLong(modifiedDate);
228 objectOutput.writeLong(parentCategoryId);
229 objectOutput.writeLong(leftCategoryId);
230 objectOutput.writeLong(rightCategoryId);
231
232 if (name == null) {
233 objectOutput.writeUTF(StringPool.BLANK);
234 }
235 else {
236 objectOutput.writeUTF(name);
237 }
238
239 if (title == null) {
240 objectOutput.writeUTF(StringPool.BLANK);
241 }
242 else {
243 objectOutput.writeUTF(title);
244 }
245
246 if (description == null) {
247 objectOutput.writeUTF(StringPool.BLANK);
248 }
249 else {
250 objectOutput.writeUTF(description);
251 }
252
253 objectOutput.writeLong(vocabularyId);
254 objectOutput.writeLong(lastPublishDate);
255 }
256
257 public String uuid;
258 public long categoryId;
259 public long groupId;
260 public long companyId;
261 public long userId;
262 public String userName;
263 public long createDate;
264 public long modifiedDate;
265 public long parentCategoryId;
266 public long leftCategoryId;
267 public long rightCategoryId;
268 public String name;
269 public String title;
270 public String description;
271 public long vocabularyId;
272 public long lastPublishDate;
273 }