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.tags.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import com.liferay.portlet.tags.model.TagsAsset;
33  import com.liferay.portlet.tags.model.TagsAssetSoap;
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="TagsAssetModelImpl.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>TagsAsset</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.tags.service.model.TagsAsset
61   * @see com.liferay.portlet.tags.service.model.TagsAssetModel
62   * @see com.liferay.portlet.tags.service.model.impl.TagsAssetImpl
63   *
64   */
65  public class TagsAssetModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "TagsAsset";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "assetId", 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              { "classNameId", new Integer(Types.BIGINT) },
90              
91  
92              { "classPK", new Integer(Types.BIGINT) },
93              
94  
95              { "startDate", new Integer(Types.TIMESTAMP) },
96              
97  
98              { "endDate", new Integer(Types.TIMESTAMP) },
99              
100 
101             { "publishDate", new Integer(Types.TIMESTAMP) },
102             
103 
104             { "expirationDate", new Integer(Types.TIMESTAMP) },
105             
106 
107             { "mimeType", new Integer(Types.VARCHAR) },
108             
109 
110             { "title", new Integer(Types.VARCHAR) },
111             
112 
113             { "description", new Integer(Types.VARCHAR) },
114             
115 
116             { "summary", new Integer(Types.VARCHAR) },
117             
118 
119             { "url", new Integer(Types.VARCHAR) },
120             
121 
122             { "height", new Integer(Types.INTEGER) },
123             
124 
125             { "width", new Integer(Types.INTEGER) },
126             
127 
128             { "priority", new Integer(Types.DOUBLE) },
129             
130 
131             { "viewCount", new Integer(Types.INTEGER) }
132         };
133     public static final String TABLE_SQL_CREATE = "create table TagsAsset (assetId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,startDate DATE null,endDate DATE null,publishDate DATE null,expirationDate DATE null,mimeType VARCHAR(75) null,title VARCHAR(300) null,description STRING null,summary STRING null,url STRING null,height INTEGER,width INTEGER,priority DOUBLE,viewCount INTEGER)";
134     public static final String TABLE_SQL_DROP = "drop table TagsAsset";
135     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
136                 "value.object.finder.cache.enabled.com.liferay.portlet.tags.model.TagsAsset"),
137             true);
138 
139     public static TagsAsset toModel(TagsAssetSoap soapModel) {
140         TagsAsset model = new TagsAssetImpl();
141 
142         model.setAssetId(soapModel.getAssetId());
143         model.setGroupId(soapModel.getGroupId());
144         model.setCompanyId(soapModel.getCompanyId());
145         model.setUserId(soapModel.getUserId());
146         model.setUserName(soapModel.getUserName());
147         model.setCreateDate(soapModel.getCreateDate());
148         model.setModifiedDate(soapModel.getModifiedDate());
149         model.setClassNameId(soapModel.getClassNameId());
150         model.setClassPK(soapModel.getClassPK());
151         model.setStartDate(soapModel.getStartDate());
152         model.setEndDate(soapModel.getEndDate());
153         model.setPublishDate(soapModel.getPublishDate());
154         model.setExpirationDate(soapModel.getExpirationDate());
155         model.setMimeType(soapModel.getMimeType());
156         model.setTitle(soapModel.getTitle());
157         model.setDescription(soapModel.getDescription());
158         model.setSummary(soapModel.getSummary());
159         model.setUrl(soapModel.getUrl());
160         model.setHeight(soapModel.getHeight());
161         model.setWidth(soapModel.getWidth());
162         model.setPriority(soapModel.getPriority());
163         model.setViewCount(soapModel.getViewCount());
164 
165         return model;
166     }
167 
168     public static List<TagsAsset> toModels(TagsAssetSoap[] soapModels) {
169         List<TagsAsset> models = new ArrayList<TagsAsset>(soapModels.length);
170 
171         for (TagsAssetSoap soapModel : soapModels) {
172             models.add(toModel(soapModel));
173         }
174 
175         return models;
176     }
177 
178     public static final boolean CACHE_ENABLED_TAGSASSETS_TAGSENTRIES = GetterUtil.getBoolean(PropsUtil.get(
179                 "value.object.finder.cache.enabled.TagsAssets_TagsEntries"),
180             true);
181     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
182                 "lock.expiration.time.com.liferay.portlet.tags.model.TagsAsset"));
183 
184     public TagsAssetModelImpl() {
185     }
186 
187     public long getPrimaryKey() {
188         return _assetId;
189     }
190 
191     public void setPrimaryKey(long pk) {
192         setAssetId(pk);
193     }
194 
195     public Serializable getPrimaryKeyObj() {
196         return new Long(_assetId);
197     }
198 
199     public long getAssetId() {
200         return _assetId;
201     }
202 
203     public void setAssetId(long assetId) {
204         if (assetId != _assetId) {
205             _assetId = assetId;
206         }
207     }
208 
209     public long getGroupId() {
210         return _groupId;
211     }
212 
213     public void setGroupId(long groupId) {
214         if (groupId != _groupId) {
215             _groupId = groupId;
216         }
217     }
218 
219     public long getCompanyId() {
220         return _companyId;
221     }
222 
223     public void setCompanyId(long companyId) {
224         if (companyId != _companyId) {
225             _companyId = companyId;
226         }
227     }
228 
229     public long getUserId() {
230         return _userId;
231     }
232 
233     public void setUserId(long userId) {
234         if (userId != _userId) {
235             _userId = userId;
236         }
237     }
238 
239     public String getUserName() {
240         return GetterUtil.getString(_userName);
241     }
242 
243     public void setUserName(String userName) {
244         if (((userName == null) && (_userName != null)) ||
245                 ((userName != null) && (_userName == null)) ||
246                 ((userName != null) && (_userName != null) &&
247                 !userName.equals(_userName))) {
248             _userName = userName;
249         }
250     }
251 
252     public Date getCreateDate() {
253         return _createDate;
254     }
255 
256     public void setCreateDate(Date createDate) {
257         if (((createDate == null) && (_createDate != null)) ||
258                 ((createDate != null) && (_createDate == null)) ||
259                 ((createDate != null) && (_createDate != null) &&
260                 !createDate.equals(_createDate))) {
261             _createDate = createDate;
262         }
263     }
264 
265     public Date getModifiedDate() {
266         return _modifiedDate;
267     }
268 
269     public void setModifiedDate(Date modifiedDate) {
270         if (((modifiedDate == null) && (_modifiedDate != null)) ||
271                 ((modifiedDate != null) && (_modifiedDate == null)) ||
272                 ((modifiedDate != null) && (_modifiedDate != null) &&
273                 !modifiedDate.equals(_modifiedDate))) {
274             _modifiedDate = modifiedDate;
275         }
276     }
277 
278     public String getClassName() {
279         return PortalUtil.getClassName(getClassNameId());
280     }
281 
282     public long getClassNameId() {
283         return _classNameId;
284     }
285 
286     public void setClassNameId(long classNameId) {
287         if (classNameId != _classNameId) {
288             _classNameId = classNameId;
289         }
290     }
291 
292     public long getClassPK() {
293         return _classPK;
294     }
295 
296     public void setClassPK(long classPK) {
297         if (classPK != _classPK) {
298             _classPK = classPK;
299         }
300     }
301 
302     public Date getStartDate() {
303         return _startDate;
304     }
305 
306     public void setStartDate(Date startDate) {
307         if (((startDate == null) && (_startDate != null)) ||
308                 ((startDate != null) && (_startDate == null)) ||
309                 ((startDate != null) && (_startDate != null) &&
310                 !startDate.equals(_startDate))) {
311             _startDate = startDate;
312         }
313     }
314 
315     public Date getEndDate() {
316         return _endDate;
317     }
318 
319     public void setEndDate(Date endDate) {
320         if (((endDate == null) && (_endDate != null)) ||
321                 ((endDate != null) && (_endDate == null)) ||
322                 ((endDate != null) && (_endDate != null) &&
323                 !endDate.equals(_endDate))) {
324             _endDate = endDate;
325         }
326     }
327 
328     public Date getPublishDate() {
329         return _publishDate;
330     }
331 
332     public void setPublishDate(Date publishDate) {
333         if (((publishDate == null) && (_publishDate != null)) ||
334                 ((publishDate != null) && (_publishDate == null)) ||
335                 ((publishDate != null) && (_publishDate != null) &&
336                 !publishDate.equals(_publishDate))) {
337             _publishDate = publishDate;
338         }
339     }
340 
341     public Date getExpirationDate() {
342         return _expirationDate;
343     }
344 
345     public void setExpirationDate(Date expirationDate) {
346         if (((expirationDate == null) && (_expirationDate != null)) ||
347                 ((expirationDate != null) && (_expirationDate == null)) ||
348                 ((expirationDate != null) && (_expirationDate != null) &&
349                 !expirationDate.equals(_expirationDate))) {
350             _expirationDate = expirationDate;
351         }
352     }
353 
354     public String getMimeType() {
355         return GetterUtil.getString(_mimeType);
356     }
357 
358     public void setMimeType(String mimeType) {
359         if (((mimeType == null) && (_mimeType != null)) ||
360                 ((mimeType != null) && (_mimeType == null)) ||
361                 ((mimeType != null) && (_mimeType != null) &&
362                 !mimeType.equals(_mimeType))) {
363             _mimeType = mimeType;
364         }
365     }
366 
367     public String getTitle() {
368         return GetterUtil.getString(_title);
369     }
370 
371     public void setTitle(String title) {
372         if (((title == null) && (_title != null)) ||
373                 ((title != null) && (_title == null)) ||
374                 ((title != null) && (_title != null) && !title.equals(_title))) {
375             _title = title;
376         }
377     }
378 
379     public String getDescription() {
380         return GetterUtil.getString(_description);
381     }
382 
383     public void setDescription(String description) {
384         if (((description == null) && (_description != null)) ||
385                 ((description != null) && (_description == null)) ||
386                 ((description != null) && (_description != null) &&
387                 !description.equals(_description))) {
388             _description = description;
389         }
390     }
391 
392     public String getSummary() {
393         return GetterUtil.getString(_summary);
394     }
395 
396     public void setSummary(String summary) {
397         if (((summary == null) && (_summary != null)) ||
398                 ((summary != null) && (_summary == null)) ||
399                 ((summary != null) && (_summary != null) &&
400                 !summary.equals(_summary))) {
401             _summary = summary;
402         }
403     }
404 
405     public String getUrl() {
406         return GetterUtil.getString(_url);
407     }
408 
409     public void setUrl(String url) {
410         if (((url == null) && (_url != null)) ||
411                 ((url != null) && (_url == null)) ||
412                 ((url != null) && (_url != null) && !url.equals(_url))) {
413             _url = url;
414         }
415     }
416 
417     public int getHeight() {
418         return _height;
419     }
420 
421     public void setHeight(int height) {
422         if (height != _height) {
423             _height = height;
424         }
425     }
426 
427     public int getWidth() {
428         return _width;
429     }
430 
431     public void setWidth(int width) {
432         if (width != _width) {
433             _width = width;
434         }
435     }
436 
437     public double getPriority() {
438         return _priority;
439     }
440 
441     public void setPriority(double priority) {
442         if (priority != _priority) {
443             _priority = priority;
444         }
445     }
446 
447     public int getViewCount() {
448         return _viewCount;
449     }
450 
451     public void setViewCount(int viewCount) {
452         if (viewCount != _viewCount) {
453             _viewCount = viewCount;
454         }
455     }
456 
457     public TagsAsset toEscapedModel() {
458         if (isEscapedModel()) {
459             return (TagsAsset)this;
460         }
461         else {
462             TagsAsset model = new TagsAssetImpl();
463 
464             model.setEscapedModel(true);
465 
466             model.setAssetId(getAssetId());
467             model.setGroupId(getGroupId());
468             model.setCompanyId(getCompanyId());
469             model.setUserId(getUserId());
470             model.setUserName(HtmlUtil.escape(getUserName()));
471             model.setCreateDate(getCreateDate());
472             model.setModifiedDate(getModifiedDate());
473             model.setClassNameId(getClassNameId());
474             model.setClassPK(getClassPK());
475             model.setStartDate(getStartDate());
476             model.setEndDate(getEndDate());
477             model.setPublishDate(getPublishDate());
478             model.setExpirationDate(getExpirationDate());
479             model.setMimeType(HtmlUtil.escape(getMimeType()));
480             model.setTitle(HtmlUtil.escape(getTitle()));
481             model.setDescription(HtmlUtil.escape(getDescription()));
482             model.setSummary(HtmlUtil.escape(getSummary()));
483             model.setUrl(HtmlUtil.escape(getUrl()));
484             model.setHeight(getHeight());
485             model.setWidth(getWidth());
486             model.setPriority(getPriority());
487             model.setViewCount(getViewCount());
488 
489             model = (TagsAsset)Proxy.newProxyInstance(TagsAsset.class.getClassLoader(),
490                     new Class[] { TagsAsset.class },
491                     new ReadOnlyBeanHandler(model));
492 
493             return model;
494         }
495     }
496 
497     public Object clone() {
498         TagsAssetImpl clone = new TagsAssetImpl();
499 
500         clone.setAssetId(getAssetId());
501         clone.setGroupId(getGroupId());
502         clone.setCompanyId(getCompanyId());
503         clone.setUserId(getUserId());
504         clone.setUserName(getUserName());
505         clone.setCreateDate(getCreateDate());
506         clone.setModifiedDate(getModifiedDate());
507         clone.setClassNameId(getClassNameId());
508         clone.setClassPK(getClassPK());
509         clone.setStartDate(getStartDate());
510         clone.setEndDate(getEndDate());
511         clone.setPublishDate(getPublishDate());
512         clone.setExpirationDate(getExpirationDate());
513         clone.setMimeType(getMimeType());
514         clone.setTitle(getTitle());
515         clone.setDescription(getDescription());
516         clone.setSummary(getSummary());
517         clone.setUrl(getUrl());
518         clone.setHeight(getHeight());
519         clone.setWidth(getWidth());
520         clone.setPriority(getPriority());
521         clone.setViewCount(getViewCount());
522 
523         return clone;
524     }
525 
526     public int compareTo(Object obj) {
527         if (obj == null) {
528             return -1;
529         }
530 
531         TagsAssetImpl tagsAsset = (TagsAssetImpl)obj;
532 
533         long pk = tagsAsset.getPrimaryKey();
534 
535         if (getPrimaryKey() < pk) {
536             return -1;
537         }
538         else if (getPrimaryKey() > pk) {
539             return 1;
540         }
541         else {
542             return 0;
543         }
544     }
545 
546     public boolean equals(Object obj) {
547         if (obj == null) {
548             return false;
549         }
550 
551         TagsAssetImpl tagsAsset = null;
552 
553         try {
554             tagsAsset = (TagsAssetImpl)obj;
555         }
556         catch (ClassCastException cce) {
557             return false;
558         }
559 
560         long pk = tagsAsset.getPrimaryKey();
561 
562         if (getPrimaryKey() == pk) {
563             return true;
564         }
565         else {
566             return false;
567         }
568     }
569 
570     public int hashCode() {
571         return (int)getPrimaryKey();
572     }
573 
574     private long _assetId;
575     private long _groupId;
576     private long _companyId;
577     private long _userId;
578     private String _userName;
579     private Date _createDate;
580     private Date _modifiedDate;
581     private long _classNameId;
582     private long _classPK;
583     private Date _startDate;
584     private Date _endDate;
585     private Date _publishDate;
586     private Date _expirationDate;
587     private String _mimeType;
588     private String _title;
589     private String _description;
590     private String _summary;
591     private String _url;
592     private int _height;
593     private int _width;
594     private double _priority;
595     private int _viewCount;
596 }