001
014
015 package com.liferay.portlet.trash.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.trash.model.TrashEntry;
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 TrashEntryCacheModel implements CacheModel<TrashEntry>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(23);
042
043 sb.append("{entryId=");
044 sb.append(entryId);
045 sb.append(", groupId=");
046 sb.append(groupId);
047 sb.append(", companyId=");
048 sb.append(companyId);
049 sb.append(", userId=");
050 sb.append(userId);
051 sb.append(", userName=");
052 sb.append(userName);
053 sb.append(", createDate=");
054 sb.append(createDate);
055 sb.append(", classNameId=");
056 sb.append(classNameId);
057 sb.append(", classPK=");
058 sb.append(classPK);
059 sb.append(", systemEventSetKey=");
060 sb.append(systemEventSetKey);
061 sb.append(", typeSettings=");
062 sb.append(typeSettings);
063 sb.append(", status=");
064 sb.append(status);
065 sb.append("}");
066
067 return sb.toString();
068 }
069
070 @Override
071 public TrashEntry toEntityModel() {
072 TrashEntryImpl trashEntryImpl = new TrashEntryImpl();
073
074 trashEntryImpl.setEntryId(entryId);
075 trashEntryImpl.setGroupId(groupId);
076 trashEntryImpl.setCompanyId(companyId);
077 trashEntryImpl.setUserId(userId);
078
079 if (userName == null) {
080 trashEntryImpl.setUserName(StringPool.BLANK);
081 }
082 else {
083 trashEntryImpl.setUserName(userName);
084 }
085
086 if (createDate == Long.MIN_VALUE) {
087 trashEntryImpl.setCreateDate(null);
088 }
089 else {
090 trashEntryImpl.setCreateDate(new Date(createDate));
091 }
092
093 trashEntryImpl.setClassNameId(classNameId);
094 trashEntryImpl.setClassPK(classPK);
095 trashEntryImpl.setSystemEventSetKey(systemEventSetKey);
096
097 if (typeSettings == null) {
098 trashEntryImpl.setTypeSettings(StringPool.BLANK);
099 }
100 else {
101 trashEntryImpl.setTypeSettings(typeSettings);
102 }
103
104 trashEntryImpl.setStatus(status);
105
106 trashEntryImpl.resetOriginalValues();
107
108 return trashEntryImpl;
109 }
110
111 @Override
112 public void readExternal(ObjectInput objectInput) throws IOException {
113 entryId = objectInput.readLong();
114 groupId = objectInput.readLong();
115 companyId = objectInput.readLong();
116 userId = objectInput.readLong();
117 userName = objectInput.readUTF();
118 createDate = objectInput.readLong();
119 classNameId = objectInput.readLong();
120 classPK = objectInput.readLong();
121 systemEventSetKey = objectInput.readLong();
122 typeSettings = objectInput.readUTF();
123 status = objectInput.readInt();
124 }
125
126 @Override
127 public void writeExternal(ObjectOutput objectOutput)
128 throws IOException {
129 objectOutput.writeLong(entryId);
130 objectOutput.writeLong(groupId);
131 objectOutput.writeLong(companyId);
132 objectOutput.writeLong(userId);
133
134 if (userName == null) {
135 objectOutput.writeUTF(StringPool.BLANK);
136 }
137 else {
138 objectOutput.writeUTF(userName);
139 }
140
141 objectOutput.writeLong(createDate);
142 objectOutput.writeLong(classNameId);
143 objectOutput.writeLong(classPK);
144 objectOutput.writeLong(systemEventSetKey);
145
146 if (typeSettings == null) {
147 objectOutput.writeUTF(StringPool.BLANK);
148 }
149 else {
150 objectOutput.writeUTF(typeSettings);
151 }
152
153 objectOutput.writeInt(status);
154 }
155
156 public long entryId;
157 public long groupId;
158 public long companyId;
159 public long userId;
160 public String userName;
161 public long createDate;
162 public long classNameId;
163 public long classPK;
164 public long systemEventSetKey;
165 public String typeSettings;
166 public int status;
167 }