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