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