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<SCProductVersion> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
110                 "value.object.entity.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
111             true);
112     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
113                 "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductVersion"),
114             true);
115 
116     public static SCProductVersion toModel(SCProductVersionSoap soapModel) {
117         SCProductVersion model = new SCProductVersionImpl();
118 
119         model.setProductVersionId(soapModel.getProductVersionId());
120         model.setCompanyId(soapModel.getCompanyId());
121         model.setUserId(soapModel.getUserId());
122         model.setUserName(soapModel.getUserName());
123         model.setCreateDate(soapModel.getCreateDate());
124         model.setModifiedDate(soapModel.getModifiedDate());
125         model.setProductEntryId(soapModel.getProductEntryId());
126         model.setVersion(soapModel.getVersion());
127         model.setChangeLog(soapModel.getChangeLog());
128         model.setDownloadPageURL(soapModel.getDownloadPageURL());
129         model.setDirectDownloadURL(soapModel.getDirectDownloadURL());
130         model.setRepoStoreArtifact(soapModel.getRepoStoreArtifact());
131 
132         return model;
133     }
134 
135     public static List<SCProductVersion> toModels(
136         SCProductVersionSoap[] soapModels) {
137         List<SCProductVersion> models = new ArrayList<SCProductVersion>(soapModels.length);
138 
139         for (SCProductVersionSoap soapModel : soapModels) {
140             models.add(toModel(soapModel));
141         }
142 
143         return models;
144     }
145 
146     public static final boolean FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS =
147         com.liferay.portlet.softwarecatalog.model.impl.SCFrameworkVersionModelImpl.FINDER_CACHE_ENABLED_SCFRAMEWORKVERSI_SCPRODUCTVERS;
148     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
149                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCProductVersion"));
150 
151     public SCProductVersionModelImpl() {
152     }
153 
154     public long getPrimaryKey() {
155         return _productVersionId;
156     }
157 
158     public void setPrimaryKey(long pk) {
159         setProductVersionId(pk);
160     }
161 
162     public Serializable getPrimaryKeyObj() {
163         return new Long(_productVersionId);
164     }
165 
166     public long getProductVersionId() {
167         return _productVersionId;
168     }
169 
170     public void setProductVersionId(long productVersionId) {
171         _productVersionId = productVersionId;
172     }
173 
174     public long getCompanyId() {
175         return _companyId;
176     }
177 
178     public void setCompanyId(long companyId) {
179         _companyId = companyId;
180     }
181 
182     public long getUserId() {
183         return _userId;
184     }
185 
186     public void setUserId(long userId) {
187         _userId = userId;
188     }
189 
190     public String getUserName() {
191         return GetterUtil.getString(_userName);
192     }
193 
194     public void setUserName(String userName) {
195         _userName = userName;
196     }
197 
198     public Date getCreateDate() {
199         return _createDate;
200     }
201 
202     public void setCreateDate(Date createDate) {
203         _createDate = createDate;
204     }
205 
206     public Date getModifiedDate() {
207         return _modifiedDate;
208     }
209 
210     public void setModifiedDate(Date modifiedDate) {
211         _modifiedDate = modifiedDate;
212     }
213 
214     public long getProductEntryId() {
215         return _productEntryId;
216     }
217 
218     public void setProductEntryId(long productEntryId) {
219         _productEntryId = productEntryId;
220     }
221 
222     public String getVersion() {
223         return GetterUtil.getString(_version);
224     }
225 
226     public void setVersion(String version) {
227         _version = version;
228     }
229 
230     public String getChangeLog() {
231         return GetterUtil.getString(_changeLog);
232     }
233 
234     public void setChangeLog(String changeLog) {
235         _changeLog = changeLog;
236     }
237 
238     public String getDownloadPageURL() {
239         return GetterUtil.getString(_downloadPageURL);
240     }
241 
242     public void setDownloadPageURL(String downloadPageURL) {
243         _downloadPageURL = downloadPageURL;
244     }
245 
246     public String getDirectDownloadURL() {
247         return GetterUtil.getString(_directDownloadURL);
248     }
249 
250     public void setDirectDownloadURL(String directDownloadURL) {
251         _directDownloadURL = directDownloadURL;
252 
253         if (_originalDirectDownloadURL == null) {
254             _originalDirectDownloadURL = directDownloadURL;
255         }
256     }
257 
258     public String getOriginalDirectDownloadURL() {
259         return GetterUtil.getString(_originalDirectDownloadURL);
260     }
261 
262     public boolean getRepoStoreArtifact() {
263         return _repoStoreArtifact;
264     }
265 
266     public boolean isRepoStoreArtifact() {
267         return _repoStoreArtifact;
268     }
269 
270     public void setRepoStoreArtifact(boolean repoStoreArtifact) {
271         _repoStoreArtifact = repoStoreArtifact;
272     }
273 
274     public SCProductVersion toEscapedModel() {
275         if (isEscapedModel()) {
276             return (SCProductVersion)this;
277         }
278         else {
279             SCProductVersion model = new SCProductVersionImpl();
280 
281             model.setNew(isNew());
282             model.setEscapedModel(true);
283 
284             model.setProductVersionId(getProductVersionId());
285             model.setCompanyId(getCompanyId());
286             model.setUserId(getUserId());
287             model.setUserName(HtmlUtil.escape(getUserName()));
288             model.setCreateDate(getCreateDate());
289             model.setModifiedDate(getModifiedDate());
290             model.setProductEntryId(getProductEntryId());
291             model.setVersion(HtmlUtil.escape(getVersion()));
292             model.setChangeLog(HtmlUtil.escape(getChangeLog()));
293             model.setDownloadPageURL(HtmlUtil.escape(getDownloadPageURL()));
294             model.setDirectDownloadURL(HtmlUtil.escape(getDirectDownloadURL()));
295             model.setRepoStoreArtifact(getRepoStoreArtifact());
296 
297             model = (SCProductVersion)Proxy.newProxyInstance(SCProductVersion.class.getClassLoader(),
298                     new Class[] { SCProductVersion.class },
299                     new ReadOnlyBeanHandler(model));
300 
301             return model;
302         }
303     }
304 
305     public ExpandoBridge getExpandoBridge() {
306         if (_expandoBridge == null) {
307             _expandoBridge = new ExpandoBridgeImpl(SCProductVersion.class.getName(),
308                     getPrimaryKey());
309         }
310 
311         return _expandoBridge;
312     }
313 
314     public Object clone() {
315         SCProductVersionImpl clone = new SCProductVersionImpl();
316 
317         clone.setProductVersionId(getProductVersionId());
318         clone.setCompanyId(getCompanyId());
319         clone.setUserId(getUserId());
320         clone.setUserName(getUserName());
321         clone.setCreateDate(getCreateDate());
322         clone.setModifiedDate(getModifiedDate());
323         clone.setProductEntryId(getProductEntryId());
324         clone.setVersion(getVersion());
325         clone.setChangeLog(getChangeLog());
326         clone.setDownloadPageURL(getDownloadPageURL());
327         clone.setDirectDownloadURL(getDirectDownloadURL());
328         clone.setRepoStoreArtifact(getRepoStoreArtifact());
329 
330         return clone;
331     }
332 
333     public int compareTo(SCProductVersion scProductVersion) {
334         int value = 0;
335 
336         value = DateUtil.compareTo(getCreateDate(),
337                 scProductVersion.getCreateDate());
338 
339         value = value * -1;
340 
341         if (value != 0) {
342             return value;
343         }
344 
345         return 0;
346     }
347 
348     public boolean equals(Object obj) {
349         if (obj == null) {
350             return false;
351         }
352 
353         SCProductVersion scProductVersion = null;
354 
355         try {
356             scProductVersion = (SCProductVersion)obj;
357         }
358         catch (ClassCastException cce) {
359             return false;
360         }
361 
362         long pk = scProductVersion.getPrimaryKey();
363 
364         if (getPrimaryKey() == pk) {
365             return true;
366         }
367         else {
368             return false;
369         }
370     }
371 
372     public int hashCode() {
373         return (int)getPrimaryKey();
374     }
375 
376     public String toString() {
377         StringBuilder sb = new StringBuilder();
378 
379         sb.append("{productVersionId=");
380         sb.append(getProductVersionId());
381         sb.append(", companyId=");
382         sb.append(getCompanyId());
383         sb.append(", userId=");
384         sb.append(getUserId());
385         sb.append(", userName=");
386         sb.append(getUserName());
387         sb.append(", createDate=");
388         sb.append(getCreateDate());
389         sb.append(", modifiedDate=");
390         sb.append(getModifiedDate());
391         sb.append(", productEntryId=");
392         sb.append(getProductEntryId());
393         sb.append(", version=");
394         sb.append(getVersion());
395         sb.append(", changeLog=");
396         sb.append(getChangeLog());
397         sb.append(", downloadPageURL=");
398         sb.append(getDownloadPageURL());
399         sb.append(", directDownloadURL=");
400         sb.append(getDirectDownloadURL());
401         sb.append(", repoStoreArtifact=");
402         sb.append(getRepoStoreArtifact());
403         sb.append("}");
404 
405         return sb.toString();
406     }
407 
408     public String toXmlString() {
409         StringBuilder sb = new StringBuilder();
410 
411         sb.append("<model><model-name>");
412         sb.append("com.liferay.portlet.softwarecatalog.model.SCProductVersion");
413         sb.append("</model-name>");
414 
415         sb.append(
416             "<column><column-name>productVersionId</column-name><column-value><![CDATA[");
417         sb.append(getProductVersionId());
418         sb.append("]]></column-value></column>");
419         sb.append(
420             "<column><column-name>companyId</column-name><column-value><![CDATA[");
421         sb.append(getCompanyId());
422         sb.append("]]></column-value></column>");
423         sb.append(
424             "<column><column-name>userId</column-name><column-value><![CDATA[");
425         sb.append(getUserId());
426         sb.append("]]></column-value></column>");
427         sb.append(
428             "<column><column-name>userName</column-name><column-value><![CDATA[");
429         sb.append(getUserName());
430         sb.append("]]></column-value></column>");
431         sb.append(
432             "<column><column-name>createDate</column-name><column-value><![CDATA[");
433         sb.append(getCreateDate());
434         sb.append("]]></column-value></column>");
435         sb.append(
436             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
437         sb.append(getModifiedDate());
438         sb.append("]]></column-value></column>");
439         sb.append(
440             "<column><column-name>productEntryId</column-name><column-value><![CDATA[");
441         sb.append(getProductEntryId());
442         sb.append("]]></column-value></column>");
443         sb.append(
444             "<column><column-name>version</column-name><column-value><![CDATA[");
445         sb.append(getVersion());
446         sb.append("]]></column-value></column>");
447         sb.append(
448             "<column><column-name>changeLog</column-name><column-value><![CDATA[");
449         sb.append(getChangeLog());
450         sb.append("]]></column-value></column>");
451         sb.append(
452             "<column><column-name>downloadPageURL</column-name><column-value><![CDATA[");
453         sb.append(getDownloadPageURL());
454         sb.append("]]></column-value></column>");
455         sb.append(
456             "<column><column-name>directDownloadURL</column-name><column-value><![CDATA[");
457         sb.append(getDirectDownloadURL());
458         sb.append("]]></column-value></column>");
459         sb.append(
460             "<column><column-name>repoStoreArtifact</column-name><column-value><![CDATA[");
461         sb.append(getRepoStoreArtifact());
462         sb.append("]]></column-value></column>");
463 
464         sb.append("</model>");
465 
466         return sb.toString();
467     }
468 
469     private long _productVersionId;
470     private long _companyId;
471     private long _userId;
472     private String _userName;
473     private Date _createDate;
474     private Date _modifiedDate;
475     private long _productEntryId;
476     private String _version;
477     private String _changeLog;
478     private String _downloadPageURL;
479     private String _directDownloadURL;
480     private String _originalDirectDownloadURL;
481     private boolean _repoStoreArtifact;
482     private transient ExpandoBridge _expandoBridge;
483 }