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