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