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