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