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.SCProductEntry;
34  import com.liferay.portlet.softwarecatalog.model.SCProductEntrySoap;
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="SCProductEntryModelImpl.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>SCProductEntry</code> table
56   * in the database.
57   * </p>
58   *
59   * @author Brian Wing Shun Chan
60   *
61   * @see com.liferay.portlet.softwarecatalog.model.SCProductEntry
62   * @see com.liferay.portlet.softwarecatalog.model.SCProductEntryModel
63   * @see com.liferay.portlet.softwarecatalog.model.impl.SCProductEntryImpl
64   *
65   */
66  public class SCProductEntryModelImpl extends BaseModelImpl {
67      public static final String TABLE_NAME = "SCProductEntry";
68      public static final Object[][] TABLE_COLUMNS = {
69              { "productEntryId", new Integer(Types.BIGINT) },
70              
71  
72              { "groupId", new Integer(Types.BIGINT) },
73              
74  
75              { "companyId", new Integer(Types.BIGINT) },
76              
77  
78              { "userId", new Integer(Types.BIGINT) },
79              
80  
81              { "userName", new Integer(Types.VARCHAR) },
82              
83  
84              { "createDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "modifiedDate", new Integer(Types.TIMESTAMP) },
88              
89  
90              { "name", new Integer(Types.VARCHAR) },
91              
92  
93              { "type_", new Integer(Types.VARCHAR) },
94              
95  
96              { "tags", new Integer(Types.VARCHAR) },
97              
98  
99              { "shortDescription", new Integer(Types.VARCHAR) },
100             
101 
102             { "longDescription", new Integer(Types.VARCHAR) },
103             
104 
105             { "pageURL", new Integer(Types.VARCHAR) },
106             
107 
108             { "author", new Integer(Types.VARCHAR) },
109             
110 
111             { "repoGroupId", new Integer(Types.VARCHAR) },
112             
113 
114             { "repoArtifactId", new Integer(Types.VARCHAR) }
115         };
116     public static final String TABLE_SQL_CREATE = "create table SCProductEntry (productEntryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name VARCHAR(75) null,type_ VARCHAR(75) null,tags VARCHAR(300) null,shortDescription STRING null,longDescription STRING null,pageURL STRING null,author VARCHAR(75) null,repoGroupId VARCHAR(75) null,repoArtifactId VARCHAR(75) null)";
117     public static final String TABLE_SQL_DROP = "drop table SCProductEntry";
118     public static final String DATA_SOURCE = "liferayDataSource";
119     public static final String SESSION_FACTORY = "liferaySessionFactory";
120     public static final String TX_MANAGER = "liferayTransactionManager";
121     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
122                 "value.object.finder.cache.enabled.com.liferay.portlet.softwarecatalog.model.SCProductEntry"),
123             true);
124 
125     public static SCProductEntry toModel(SCProductEntrySoap soapModel) {
126         SCProductEntry model = new SCProductEntryImpl();
127 
128         model.setProductEntryId(soapModel.getProductEntryId());
129         model.setGroupId(soapModel.getGroupId());
130         model.setCompanyId(soapModel.getCompanyId());
131         model.setUserId(soapModel.getUserId());
132         model.setUserName(soapModel.getUserName());
133         model.setCreateDate(soapModel.getCreateDate());
134         model.setModifiedDate(soapModel.getModifiedDate());
135         model.setName(soapModel.getName());
136         model.setType(soapModel.getType());
137         model.setTags(soapModel.getTags());
138         model.setShortDescription(soapModel.getShortDescription());
139         model.setLongDescription(soapModel.getLongDescription());
140         model.setPageURL(soapModel.getPageURL());
141         model.setAuthor(soapModel.getAuthor());
142         model.setRepoGroupId(soapModel.getRepoGroupId());
143         model.setRepoArtifactId(soapModel.getRepoArtifactId());
144 
145         return model;
146     }
147 
148     public static List<SCProductEntry> toModels(SCProductEntrySoap[] soapModels) {
149         List<SCProductEntry> models = new ArrayList<SCProductEntry>(soapModels.length);
150 
151         for (SCProductEntrySoap soapModel : soapModels) {
152             models.add(toModel(soapModel));
153         }
154 
155         return models;
156     }
157 
158     public static final boolean CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES = com.liferay.portlet.softwarecatalog.model.impl.SCLicenseModelImpl.CACHE_ENABLED_SCLICENSES_SCPRODUCTENTRIES;
159     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
160                 "lock.expiration.time.com.liferay.portlet.softwarecatalog.model.SCProductEntry"));
161 
162     public SCProductEntryModelImpl() {
163     }
164 
165     public long getPrimaryKey() {
166         return _productEntryId;
167     }
168 
169     public void setPrimaryKey(long pk) {
170         setProductEntryId(pk);
171     }
172 
173     public Serializable getPrimaryKeyObj() {
174         return new Long(_productEntryId);
175     }
176 
177     public long getProductEntryId() {
178         return _productEntryId;
179     }
180 
181     public void setProductEntryId(long productEntryId) {
182         if (productEntryId != _productEntryId) {
183             _productEntryId = productEntryId;
184         }
185     }
186 
187     public long getGroupId() {
188         return _groupId;
189     }
190 
191     public void setGroupId(long groupId) {
192         if (groupId != _groupId) {
193             _groupId = groupId;
194         }
195     }
196 
197     public long getCompanyId() {
198         return _companyId;
199     }
200 
201     public void setCompanyId(long companyId) {
202         if (companyId != _companyId) {
203             _companyId = companyId;
204         }
205     }
206 
207     public long getUserId() {
208         return _userId;
209     }
210 
211     public void setUserId(long userId) {
212         if (userId != _userId) {
213             _userId = userId;
214         }
215     }
216 
217     public String getUserName() {
218         return GetterUtil.getString(_userName);
219     }
220 
221     public void setUserName(String userName) {
222         if (((userName == null) && (_userName != null)) ||
223                 ((userName != null) && (_userName == null)) ||
224                 ((userName != null) && (_userName != null) &&
225                 !userName.equals(_userName))) {
226             _userName = userName;
227         }
228     }
229 
230     public Date getCreateDate() {
231         return _createDate;
232     }
233 
234     public void setCreateDate(Date createDate) {
235         if (((createDate == null) && (_createDate != null)) ||
236                 ((createDate != null) && (_createDate == null)) ||
237                 ((createDate != null) && (_createDate != null) &&
238                 !createDate.equals(_createDate))) {
239             _createDate = createDate;
240         }
241     }
242 
243     public Date getModifiedDate() {
244         return _modifiedDate;
245     }
246 
247     public void setModifiedDate(Date modifiedDate) {
248         if (((modifiedDate == null) && (_modifiedDate != null)) ||
249                 ((modifiedDate != null) && (_modifiedDate == null)) ||
250                 ((modifiedDate != null) && (_modifiedDate != null) &&
251                 !modifiedDate.equals(_modifiedDate))) {
252             _modifiedDate = modifiedDate;
253         }
254     }
255 
256     public String getName() {
257         return GetterUtil.getString(_name);
258     }
259 
260     public void setName(String name) {
261         if (((name == null) && (_name != null)) ||
262                 ((name != null) && (_name == null)) ||
263                 ((name != null) && (_name != null) && !name.equals(_name))) {
264             _name = name;
265         }
266     }
267 
268     public String getType() {
269         return GetterUtil.getString(_type);
270     }
271 
272     public void setType(String type) {
273         if (((type == null) && (_type != null)) ||
274                 ((type != null) && (_type == null)) ||
275                 ((type != null) && (_type != null) && !type.equals(_type))) {
276             _type = type;
277         }
278     }
279 
280     public String getTags() {
281         return GetterUtil.getString(_tags);
282     }
283 
284     public void setTags(String tags) {
285         if (((tags == null) && (_tags != null)) ||
286                 ((tags != null) && (_tags == null)) ||
287                 ((tags != null) && (_tags != null) && !tags.equals(_tags))) {
288             _tags = tags;
289         }
290     }
291 
292     public String getShortDescription() {
293         return GetterUtil.getString(_shortDescription);
294     }
295 
296     public void setShortDescription(String shortDescription) {
297         if (((shortDescription == null) && (_shortDescription != null)) ||
298                 ((shortDescription != null) && (_shortDescription == null)) ||
299                 ((shortDescription != null) && (_shortDescription != null) &&
300                 !shortDescription.equals(_shortDescription))) {
301             _shortDescription = shortDescription;
302         }
303     }
304 
305     public String getLongDescription() {
306         return GetterUtil.getString(_longDescription);
307     }
308 
309     public void setLongDescription(String longDescription) {
310         if (((longDescription == null) && (_longDescription != null)) ||
311                 ((longDescription != null) && (_longDescription == null)) ||
312                 ((longDescription != null) && (_longDescription != null) &&
313                 !longDescription.equals(_longDescription))) {
314             _longDescription = longDescription;
315         }
316     }
317 
318     public String getPageURL() {
319         return GetterUtil.getString(_pageURL);
320     }
321 
322     public void setPageURL(String pageURL) {
323         if (((pageURL == null) && (_pageURL != null)) ||
324                 ((pageURL != null) && (_pageURL == null)) ||
325                 ((pageURL != null) && (_pageURL != null) &&
326                 !pageURL.equals(_pageURL))) {
327             _pageURL = pageURL;
328         }
329     }
330 
331     public String getAuthor() {
332         return GetterUtil.getString(_author);
333     }
334 
335     public void setAuthor(String author) {
336         if (((author == null) && (_author != null)) ||
337                 ((author != null) && (_author == null)) ||
338                 ((author != null) && (_author != null) &&
339                 !author.equals(_author))) {
340             _author = author;
341         }
342     }
343 
344     public String getRepoGroupId() {
345         return GetterUtil.getString(_repoGroupId);
346     }
347 
348     public void setRepoGroupId(String repoGroupId) {
349         if (((repoGroupId == null) && (_repoGroupId != null)) ||
350                 ((repoGroupId != null) && (_repoGroupId == null)) ||
351                 ((repoGroupId != null) && (_repoGroupId != null) &&
352                 !repoGroupId.equals(_repoGroupId))) {
353             _repoGroupId = repoGroupId;
354         }
355     }
356 
357     public String getRepoArtifactId() {
358         return GetterUtil.getString(_repoArtifactId);
359     }
360 
361     public void setRepoArtifactId(String repoArtifactId) {
362         if (((repoArtifactId == null) && (_repoArtifactId != null)) ||
363                 ((repoArtifactId != null) && (_repoArtifactId == null)) ||
364                 ((repoArtifactId != null) && (_repoArtifactId != null) &&
365                 !repoArtifactId.equals(_repoArtifactId))) {
366             _repoArtifactId = repoArtifactId;
367         }
368     }
369 
370     public SCProductEntry toEscapedModel() {
371         if (isEscapedModel()) {
372             return (SCProductEntry)this;
373         }
374         else {
375             SCProductEntry model = new SCProductEntryImpl();
376 
377             model.setNew(isNew());
378             model.setEscapedModel(true);
379 
380             model.setProductEntryId(getProductEntryId());
381             model.setGroupId(getGroupId());
382             model.setCompanyId(getCompanyId());
383             model.setUserId(getUserId());
384             model.setUserName(HtmlUtil.escape(getUserName()));
385             model.setCreateDate(getCreateDate());
386             model.setModifiedDate(getModifiedDate());
387             model.setName(HtmlUtil.escape(getName()));
388             model.setType(HtmlUtil.escape(getType()));
389             model.setTags(HtmlUtil.escape(getTags()));
390             model.setShortDescription(HtmlUtil.escape(getShortDescription()));
391             model.setLongDescription(HtmlUtil.escape(getLongDescription()));
392             model.setPageURL(HtmlUtil.escape(getPageURL()));
393             model.setAuthor(HtmlUtil.escape(getAuthor()));
394             model.setRepoGroupId(HtmlUtil.escape(getRepoGroupId()));
395             model.setRepoArtifactId(HtmlUtil.escape(getRepoArtifactId()));
396 
397             model = (SCProductEntry)Proxy.newProxyInstance(SCProductEntry.class.getClassLoader(),
398                     new Class[] { SCProductEntry.class },
399                     new ReadOnlyBeanHandler(model));
400 
401             return model;
402         }
403     }
404 
405     public ExpandoBridge getExpandoBridge() {
406         if (_expandoBridge == null) {
407             _expandoBridge = new ExpandoBridgeImpl(SCProductEntry.class.getName(),
408                     getPrimaryKey());
409         }
410 
411         return _expandoBridge;
412     }
413 
414     public Object clone() {
415         SCProductEntryImpl clone = new SCProductEntryImpl();
416 
417         clone.setProductEntryId(getProductEntryId());
418         clone.setGroupId(getGroupId());
419         clone.setCompanyId(getCompanyId());
420         clone.setUserId(getUserId());
421         clone.setUserName(getUserName());
422         clone.setCreateDate(getCreateDate());
423         clone.setModifiedDate(getModifiedDate());
424         clone.setName(getName());
425         clone.setType(getType());
426         clone.setTags(getTags());
427         clone.setShortDescription(getShortDescription());
428         clone.setLongDescription(getLongDescription());
429         clone.setPageURL(getPageURL());
430         clone.setAuthor(getAuthor());
431         clone.setRepoGroupId(getRepoGroupId());
432         clone.setRepoArtifactId(getRepoArtifactId());
433 
434         return clone;
435     }
436 
437     public int compareTo(Object obj) {
438         if (obj == null) {
439             return -1;
440         }
441 
442         SCProductEntryImpl scProductEntry = (SCProductEntryImpl)obj;
443 
444         int value = 0;
445 
446         value = DateUtil.compareTo(getModifiedDate(),
447                 scProductEntry.getModifiedDate());
448 
449         value = value * -1;
450 
451         if (value != 0) {
452             return value;
453         }
454 
455         value = getName().compareTo(scProductEntry.getName());
456 
457         value = value * -1;
458 
459         if (value != 0) {
460             return value;
461         }
462 
463         return 0;
464     }
465 
466     public boolean equals(Object obj) {
467         if (obj == null) {
468             return false;
469         }
470 
471         SCProductEntryImpl scProductEntry = null;
472 
473         try {
474             scProductEntry = (SCProductEntryImpl)obj;
475         }
476         catch (ClassCastException cce) {
477             return false;
478         }
479 
480         long pk = scProductEntry.getPrimaryKey();
481 
482         if (getPrimaryKey() == pk) {
483             return true;
484         }
485         else {
486             return false;
487         }
488     }
489 
490     public int hashCode() {
491         return (int)getPrimaryKey();
492     }
493 
494     private long _productEntryId;
495     private long _groupId;
496     private long _companyId;
497     private long _userId;
498     private String _userName;
499     private Date _createDate;
500     private Date _modifiedDate;
501     private String _name;
502     private String _type;
503     private String _tags;
504     private String _shortDescription;
505     private String _longDescription;
506     private String _pageURL;
507     private String _author;
508     private String _repoGroupId;
509     private String _repoArtifactId;
510     private transient ExpandoBridge _expandoBridge;
511 }