1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.softwarecatalog.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.DateUtil;
28  import com.liferay.portal.kernel.util.GetterUtil;
29  import com.liferay.portal.kernel.util.HtmlUtil;
30  import com.liferay.portal.model.impl.BaseModelImpl;
31  import com.liferay.portal.service.ServiceContext;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
36  import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
37  import com.liferay.portlet.softwarecatalog.model.SCProductVersionSoap;
38  
39  import java.io.Serializable;
40  
41  import java.lang.reflect.Proxy;
42  
43  import java.sql.Types;
44  
45  import java.util.ArrayList;
46  import java.util.Date;
47  import java.util.List;
48  
49  /**
50   * <a href="SCProductVersionModelImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * <p>
58   * This interface is a model that represents the SCProductVersion table in the
59   * database.
60   * </p>
61   *
62   * @author    Brian Wing Shun Chan
63   * @see       SCProductVersionImpl
64   * @see       com.liferay.portlet.softwarecatalog.model.SCProductVersion
65   * @see       com.liferay.portlet.softwarecatalog.model.SCProductVersionModel
66   * @generated
67   */
68  public class SCProductVersionModelImpl extends BaseModelImpl<SCProductVersion> {
69      public static final String TABLE_NAME = "SCProductVersion";
70      public static final Object[][] TABLE_COLUMNS = {
71              { "productVersionId", new Integer(Types.BIGINT) },
72              { "companyId", new Integer(Types.BIGINT) },
73              { "userId", new Integer(Types.BIGINT) },
74              { "userName", new Integer(Types.VARCHAR) },
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              { "modifiedDate", new Integer(Types.TIMESTAMP) },
77              { "productEntryId", new Integer(Types.BIGINT) },
78              { "version", new Integer(Types.VARCHAR) },
79              { "changeLog", new Integer(Types.VARCHAR) },
80              { "downloadPageURL", new Integer(Types.VARCHAR) },
81              { "directDownloadURL", new Integer(Types.VARCHAR) },
82              { "repoStoreArtifact", new Integer(Types.BOOLEAN) }
83          };
84      public static final String TABLE_SQL_CREATE = "create table SCProductVersion (productVersionId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,productEntryId LONG,version VARCHAR(75) null,changeLog STRING null,downloadPageURL STRING null,directDownloadURL VARCHAR(2000) null,repoStoreArtifact BOOLEAN)";
85      public static final String TABLE_SQL_DROP = "drop table SCProductVersion";
86      public static final String DATA_SOURCE = "liferayDataSource";
87      public static final String SESSION_FACTORY = "liferaySessionFactory";
88      public static final String TX_MANAGER = "liferayTransactionManager";
89      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
91              true);
92      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
94              true);
95  
96      public static SCProductVersion toModel(SCProductVersionSoap soapModel) {
97          SCProductVersion model = new SCProductVersionImpl();
98  
99          model.setProductVersionId(soapModel.getProductVersionId());
100         model.setCompanyId(soapModel.getCompanyId());
101         model.setUserId(soapModel.getUserId());
102         model.setUserName(soapModel.getUserName());
103         model.setCreateDate(soapModel.getCreateDate());
104         model.setModifiedDate(soapModel.getModifiedDate());
105         model.setProductEntryId(soapModel.getProductEntryId());
106         model.setVersion(soapModel.getVersion());
107         model.setChangeLog(soapModel.getChangeLog());
108         model.setDownloadPageURL(soapModel.getDownloadPageURL());
109         model.setDirectDownloadURL(soapModel.getDirectDownloadURL());
110         model.setRepoStoreArtifact(soapModel.getRepoStoreArtifact());
111 
112         return model;
113     }
114 
115     public static List<SCProductVersion> toModels(
116         SCProductVersionSoap[] soapModels) {
117         List<SCProductVersion> models = new ArrayList<SCProductVersion>(soapModels.length);
118 
119         for (SCProductVersionSoap soapModel : soapModels) {
120             models.add(toModel(soapModel));
121         }
122 
123         return models;
124     }
125 
126     public static final boolean FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS =
127         com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS;
128     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCProductVersion"));
130 
131     public SCProductVersionModelImpl() {
132     }
133 
134     public long getPrimaryKey() {
135         return _productVersionId;
136     }
137 
138     public void setPrimaryKey(long pk) {
139         setProductVersionId(pk);
140     }
141 
142     public Serializable getPrimaryKeyObj() {
143         return new Long(_productVersionId);
144     }
145 
146     public long getProductVersionId() {
147         return _productVersionId;
148     }
149 
150     public void setProductVersionId(long productVersionId) {
151         _productVersionId = productVersionId;
152     }
153 
154     public long getCompanyId() {
155         return _companyId;
156     }
157 
158     public void setCompanyId(long companyId) {
159         _companyId = companyId;
160     }
161 
162     public long getUserId() {
163         return _userId;
164     }
165 
166     public void setUserId(long userId) {
167         _userId = userId;
168     }
169 
170     public String getUserUuid() throws SystemException {
171         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
172     }
173 
174     public void setUserUuid(String userUuid) {
175         _userUuid = userUuid;
176     }
177 
178     public String getUserName() {
179         return GetterUtil.getString(_userName);
180     }
181 
182     public void setUserName(String userName) {
183         _userName = userName;
184     }
185 
186     public Date getCreateDate() {
187         return _createDate;
188     }
189 
190     public void setCreateDate(Date createDate) {
191         _createDate = createDate;
192     }
193 
194     public Date getModifiedDate() {
195         return _modifiedDate;
196     }
197 
198     public void setModifiedDate(Date modifiedDate) {
199         _modifiedDate = modifiedDate;
200     }
201 
202     public long getProductEntryId() {
203         return _productEntryId;
204     }
205 
206     public void setProductEntryId(long productEntryId) {
207         _productEntryId = productEntryId;
208     }
209 
210     public String getVersion() {
211         return GetterUtil.getString(_version);
212     }
213 
214     public void setVersion(String version) {
215         _version = version;
216     }
217 
218     public String getChangeLog() {
219         return GetterUtil.getString(_changeLog);
220     }
221 
222     public void setChangeLog(String changeLog) {
223         _changeLog = changeLog;
224     }
225 
226     public String getDownloadPageURL() {
227         return GetterUtil.getString(_downloadPageURL);
228     }
229 
230     public void setDownloadPageURL(String downloadPageURL) {
231         _downloadPageURL = downloadPageURL;
232     }
233 
234     public String getDirectDownloadURL() {
235         return GetterUtil.getString(_directDownloadURL);
236     }
237 
238     public void setDirectDownloadURL(String directDownloadURL) {
239         _directDownloadURL = directDownloadURL;
240 
241         if (_originalDirectDownloadURL == null) {
242             _originalDirectDownloadURL = directDownloadURL;
243         }
244     }
245 
246     public String getOriginalDirectDownloadURL() {
247         return GetterUtil.getString(_originalDirectDownloadURL);
248     }
249 
250     public boolean getRepoStoreArtifact() {
251         return _repoStoreArtifact;
252     }
253 
254     public boolean isRepoStoreArtifact() {
255         return _repoStoreArtifact;
256     }
257 
258     public void setRepoStoreArtifact(boolean repoStoreArtifact) {
259         _repoStoreArtifact = repoStoreArtifact;
260     }
261 
262     public SCProductVersion toEscapedModel() {
263         if (isEscapedModel()) {
264             return (SCProductVersion)this;
265         }
266         else {
267             SCProductVersion model = new SCProductVersionImpl();
268 
269             model.setNew(isNew());
270             model.setEscapedModel(true);
271 
272             model.setProductVersionId(getProductVersionId());
273             model.setCompanyId(getCompanyId());
274             model.setUserId(getUserId());
275             model.setUserName(HtmlUtil.escape(getUserName()));
276             model.setCreateDate(getCreateDate());
277             model.setModifiedDate(getModifiedDate());
278             model.setProductEntryId(getProductEntryId());
279             model.setVersion(HtmlUtil.escape(getVersion()));
280             model.setChangeLog(HtmlUtil.escape(getChangeLog()));
281             model.setDownloadPageURL(HtmlUtil.escape(getDownloadPageURL()));
282             model.setDirectDownloadURL(HtmlUtil.escape(getDirectDownloadURL()));
283             model.setRepoStoreArtifact(getRepoStoreArtifact());
284 
285             model = (SCProductVersion)Proxy.newProxyInstance(SCProductVersion.class.getClassLoader(),
286                     new Class[] { SCProductVersion.class },
287                     new ReadOnlyBeanHandler(model));
288 
289             return model;
290         }
291     }
292 
293     public ExpandoBridge getExpandoBridge() {
294         if (_expandoBridge == null) {
295             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(SCProductVersion.class.getName(),
296                     getPrimaryKey());
297         }
298 
299         return _expandoBridge;
300     }
301 
302     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
303         getExpandoBridge().setAttributes(serviceContext);
304     }
305 
306     public Object clone() {
307         SCProductVersionImpl clone = new SCProductVersionImpl();
308 
309         clone.setProductVersionId(getProductVersionId());
310         clone.setCompanyId(getCompanyId());
311         clone.setUserId(getUserId());
312         clone.setUserName(getUserName());
313         clone.setCreateDate(getCreateDate());
314         clone.setModifiedDate(getModifiedDate());
315         clone.setProductEntryId(getProductEntryId());
316         clone.setVersion(getVersion());
317         clone.setChangeLog(getChangeLog());
318         clone.setDownloadPageURL(getDownloadPageURL());
319         clone.setDirectDownloadURL(getDirectDownloadURL());
320         clone.setRepoStoreArtifact(getRepoStoreArtifact());
321 
322         return clone;
323     }
324 
325     public int compareTo(SCProductVersion scProductVersion) {
326         int value = 0;
327 
328         value = DateUtil.compareTo(getCreateDate(),
329                 scProductVersion.getCreateDate());
330 
331         value = value * -1;
332 
333         if (value != 0) {
334             return value;
335         }
336 
337         return 0;
338     }
339 
340     public boolean equals(Object obj) {
341         if (obj == null) {
342             return false;
343         }
344 
345         SCProductVersion scProductVersion = null;
346 
347         try {
348             scProductVersion = (SCProductVersion)obj;
349         }
350         catch (ClassCastException cce) {
351             return false;
352         }
353 
354         long pk = scProductVersion.getPrimaryKey();
355 
356         if (getPrimaryKey() == pk) {
357             return true;
358         }
359         else {
360             return false;
361         }
362     }
363 
364     public int hashCode() {
365         return (int)getPrimaryKey();
366     }
367 
368     public String toString() {
369         StringBuilder sb = new StringBuilder();
370 
371         sb.append("{productVersionId=");
372         sb.append(getProductVersionId());
373         sb.append(", companyId=");
374         sb.append(getCompanyId());
375         sb.append(", userId=");
376         sb.append(getUserId());
377         sb.append(", userName=");
378         sb.append(getUserName());
379         sb.append(", createDate=");
380         sb.append(getCreateDate());
381         sb.append(", modifiedDate=");
382         sb.append(getModifiedDate());
383         sb.append(", productEntryId=");
384         sb.append(getProductEntryId());
385         sb.append(", version=");
386         sb.append(getVersion());
387         sb.append(", changeLog=");
388         sb.append(getChangeLog());
389         sb.append(", downloadPageURL=");
390         sb.append(getDownloadPageURL());
391         sb.append(", directDownloadURL=");
392         sb.append(getDirectDownloadURL());
393         sb.append(", repoStoreArtifact=");
394         sb.append(getRepoStoreArtifact());
395         sb.append("}");
396 
397         return sb.toString();
398     }
399 
400     public String toXmlString() {
401         StringBuilder sb = new StringBuilder();
402 
403         sb.append("<model><model-name>");
404         sb.append("com.liferay.portlet.softwarecatalog.model.SCProductVersion");
405         sb.append("</model-name>");
406 
407         sb.append(
408             "<column><column-name>productVersionId</column-name><column-value><![CDATA[");
409         sb.append(getProductVersionId());
410         sb.append("]]></column-value></column>");
411         sb.append(
412             "<column><column-name>companyId</column-name><column-value><![CDATA[");
413         sb.append(getCompanyId());
414         sb.append("]]></column-value></column>");
415         sb.append(
416             "<column><column-name>userId</column-name><column-value><![CDATA[");
417         sb.append(getUserId());
418         sb.append("]]></column-value></column>");
419         sb.append(
420             "<column><column-name>userName</column-name><column-value><![CDATA[");
421         sb.append(getUserName());
422         sb.append("]]></column-value></column>");
423         sb.append(
424             "<column><column-name>createDate</column-name><column-value><![CDATA[");
425         sb.append(getCreateDate());
426         sb.append("]]></column-value></column>");
427         sb.append(
428             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
429         sb.append(getModifiedDate());
430         sb.append("]]></column-value></column>");
431         sb.append(
432             "<column><column-name>productEntryId</column-name><column-value><![CDATA[");
433         sb.append(getProductEntryId());
434         sb.append("]]></column-value></column>");
435         sb.append(
436             "<column><column-name>version</column-name><column-value><![CDATA[");
437         sb.append(getVersion());
438         sb.append("]]></column-value></column>");
439         sb.append(
440             "<column><column-name>changeLog</column-name><column-value><![CDATA[");
441         sb.append(getChangeLog());
442         sb.append("]]></column-value></column>");
443         sb.append(
444             "<column><column-name>downloadPageURL</column-name><column-value><![CDATA[");
445         sb.append(getDownloadPageURL());
446         sb.append("]]></column-value></column>");
447         sb.append(
448             "<column><column-name>directDownloadURL</column-name><column-value><![CDATA[");
449         sb.append(getDirectDownloadURL());
450         sb.append("]]></column-value></column>");
451         sb.append(
452             "<column><column-name>repoStoreArtifact</column-name><column-value><![CDATA[");
453         sb.append(getRepoStoreArtifact());
454         sb.append("]]></column-value></column>");
455 
456         sb.append("</model>");
457 
458         return sb.toString();
459     }
460 
461     private long _productVersionId;
462     private long _companyId;
463     private long _userId;
464     private String _userUuid;
465     private String _userName;
466     private Date _createDate;
467     private Date _modifiedDate;
468     private long _productEntryId;
469     private String _version;
470     private String _changeLog;
471     private String _downloadPageURL;
472     private String _directDownloadURL;
473     private String _originalDirectDownloadURL;
474     private boolean _repoStoreArtifact;
475     private transient ExpandoBridge _expandoBridge;
476 }