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