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.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.model.SCProductVersion
60   * @see com.liferay.portlet.softwarecatalog.model.SCProductVersionModel
61   * @see com.liferay.portlet.softwarecatalog.model.impl.SCProductVersionImpl
62   *
63   */
64  public class SCProductVersionModelImpl extends BaseModelImpl<SCProductVersion> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
108                 "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
109             true);
110     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
111                 "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
112             true);
113 
114     public static SCProductVersion toModel(SCProductVersionSoap soapModel) {
115         SCProductVersion model = new SCProductVersionImpl();
116 
117         model.setProductVersionId(soapModel.getProductVersionId());
118         model.setCompanyId(soapModel.getCompanyId());
119         model.setUserId(soapModel.getUserId());
120         model.setUserName(soapModel.getUserName());
121         model.setCreateDate(soapModel.getCreateDate());
122         model.setModifiedDate(soapModel.getModifiedDate());
123         model.setProductEntryId(soapModel.getProductEntryId());
124         model.setVersion(soapModel.getVersion());
125         model.setChangeLog(soapModel.getChangeLog());
126         model.setDownloadPageURL(soapModel.getDownloadPageURL());
127         model.setDirectDownloadURL(soapModel.getDirectDownloadURL());
128         model.setRepoStoreArtifact(soapModel.getRepoStoreArtifact());
129 
130         return model;
131     }
132 
133     public static List<SCProductVersion> toModels(
134         SCProductVersionSoap[] soapModels) {
135         List<SCProductVersion> models = new ArrayList<SCProductVersion>(soapModels.length);
136 
137         for (SCProductVersionSoap soapModel : soapModels) {
138             models.add(toModel(soapModel));
139         }
140 
141         return models;
142     }
143 
144     public static final boolean FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS =
145         com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS;
146     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
147                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCProductVersion"));
148 
149     public SCProductVersionModelImpl() {
150     }
151 
152     public long getPrimaryKey() {
153         return _productVersionId;
154     }
155 
156     public void setPrimaryKey(long pk) {
157         setProductVersionId(pk);
158     }
159 
160     public Serializable getPrimaryKeyObj() {
161         return new Long(_productVersionId);
162     }
163 
164     public long getProductVersionId() {
165         return _productVersionId;
166     }
167 
168     public void setProductVersionId(long productVersionId) {
169         _productVersionId = productVersionId;
170     }
171 
172     public long getCompanyId() {
173         return _companyId;
174     }
175 
176     public void setCompanyId(long companyId) {
177         _companyId = companyId;
178     }
179 
180     public long getUserId() {
181         return _userId;
182     }
183 
184     public void setUserId(long userId) {
185         _userId = userId;
186     }
187 
188     public String getUserName() {
189         return GetterUtil.getString(_userName);
190     }
191 
192     public void setUserName(String userName) {
193         _userName = userName;
194     }
195 
196     public Date getCreateDate() {
197         return _createDate;
198     }
199 
200     public void setCreateDate(Date createDate) {
201         _createDate = createDate;
202     }
203 
204     public Date getModifiedDate() {
205         return _modifiedDate;
206     }
207 
208     public void setModifiedDate(Date modifiedDate) {
209         _modifiedDate = modifiedDate;
210     }
211 
212     public long getProductEntryId() {
213         return _productEntryId;
214     }
215 
216     public void setProductEntryId(long productEntryId) {
217         _productEntryId = productEntryId;
218     }
219 
220     public String getVersion() {
221         return GetterUtil.getString(_version);
222     }
223 
224     public void setVersion(String version) {
225         _version = version;
226     }
227 
228     public String getChangeLog() {
229         return GetterUtil.getString(_changeLog);
230     }
231 
232     public void setChangeLog(String changeLog) {
233         _changeLog = changeLog;
234     }
235 
236     public String getDownloadPageURL() {
237         return GetterUtil.getString(_downloadPageURL);
238     }
239 
240     public void setDownloadPageURL(String downloadPageURL) {
241         _downloadPageURL = downloadPageURL;
242     }
243 
244     public String getDirectDownloadURL() {
245         return GetterUtil.getString(_directDownloadURL);
246     }
247 
248     public void setDirectDownloadURL(String directDownloadURL) {
249         _directDownloadURL = directDownloadURL;
250 
251         if (_originalDirectDownloadURL == null) {
252             _originalDirectDownloadURL = directDownloadURL;
253         }
254     }
255 
256     public String getOriginalDirectDownloadURL() {
257         return GetterUtil.getString(_originalDirectDownloadURL);
258     }
259 
260     public boolean getRepoStoreArtifact() {
261         return _repoStoreArtifact;
262     }
263 
264     public boolean isRepoStoreArtifact() {
265         return _repoStoreArtifact;
266     }
267 
268     public void setRepoStoreArtifact(boolean repoStoreArtifact) {
269         _repoStoreArtifact = repoStoreArtifact;
270     }
271 
272     public SCProductVersion toEscapedModel() {
273         if (isEscapedModel()) {
274             return (SCProductVersion)this;
275         }
276         else {
277             SCProductVersion model = new SCProductVersionImpl();
278 
279             model.setNew(isNew());
280             model.setEscapedModel(true);
281 
282             model.setProductVersionId(getProductVersionId());
283             model.setCompanyId(getCompanyId());
284             model.setUserId(getUserId());
285             model.setUserName(HtmlUtil.escape(getUserName()));
286             model.setCreateDate(getCreateDate());
287             model.setModifiedDate(getModifiedDate());
288             model.setProductEntryId(getProductEntryId());
289             model.setVersion(HtmlUtil.escape(getVersion()));
290             model.setChangeLog(HtmlUtil.escape(getChangeLog()));
291             model.setDownloadPageURL(HtmlUtil.escape(getDownloadPageURL()));
292             model.setDirectDownloadURL(HtmlUtil.escape(getDirectDownloadURL()));
293             model.setRepoStoreArtifact(getRepoStoreArtifact());
294 
295             model = (SCProductVersion)Proxy.newProxyInstance(SCProductVersion.class.getClassLoader(),
296                     new Class[] { SCProductVersion.class },
297                     new ReadOnlyBeanHandler(model));
298 
299             return model;
300         }
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         StringBuilder sb = new StringBuilder();
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         StringBuilder sb = new StringBuilder();
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 _userName;
462     private Date _createDate;
463     private Date _modifiedDate;
464     private long _productEntryId;
465     private String _version;
466     private String _changeLog;
467     private String _downloadPageURL;
468     private String _directDownloadURL;
469     private String _originalDirectDownloadURL;
470     private boolean _repoStoreArtifact;
471 }