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