001
014
015 package com.liferay.portlet.softwarecatalog.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.softwarecatalog.model.SCProductVersion;
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 SCProductVersionCacheModel implements CacheModel<SCProductVersion>,
038 Externalizable {
039 @Override
040 public String toString() {
041 StringBundler sb = new StringBundler(25);
042
043 sb.append("{productVersionId=");
044 sb.append(productVersionId);
045 sb.append(", companyId=");
046 sb.append(companyId);
047 sb.append(", userId=");
048 sb.append(userId);
049 sb.append(", userName=");
050 sb.append(userName);
051 sb.append(", createDate=");
052 sb.append(createDate);
053 sb.append(", modifiedDate=");
054 sb.append(modifiedDate);
055 sb.append(", productEntryId=");
056 sb.append(productEntryId);
057 sb.append(", version=");
058 sb.append(version);
059 sb.append(", changeLog=");
060 sb.append(changeLog);
061 sb.append(", downloadPageURL=");
062 sb.append(downloadPageURL);
063 sb.append(", directDownloadURL=");
064 sb.append(directDownloadURL);
065 sb.append(", repoStoreArtifact=");
066 sb.append(repoStoreArtifact);
067 sb.append("}");
068
069 return sb.toString();
070 }
071
072 @Override
073 public SCProductVersion toEntityModel() {
074 SCProductVersionImpl scProductVersionImpl = new SCProductVersionImpl();
075
076 scProductVersionImpl.setProductVersionId(productVersionId);
077 scProductVersionImpl.setCompanyId(companyId);
078 scProductVersionImpl.setUserId(userId);
079
080 if (userName == null) {
081 scProductVersionImpl.setUserName(StringPool.BLANK);
082 }
083 else {
084 scProductVersionImpl.setUserName(userName);
085 }
086
087 if (createDate == Long.MIN_VALUE) {
088 scProductVersionImpl.setCreateDate(null);
089 }
090 else {
091 scProductVersionImpl.setCreateDate(new Date(createDate));
092 }
093
094 if (modifiedDate == Long.MIN_VALUE) {
095 scProductVersionImpl.setModifiedDate(null);
096 }
097 else {
098 scProductVersionImpl.setModifiedDate(new Date(modifiedDate));
099 }
100
101 scProductVersionImpl.setProductEntryId(productEntryId);
102
103 if (version == null) {
104 scProductVersionImpl.setVersion(StringPool.BLANK);
105 }
106 else {
107 scProductVersionImpl.setVersion(version);
108 }
109
110 if (changeLog == null) {
111 scProductVersionImpl.setChangeLog(StringPool.BLANK);
112 }
113 else {
114 scProductVersionImpl.setChangeLog(changeLog);
115 }
116
117 if (downloadPageURL == null) {
118 scProductVersionImpl.setDownloadPageURL(StringPool.BLANK);
119 }
120 else {
121 scProductVersionImpl.setDownloadPageURL(downloadPageURL);
122 }
123
124 if (directDownloadURL == null) {
125 scProductVersionImpl.setDirectDownloadURL(StringPool.BLANK);
126 }
127 else {
128 scProductVersionImpl.setDirectDownloadURL(directDownloadURL);
129 }
130
131 scProductVersionImpl.setRepoStoreArtifact(repoStoreArtifact);
132
133 scProductVersionImpl.resetOriginalValues();
134
135 return scProductVersionImpl;
136 }
137
138 @Override
139 public void readExternal(ObjectInput objectInput) throws IOException {
140 productVersionId = objectInput.readLong();
141 companyId = objectInput.readLong();
142 userId = objectInput.readLong();
143 userName = objectInput.readUTF();
144 createDate = objectInput.readLong();
145 modifiedDate = objectInput.readLong();
146 productEntryId = objectInput.readLong();
147 version = objectInput.readUTF();
148 changeLog = objectInput.readUTF();
149 downloadPageURL = objectInput.readUTF();
150 directDownloadURL = objectInput.readUTF();
151 repoStoreArtifact = objectInput.readBoolean();
152 }
153
154 @Override
155 public void writeExternal(ObjectOutput objectOutput)
156 throws IOException {
157 objectOutput.writeLong(productVersionId);
158 objectOutput.writeLong(companyId);
159 objectOutput.writeLong(userId);
160
161 if (userName == null) {
162 objectOutput.writeUTF(StringPool.BLANK);
163 }
164 else {
165 objectOutput.writeUTF(userName);
166 }
167
168 objectOutput.writeLong(createDate);
169 objectOutput.writeLong(modifiedDate);
170 objectOutput.writeLong(productEntryId);
171
172 if (version == null) {
173 objectOutput.writeUTF(StringPool.BLANK);
174 }
175 else {
176 objectOutput.writeUTF(version);
177 }
178
179 if (changeLog == null) {
180 objectOutput.writeUTF(StringPool.BLANK);
181 }
182 else {
183 objectOutput.writeUTF(changeLog);
184 }
185
186 if (downloadPageURL == null) {
187 objectOutput.writeUTF(StringPool.BLANK);
188 }
189 else {
190 objectOutput.writeUTF(downloadPageURL);
191 }
192
193 if (directDownloadURL == null) {
194 objectOutput.writeUTF(StringPool.BLANK);
195 }
196 else {
197 objectOutput.writeUTF(directDownloadURL);
198 }
199
200 objectOutput.writeBoolean(repoStoreArtifact);
201 }
202
203 public long productVersionId;
204 public long companyId;
205 public long userId;
206 public String userName;
207 public long createDate;
208 public long modifiedDate;
209 public long productEntryId;
210 public String version;
211 public String changeLog;
212 public String downloadPageURL;
213 public String directDownloadURL;
214 public boolean repoStoreArtifact;
215 }