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