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