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