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