001
014
015 package com.liferay.portlet.dynamicdatalists.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.dynamicdatalists.model.DDLRecordSet;
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 DDLRecordSetCacheModel implements CacheModel<DDLRecordSet>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(29);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", recordSetId=");
046 sb.append(recordSetId);
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(", DDMStructureId=");
060 sb.append(DDMStructureId);
061 sb.append(", recordSetKey=");
062 sb.append(recordSetKey);
063 sb.append(", name=");
064 sb.append(name);
065 sb.append(", description=");
066 sb.append(description);
067 sb.append(", minDisplayRows=");
068 sb.append(minDisplayRows);
069 sb.append(", scope=");
070 sb.append(scope);
071 sb.append("}");
072
073 return sb.toString();
074 }
075
076 @Override
077 public DDLRecordSet toEntityModel() {
078 DDLRecordSetImpl ddlRecordSetImpl = new DDLRecordSetImpl();
079
080 if (uuid == null) {
081 ddlRecordSetImpl.setUuid(StringPool.BLANK);
082 }
083 else {
084 ddlRecordSetImpl.setUuid(uuid);
085 }
086
087 ddlRecordSetImpl.setRecordSetId(recordSetId);
088 ddlRecordSetImpl.setGroupId(groupId);
089 ddlRecordSetImpl.setCompanyId(companyId);
090 ddlRecordSetImpl.setUserId(userId);
091
092 if (userName == null) {
093 ddlRecordSetImpl.setUserName(StringPool.BLANK);
094 }
095 else {
096 ddlRecordSetImpl.setUserName(userName);
097 }
098
099 if (createDate == Long.MIN_VALUE) {
100 ddlRecordSetImpl.setCreateDate(null);
101 }
102 else {
103 ddlRecordSetImpl.setCreateDate(new Date(createDate));
104 }
105
106 if (modifiedDate == Long.MIN_VALUE) {
107 ddlRecordSetImpl.setModifiedDate(null);
108 }
109 else {
110 ddlRecordSetImpl.setModifiedDate(new Date(modifiedDate));
111 }
112
113 ddlRecordSetImpl.setDDMStructureId(DDMStructureId);
114
115 if (recordSetKey == null) {
116 ddlRecordSetImpl.setRecordSetKey(StringPool.BLANK);
117 }
118 else {
119 ddlRecordSetImpl.setRecordSetKey(recordSetKey);
120 }
121
122 if (name == null) {
123 ddlRecordSetImpl.setName(StringPool.BLANK);
124 }
125 else {
126 ddlRecordSetImpl.setName(name);
127 }
128
129 if (description == null) {
130 ddlRecordSetImpl.setDescription(StringPool.BLANK);
131 }
132 else {
133 ddlRecordSetImpl.setDescription(description);
134 }
135
136 ddlRecordSetImpl.setMinDisplayRows(minDisplayRows);
137 ddlRecordSetImpl.setScope(scope);
138
139 ddlRecordSetImpl.resetOriginalValues();
140
141 return ddlRecordSetImpl;
142 }
143
144 @Override
145 public void readExternal(ObjectInput objectInput) throws IOException {
146 uuid = objectInput.readUTF();
147 recordSetId = objectInput.readLong();
148 groupId = objectInput.readLong();
149 companyId = objectInput.readLong();
150 userId = objectInput.readLong();
151 userName = objectInput.readUTF();
152 createDate = objectInput.readLong();
153 modifiedDate = objectInput.readLong();
154 DDMStructureId = objectInput.readLong();
155 recordSetKey = objectInput.readUTF();
156 name = objectInput.readUTF();
157 description = objectInput.readUTF();
158 minDisplayRows = objectInput.readInt();
159 scope = objectInput.readInt();
160 }
161
162 @Override
163 public void writeExternal(ObjectOutput objectOutput)
164 throws IOException {
165 if (uuid == null) {
166 objectOutput.writeUTF(StringPool.BLANK);
167 }
168 else {
169 objectOutput.writeUTF(uuid);
170 }
171
172 objectOutput.writeLong(recordSetId);
173 objectOutput.writeLong(groupId);
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(DDMStructureId);
187
188 if (recordSetKey == null) {
189 objectOutput.writeUTF(StringPool.BLANK);
190 }
191 else {
192 objectOutput.writeUTF(recordSetKey);
193 }
194
195 if (name == null) {
196 objectOutput.writeUTF(StringPool.BLANK);
197 }
198 else {
199 objectOutput.writeUTF(name);
200 }
201
202 if (description == null) {
203 objectOutput.writeUTF(StringPool.BLANK);
204 }
205 else {
206 objectOutput.writeUTF(description);
207 }
208
209 objectOutput.writeInt(minDisplayRows);
210 objectOutput.writeInt(scope);
211 }
212
213 public String uuid;
214 public long recordSetId;
215 public long groupId;
216 public long companyId;
217 public long userId;
218 public String userName;
219 public long createDate;
220 public long modifiedDate;
221 public long DDMStructureId;
222 public String recordSetKey;
223 public String name;
224 public String description;
225 public int minDisplayRows;
226 public int scope;
227 }