1   /**
2    * Copyright (c) 2000-2008 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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  
31  import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
32  import com.liferay.portlet.softwarecatalog.model.SCProductVersionSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="SCProductVersionModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>SCProductVersion</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.softwarecatalog.service.model.SCProductVersion
60   * @see com.liferay.portlet.softwarecatalog.service.model.SCProductVersionModel
61   * @see com.liferay.portlet.softwarecatalog.service.model.impl.SCProductVersionImpl
62   *
63   */
64  public class SCProductVersionModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "SCProductVersion";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "productVersionId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "userName", new Integer(Types.VARCHAR) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "productEntryId", new Integer(Types.BIGINT) },
86              
87  
88              { "version", new Integer(Types.VARCHAR) },
89              
90  
91              { "changeLog", new Integer(Types.VARCHAR) },
92              
93  
94              { "downloadPageURL", new Integer(Types.VARCHAR) },
95              
96  
97              { "directDownloadURL", new Integer(Types.VARCHAR) },
98              
99  
100             { "repoStoreArtifact", new Integer(Types.BOOLEAN) }
101         };
102     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)";
103     public static final String TABLE_SQL_DROP = "drop table SCProductVersion";
104     public static final String DATA_SOURCE = "liferayDataSource";
105     public static final String SESSION_FACTORY = "liferaySessionFactory";
106     public static final String TX_MANAGER = "liferayTransactionManager";
107     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
108                 "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
109             true);
110 
111     public static SCProductVersion toModel(SCProductVersionSoap soapModel) {
112         SCProductVersion model = new SCProductVersionImpl();
113 
114         model.setProductVersionId(soapModel.getProductVersionId());
115         model.setCompanyId(soapModel.getCompanyId());
116         model.setUserId(soapModel.getUserId());
117         model.setUserName(soapModel.getUserName());
118         model.setCreateDate(soapModel.getCreateDate());
119         model.setModifiedDate(soapModel.getModifiedDate());
120         model.setProductEntryId(soapModel.getProductEntryId());
121         model.setVersion(soapModel.getVersion());
122         model.setChangeLog(soapModel.getChangeLog());
123         model.setDownloadPageURL(soapModel.getDownloadPageURL());
124         model.setDirectDownloadURL(soapModel.getDirectDownloadURL());
125         model.setRepoStoreArtifact(soapModel.getRepoStoreArtifact());
126 
127         return model;
128     }
129 
130     public static List<SCProductVersion> toModels(
131         SCProductVersionSoap[] soapModels) {
132         List<SCProductVersion> models = new ArrayList<SCProductVersion>(soapModels.length);
133 
134         for (SCProductVersionSoap soapModel : soapModels) {
135             models.add(toModel(soapModel));
136         }
137 
138         return models;
139     }
140 
141     public static final boolean CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS = com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS;
142     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
143                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCProductVersion"));
144 
145     public SCProductVersionModelImpl() {
146     }
147 
148     public long getPrimaryKey() {
149         return _productVersionId;
150     }
151 
152     public void setPrimaryKey(long pk) {
153         setProductVersionId(pk);
154     }
155 
156     public Serializable getPrimaryKeyObj() {
157         return new Long(_productVersionId);
158     }
159 
160     public long getProductVersionId() {
161         return _productVersionId;
162     }
163 
164     public void setProductVersionId(long productVersionId) {
165         if (productVersionId != _productVersionId) {
166             _productVersionId = productVersionId;
167         }
168     }
169 
170     public long getCompanyId() {
171         return _companyId;
172     }
173 
174     public void setCompanyId(long companyId) {
175         if (companyId != _companyId) {
176             _companyId = companyId;
177         }
178     }
179 
180     public long getUserId() {
181         return _userId;
182     }
183 
184     public void setUserId(long userId) {
185         if (userId != _userId) {
186             _userId = userId;
187         }
188     }
189 
190     public String getUserName() {
191         return GetterUtil.getString(_userName);
192     }
193 
194     public void setUserName(String userName) {
195         if (((userName == null) && (_userName != null)) ||
196                 ((userName != null) && (_userName == null)) ||
197                 ((userName != null) && (_userName != null) &&
198                 !userName.equals(_userName))) {
199             _userName = userName;
200         }
201     }
202 
203     public Date getCreateDate() {
204         return _createDate;
205     }
206 
207     public void setCreateDate(Date createDate) {
208         if (((createDate == null) && (_createDate != null)) ||
209                 ((createDate != null) && (_createDate == null)) ||
210                 ((createDate != null) && (_createDate != null) &&
211                 !createDate.equals(_createDate))) {
212             _createDate = createDate;
213         }
214     }
215 
216     public Date getModifiedDate() {
217         return _modifiedDate;
218     }
219 
220     public void setModifiedDate(Date modifiedDate) {
221         if (((modifiedDate == null) && (_modifiedDate != null)) ||
222                 ((modifiedDate != null) && (_modifiedDate == null)) ||
223                 ((modifiedDate != null) && (_modifiedDate != null) &&
224                 !modifiedDate.equals(_modifiedDate))) {
225             _modifiedDate = modifiedDate;
226         }
227     }
228 
229     public long getProductEntryId() {
230         return _productEntryId;
231     }
232 
233     public void setProductEntryId(long productEntryId) {
234         if (productEntryId != _productEntryId) {
235             _productEntryId = productEntryId;
236         }
237     }
238 
239     public String getVersion() {
240         return GetterUtil.getString(_version);
241     }
242 
243     public void setVersion(String version) {
244         if (((version == null) && (_version != null)) ||
245                 ((version != null) && (_version == null)) ||
246                 ((version != null) && (_version != null) &&
247                 !version.equals(_version))) {
248             _version = version;
249         }
250     }
251 
252     public String getChangeLog() {
253         return GetterUtil.getString(_changeLog);
254     }
255 
256     public void setChangeLog(String changeLog) {
257         if (((changeLog == null) && (_changeLog != null)) ||
258                 ((changeLog != null) && (_changeLog == null)) ||
259                 ((changeLog != null) && (_changeLog != null) &&
260                 !changeLog.equals(_changeLog))) {
261             _changeLog = changeLog;
262         }
263     }
264 
265     public String getDownloadPageURL() {
266         return GetterUtil.getString(_downloadPageURL);
267     }
268 
269     public void setDownloadPageURL(String downloadPageURL) {
270         if (((downloadPageURL == null) && (_downloadPageURL != null)) ||
271                 ((downloadPageURL != null) && (_downloadPageURL == null)) ||
272                 ((downloadPageURL != null) && (_downloadPageURL != null) &&
273                 !downloadPageURL.equals(_downloadPageURL))) {
274             _downloadPageURL = downloadPageURL;
275         }
276     }
277 
278     public String getDirectDownloadURL() {
279         return GetterUtil.getString(_directDownloadURL);
280     }
281 
282     public void setDirectDownloadURL(String directDownloadURL) {
283         if (((directDownloadURL == null) && (_directDownloadURL != null)) ||
284                 ((directDownloadURL != null) && (_directDownloadURL == null)) ||
285                 ((directDownloadURL != null) && (_directDownloadURL != null) &&
286                 !directDownloadURL.equals(_directDownloadURL))) {
287             _directDownloadURL = directDownloadURL;
288         }
289     }
290 
291     public boolean getRepoStoreArtifact() {
292         return _repoStoreArtifact;
293     }
294 
295     public boolean isRepoStoreArtifact() {
296         return _repoStoreArtifact;
297     }
298 
299     public void setRepoStoreArtifact(boolean repoStoreArtifact) {
300         if (repoStoreArtifact != _repoStoreArtifact) {
301             _repoStoreArtifact = repoStoreArtifact;
302         }
303     }
304 
305     public SCProductVersion toEscapedModel() {
306         if (isEscapedModel()) {
307             return (SCProductVersion)this;
308         }
309         else {
310             SCProductVersion model = new SCProductVersionImpl();
311 
312             model.setEscapedModel(true);
313 
314             model.setProductVersionId(getProductVersionId());
315             model.setCompanyId(getCompanyId());
316             model.setUserId(getUserId());
317             model.setUserName(HtmlUtil.escape(getUserName()));
318             model.setCreateDate(getCreateDate());
319             model.setModifiedDate(getModifiedDate());
320             model.setProductEntryId(getProductEntryId());
321             model.setVersion(HtmlUtil.escape(getVersion()));
322             model.setChangeLog(HtmlUtil.escape(getChangeLog()));
323             model.setDownloadPageURL(HtmlUtil.escape(getDownloadPageURL()));
324             model.setDirectDownloadURL(HtmlUtil.escape(getDirectDownloadURL()));
325             model.setRepoStoreArtifact(getRepoStoreArtifact());
326 
327             model = (SCProductVersion)Proxy.newProxyInstance(SCProductVersion.class.getClassLoader(),
328                     new Class[] { SCProductVersion.class },
329                     new ReadOnlyBeanHandler(model));
330 
331             return model;
332         }
333     }
334 
335     public Object clone() {
336         SCProductVersionImpl clone = new SCProductVersionImpl();
337 
338         clone.setProductVersionId(getProductVersionId());
339         clone.setCompanyId(getCompanyId());
340         clone.setUserId(getUserId());
341         clone.setUserName(getUserName());
342         clone.setCreateDate(getCreateDate());
343         clone.setModifiedDate(getModifiedDate());
344         clone.setProductEntryId(getProductEntryId());
345         clone.setVersion(getVersion());
346         clone.setChangeLog(getChangeLog());
347         clone.setDownloadPageURL(getDownloadPageURL());
348         clone.setDirectDownloadURL(getDirectDownloadURL());
349         clone.setRepoStoreArtifact(getRepoStoreArtifact());
350 
351         return clone;
352     }
353 
354     public int compareTo(Object obj) {
355         if (obj == null) {
356             return -1;
357         }
358 
359         SCProductVersionImpl scProductVersion = (SCProductVersionImpl)obj;
360 
361         int value = 0;
362 
363         value = DateUtil.compareTo(getCreateDate(),
364                 scProductVersion.getCreateDate());
365 
366         value = value * -1;
367 
368         if (value != 0) {
369             return value;
370         }
371 
372         return 0;
373     }
374 
375     public boolean equals(Object obj) {
376         if (obj == null) {
377             return false;
378         }
379 
380         SCProductVersionImpl scProductVersion = null;
381 
382         try {
383             scProductVersion = (SCProductVersionImpl)obj;
384         }
385         catch (ClassCastException cce) {
386             return false;
387         }
388 
389         long pk = scProductVersion.getPrimaryKey();
390 
391         if (getPrimaryKey() == pk) {
392             return true;
393         }
394         else {
395             return false;
396         }
397     }
398 
399     public int hashCode() {
400         return (int)getPrimaryKey();
401     }
402 
403     private long _productVersionId;
404     private long _companyId;
405     private long _userId;
406     private String _userName;
407     private Date _createDate;
408     private Date _modifiedDate;
409     private long _productEntryId;
410     private String _version;
411     private String _changeLog;
412     private String _downloadPageURL;
413     private String _directDownloadURL;
414     private boolean _repoStoreArtifact;
415 }