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 public Role toEntityModel() {
075 RoleImpl roleImpl = new RoleImpl();
076
077 if (uuid == null) {
078 roleImpl.setUuid(StringPool.BLANK);
079 }
080 else {
081 roleImpl.setUuid(uuid);
082 }
083
084 roleImpl.setRoleId(roleId);
085 roleImpl.setCompanyId(companyId);
086 roleImpl.setUserId(userId);
087
088 if (userName == null) {
089 roleImpl.setUserName(StringPool.BLANK);
090 }
091 else {
092 roleImpl.setUserName(userName);
093 }
094
095 if (createDate == Long.MIN_VALUE) {
096 roleImpl.setCreateDate(null);
097 }
098 else {
099 roleImpl.setCreateDate(new Date(createDate));
100 }
101
102 if (modifiedDate == Long.MIN_VALUE) {
103 roleImpl.setModifiedDate(null);
104 }
105 else {
106 roleImpl.setModifiedDate(new Date(modifiedDate));
107 }
108
109 roleImpl.setClassNameId(classNameId);
110 roleImpl.setClassPK(classPK);
111
112 if (name == null) {
113 roleImpl.setName(StringPool.BLANK);
114 }
115 else {
116 roleImpl.setName(name);
117 }
118
119 if (title == null) {
120 roleImpl.setTitle(StringPool.BLANK);
121 }
122 else {
123 roleImpl.setTitle(title);
124 }
125
126 if (description == null) {
127 roleImpl.setDescription(StringPool.BLANK);
128 }
129 else {
130 roleImpl.setDescription(description);
131 }
132
133 roleImpl.setType(type);
134
135 if (subtype == null) {
136 roleImpl.setSubtype(StringPool.BLANK);
137 }
138 else {
139 roleImpl.setSubtype(subtype);
140 }
141
142 roleImpl.resetOriginalValues();
143
144 return roleImpl;
145 }
146
147 public void readExternal(ObjectInput objectInput) throws IOException {
148 uuid = objectInput.readUTF();
149 roleId = objectInput.readLong();
150 companyId = objectInput.readLong();
151 userId = objectInput.readLong();
152 userName = objectInput.readUTF();
153 createDate = objectInput.readLong();
154 modifiedDate = objectInput.readLong();
155 classNameId = objectInput.readLong();
156 classPK = objectInput.readLong();
157 name = objectInput.readUTF();
158 title = objectInput.readUTF();
159 description = objectInput.readUTF();
160 type = objectInput.readInt();
161 subtype = objectInput.readUTF();
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(roleId);
174 objectOutput.writeLong(companyId);
175 objectOutput.writeLong(userId);
176
177 if (userName == null) {
178 objectOutput.writeUTF(StringPool.BLANK);
179 }
180 else {
181 objectOutput.writeUTF(userName);
182 }
183
184 objectOutput.writeLong(createDate);
185 objectOutput.writeLong(modifiedDate);
186 objectOutput.writeLong(classNameId);
187 objectOutput.writeLong(classPK);
188
189 if (name == null) {
190 objectOutput.writeUTF(StringPool.BLANK);
191 }
192 else {
193 objectOutput.writeUTF(name);
194 }
195
196 if (title == null) {
197 objectOutput.writeUTF(StringPool.BLANK);
198 }
199 else {
200 objectOutput.writeUTF(title);
201 }
202
203 if (description == null) {
204 objectOutput.writeUTF(StringPool.BLANK);
205 }
206 else {
207 objectOutput.writeUTF(description);
208 }
209
210 objectOutput.writeInt(type);
211
212 if (subtype == null) {
213 objectOutput.writeUTF(StringPool.BLANK);
214 }
215 else {
216 objectOutput.writeUTF(subtype);
217 }
218 }
219
220 public String uuid;
221 public long roleId;
222 public long companyId;
223 public long userId;
224 public String userName;
225 public long createDate;
226 public long modifiedDate;
227 public long classNameId;
228 public long classPK;
229 public String name;
230 public String title;
231 public String description;
232 public int type;
233 public String subtype;
234 }