001
014
015 package com.liferay.portlet.dynamicdatamapping.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.dynamicdatamapping.model.DDMContent;
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 DDMContentCacheModel implements CacheModel<DDMContent>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(23);
042
043 sb.append("{uuid=");
044 sb.append(uuid);
045 sb.append(", contentId=");
046 sb.append(contentId);
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(", name=");
060 sb.append(name);
061 sb.append(", description=");
062 sb.append(description);
063 sb.append(", xml=");
064 sb.append(xml);
065 sb.append("}");
066
067 return sb.toString();
068 }
069
070 @Override
071 public DDMContent toEntityModel() {
072 DDMContentImpl ddmContentImpl = new DDMContentImpl();
073
074 if (uuid == null) {
075 ddmContentImpl.setUuid(StringPool.BLANK);
076 }
077 else {
078 ddmContentImpl.setUuid(uuid);
079 }
080
081 ddmContentImpl.setContentId(contentId);
082 ddmContentImpl.setGroupId(groupId);
083 ddmContentImpl.setCompanyId(companyId);
084 ddmContentImpl.setUserId(userId);
085
086 if (userName == null) {
087 ddmContentImpl.setUserName(StringPool.BLANK);
088 }
089 else {
090 ddmContentImpl.setUserName(userName);
091 }
092
093 if (createDate == Long.MIN_VALUE) {
094 ddmContentImpl.setCreateDate(null);
095 }
096 else {
097 ddmContentImpl.setCreateDate(new Date(createDate));
098 }
099
100 if (modifiedDate == Long.MIN_VALUE) {
101 ddmContentImpl.setModifiedDate(null);
102 }
103 else {
104 ddmContentImpl.setModifiedDate(new Date(modifiedDate));
105 }
106
107 if (name == null) {
108 ddmContentImpl.setName(StringPool.BLANK);
109 }
110 else {
111 ddmContentImpl.setName(name);
112 }
113
114 if (description == null) {
115 ddmContentImpl.setDescription(StringPool.BLANK);
116 }
117 else {
118 ddmContentImpl.setDescription(description);
119 }
120
121 if (xml == null) {
122 ddmContentImpl.setXml(StringPool.BLANK);
123 }
124 else {
125 ddmContentImpl.setXml(xml);
126 }
127
128 ddmContentImpl.resetOriginalValues();
129
130 return ddmContentImpl;
131 }
132
133 @Override
134 public void readExternal(ObjectInput objectInput) throws IOException {
135 uuid = objectInput.readUTF();
136 contentId = objectInput.readLong();
137 groupId = objectInput.readLong();
138 companyId = objectInput.readLong();
139 userId = objectInput.readLong();
140 userName = objectInput.readUTF();
141 createDate = objectInput.readLong();
142 modifiedDate = objectInput.readLong();
143 name = objectInput.readUTF();
144 description = objectInput.readUTF();
145 xml = objectInput.readUTF();
146 }
147
148 @Override
149 public void writeExternal(ObjectOutput objectOutput)
150 throws IOException {
151 if (uuid == null) {
152 objectOutput.writeUTF(StringPool.BLANK);
153 }
154 else {
155 objectOutput.writeUTF(uuid);
156 }
157
158 objectOutput.writeLong(contentId);
159 objectOutput.writeLong(groupId);
160 objectOutput.writeLong(companyId);
161 objectOutput.writeLong(userId);
162
163 if (userName == null) {
164 objectOutput.writeUTF(StringPool.BLANK);
165 }
166 else {
167 objectOutput.writeUTF(userName);
168 }
169
170 objectOutput.writeLong(createDate);
171 objectOutput.writeLong(modifiedDate);
172
173 if (name == null) {
174 objectOutput.writeUTF(StringPool.BLANK);
175 }
176 else {
177 objectOutput.writeUTF(name);
178 }
179
180 if (description == null) {
181 objectOutput.writeUTF(StringPool.BLANK);
182 }
183 else {
184 objectOutput.writeUTF(description);
185 }
186
187 if (xml == null) {
188 objectOutput.writeUTF(StringPool.BLANK);
189 }
190 else {
191 objectOutput.writeUTF(xml);
192 }
193 }
194
195 public String uuid;
196 public long contentId;
197 public long groupId;
198 public long companyId;
199 public long userId;
200 public String userName;
201 public long createDate;
202 public long modifiedDate;
203 public String name;
204 public String description;
205 public String xml;
206 }