001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.trash.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSON;
020    import com.liferay.portal.kernel.util.DateUtil;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.kernel.util.Validator;
026    import com.liferay.portal.model.CacheModel;
027    import com.liferay.portal.model.impl.BaseModelImpl;
028    import com.liferay.portal.service.ServiceContext;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    import com.liferay.portlet.trash.model.TrashEntry;
034    import com.liferay.portlet.trash.model.TrashEntryModel;
035    import com.liferay.portlet.trash.model.TrashEntrySoap;
036    
037    import java.io.Serializable;
038    
039    import java.sql.Types;
040    
041    import java.util.ArrayList;
042    import java.util.Date;
043    import java.util.HashMap;
044    import java.util.List;
045    import java.util.Map;
046    
047    /**
048     * The base model implementation for the TrashEntry service. Represents a row in the "TrashEntry" database table, with each column mapped to a property of this class.
049     *
050     * <p>
051     * This implementation and its corresponding interface {@link com.liferay.portlet.trash.model.TrashEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TrashEntryImpl}.
052     * </p>
053     *
054     * @author Brian Wing Shun Chan
055     * @see TrashEntryImpl
056     * @see com.liferay.portlet.trash.model.TrashEntry
057     * @see com.liferay.portlet.trash.model.TrashEntryModel
058     * @generated
059     */
060    @JSON(strict = true)
061    public class TrashEntryModelImpl extends BaseModelImpl<TrashEntry>
062            implements TrashEntryModel {
063            /*
064             * NOTE FOR DEVELOPERS:
065             *
066             * Never modify or reference this class directly. All methods that expect a trash entry model instance should use the {@link com.liferay.portlet.trash.model.TrashEntry} interface instead.
067             */
068            public static final String TABLE_NAME = "TrashEntry";
069            public static final Object[][] TABLE_COLUMNS = {
070                            { "entryId", Types.BIGINT },
071                            { "groupId", Types.BIGINT },
072                            { "companyId", Types.BIGINT },
073                            { "userId", Types.BIGINT },
074                            { "userName", Types.VARCHAR },
075                            { "createDate", Types.TIMESTAMP },
076                            { "classNameId", Types.BIGINT },
077                            { "classPK", Types.BIGINT },
078                            { "typeSettings", Types.CLOB },
079                            { "status", Types.INTEGER }
080                    };
081            public static final String TABLE_SQL_CREATE = "create table TrashEntry (entryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,classNameId LONG,classPK LONG,typeSettings TEXT null,status INTEGER)";
082            public static final String TABLE_SQL_DROP = "drop table TrashEntry";
083            public static final String ORDER_BY_JPQL = " ORDER BY trashEntry.createDate DESC";
084            public static final String ORDER_BY_SQL = " ORDER BY TrashEntry.createDate DESC";
085            public static final String DATA_SOURCE = "liferayDataSource";
086            public static final String SESSION_FACTORY = "liferaySessionFactory";
087            public static final String TX_MANAGER = "liferayTransactionManager";
088            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089                                    "value.object.entity.cache.enabled.com.liferay.portlet.trash.model.TrashEntry"),
090                            true);
091            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
092                                    "value.object.finder.cache.enabled.com.liferay.portlet.trash.model.TrashEntry"),
093                            true);
094            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095                                    "value.object.column.bitmask.enabled.com.liferay.portlet.trash.model.TrashEntry"),
096                            true);
097            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
098            public static long CLASSPK_COLUMN_BITMASK = 2L;
099            public static long COMPANYID_COLUMN_BITMASK = 4L;
100            public static long CREATEDATE_COLUMN_BITMASK = 8L;
101            public static long GROUPID_COLUMN_BITMASK = 16L;
102    
103            /**
104             * Converts the soap model instance into a normal model instance.
105             *
106             * @param soapModel the soap model instance to convert
107             * @return the normal model instance
108             */
109            public static TrashEntry toModel(TrashEntrySoap soapModel) {
110                    if (soapModel == null) {
111                            return null;
112                    }
113    
114                    TrashEntry model = new TrashEntryImpl();
115    
116                    model.setEntryId(soapModel.getEntryId());
117                    model.setGroupId(soapModel.getGroupId());
118                    model.setCompanyId(soapModel.getCompanyId());
119                    model.setUserId(soapModel.getUserId());
120                    model.setUserName(soapModel.getUserName());
121                    model.setCreateDate(soapModel.getCreateDate());
122                    model.setClassNameId(soapModel.getClassNameId());
123                    model.setClassPK(soapModel.getClassPK());
124                    model.setTypeSettings(soapModel.getTypeSettings());
125                    model.setStatus(soapModel.getStatus());
126    
127                    return model;
128            }
129    
130            /**
131             * Converts the soap model instances into normal model instances.
132             *
133             * @param soapModels the soap model instances to convert
134             * @return the normal model instances
135             */
136            public static List<TrashEntry> toModels(TrashEntrySoap[] soapModels) {
137                    if (soapModels == null) {
138                            return null;
139                    }
140    
141                    List<TrashEntry> models = new ArrayList<TrashEntry>(soapModels.length);
142    
143                    for (TrashEntrySoap soapModel : soapModels) {
144                            models.add(toModel(soapModel));
145                    }
146    
147                    return models;
148            }
149    
150            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
151                                    "lock.expiration.time.com.liferay.portlet.trash.model.TrashEntry"));
152    
153            public TrashEntryModelImpl() {
154            }
155    
156            @Override
157            public long getPrimaryKey() {
158                    return _entryId;
159            }
160    
161            @Override
162            public void setPrimaryKey(long primaryKey) {
163                    setEntryId(primaryKey);
164            }
165    
166            @Override
167            public Serializable getPrimaryKeyObj() {
168                    return _entryId;
169            }
170    
171            @Override
172            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
173                    setPrimaryKey(((Long)primaryKeyObj).longValue());
174            }
175    
176            @Override
177            public Class<?> getModelClass() {
178                    return TrashEntry.class;
179            }
180    
181            @Override
182            public String getModelClassName() {
183                    return TrashEntry.class.getName();
184            }
185    
186            @Override
187            public Map<String, Object> getModelAttributes() {
188                    Map<String, Object> attributes = new HashMap<String, Object>();
189    
190                    attributes.put("entryId", getEntryId());
191                    attributes.put("groupId", getGroupId());
192                    attributes.put("companyId", getCompanyId());
193                    attributes.put("userId", getUserId());
194                    attributes.put("userName", getUserName());
195                    attributes.put("createDate", getCreateDate());
196                    attributes.put("classNameId", getClassNameId());
197                    attributes.put("classPK", getClassPK());
198                    attributes.put("typeSettings", getTypeSettings());
199                    attributes.put("status", getStatus());
200    
201                    return attributes;
202            }
203    
204            @Override
205            public void setModelAttributes(Map<String, Object> attributes) {
206                    Long entryId = (Long)attributes.get("entryId");
207    
208                    if (entryId != null) {
209                            setEntryId(entryId);
210                    }
211    
212                    Long groupId = (Long)attributes.get("groupId");
213    
214                    if (groupId != null) {
215                            setGroupId(groupId);
216                    }
217    
218                    Long companyId = (Long)attributes.get("companyId");
219    
220                    if (companyId != null) {
221                            setCompanyId(companyId);
222                    }
223    
224                    Long userId = (Long)attributes.get("userId");
225    
226                    if (userId != null) {
227                            setUserId(userId);
228                    }
229    
230                    String userName = (String)attributes.get("userName");
231    
232                    if (userName != null) {
233                            setUserName(userName);
234                    }
235    
236                    Date createDate = (Date)attributes.get("createDate");
237    
238                    if (createDate != null) {
239                            setCreateDate(createDate);
240                    }
241    
242                    Long classNameId = (Long)attributes.get("classNameId");
243    
244                    if (classNameId != null) {
245                            setClassNameId(classNameId);
246                    }
247    
248                    Long classPK = (Long)attributes.get("classPK");
249    
250                    if (classPK != null) {
251                            setClassPK(classPK);
252                    }
253    
254                    String typeSettings = (String)attributes.get("typeSettings");
255    
256                    if (typeSettings != null) {
257                            setTypeSettings(typeSettings);
258                    }
259    
260                    Integer status = (Integer)attributes.get("status");
261    
262                    if (status != null) {
263                            setStatus(status);
264                    }
265            }
266    
267            @JSON
268            @Override
269            public long getEntryId() {
270                    return _entryId;
271            }
272    
273            @Override
274            public void setEntryId(long entryId) {
275                    _entryId = entryId;
276            }
277    
278            @JSON
279            @Override
280            public long getGroupId() {
281                    return _groupId;
282            }
283    
284            @Override
285            public void setGroupId(long groupId) {
286                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
287    
288                    if (!_setOriginalGroupId) {
289                            _setOriginalGroupId = true;
290    
291                            _originalGroupId = _groupId;
292                    }
293    
294                    _groupId = groupId;
295            }
296    
297            public long getOriginalGroupId() {
298                    return _originalGroupId;
299            }
300    
301            @JSON
302            @Override
303            public long getCompanyId() {
304                    return _companyId;
305            }
306    
307            @Override
308            public void setCompanyId(long companyId) {
309                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
310    
311                    if (!_setOriginalCompanyId) {
312                            _setOriginalCompanyId = true;
313    
314                            _originalCompanyId = _companyId;
315                    }
316    
317                    _companyId = companyId;
318            }
319    
320            public long getOriginalCompanyId() {
321                    return _originalCompanyId;
322            }
323    
324            @JSON
325            @Override
326            public long getUserId() {
327                    return _userId;
328            }
329    
330            @Override
331            public void setUserId(long userId) {
332                    _userId = userId;
333            }
334    
335            @Override
336            public String getUserUuid() throws SystemException {
337                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
338            }
339    
340            @Override
341            public void setUserUuid(String userUuid) {
342                    _userUuid = userUuid;
343            }
344    
345            @JSON
346            @Override
347            public String getUserName() {
348                    if (_userName == null) {
349                            return StringPool.BLANK;
350                    }
351                    else {
352                            return _userName;
353                    }
354            }
355    
356            @Override
357            public void setUserName(String userName) {
358                    _userName = userName;
359            }
360    
361            @JSON
362            @Override
363            public Date getCreateDate() {
364                    return _createDate;
365            }
366    
367            @Override
368            public void setCreateDate(Date createDate) {
369                    _columnBitmask = -1L;
370    
371                    if (_originalCreateDate == null) {
372                            _originalCreateDate = _createDate;
373                    }
374    
375                    _createDate = createDate;
376            }
377    
378            public Date getOriginalCreateDate() {
379                    return _originalCreateDate;
380            }
381    
382            @Override
383            public String getClassName() {
384                    if (getClassNameId() <= 0) {
385                            return StringPool.BLANK;
386                    }
387    
388                    return PortalUtil.getClassName(getClassNameId());
389            }
390    
391            @Override
392            public void setClassName(String className) {
393                    long classNameId = 0;
394    
395                    if (Validator.isNotNull(className)) {
396                            classNameId = PortalUtil.getClassNameId(className);
397                    }
398    
399                    setClassNameId(classNameId);
400            }
401    
402            @JSON
403            @Override
404            public long getClassNameId() {
405                    return _classNameId;
406            }
407    
408            @Override
409            public void setClassNameId(long classNameId) {
410                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
411    
412                    if (!_setOriginalClassNameId) {
413                            _setOriginalClassNameId = true;
414    
415                            _originalClassNameId = _classNameId;
416                    }
417    
418                    _classNameId = classNameId;
419            }
420    
421            public long getOriginalClassNameId() {
422                    return _originalClassNameId;
423            }
424    
425            @JSON
426            @Override
427            public long getClassPK() {
428                    return _classPK;
429            }
430    
431            @Override
432            public void setClassPK(long classPK) {
433                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
434    
435                    if (!_setOriginalClassPK) {
436                            _setOriginalClassPK = true;
437    
438                            _originalClassPK = _classPK;
439                    }
440    
441                    _classPK = classPK;
442            }
443    
444            public long getOriginalClassPK() {
445                    return _originalClassPK;
446            }
447    
448            @JSON
449            @Override
450            public String getTypeSettings() {
451                    if (_typeSettings == null) {
452                            return StringPool.BLANK;
453                    }
454                    else {
455                            return _typeSettings;
456                    }
457            }
458    
459            @Override
460            public void setTypeSettings(String typeSettings) {
461                    _typeSettings = typeSettings;
462            }
463    
464            @JSON
465            @Override
466            public int getStatus() {
467                    return _status;
468            }
469    
470            @Override
471            public void setStatus(int status) {
472                    _status = status;
473            }
474    
475            public long getColumnBitmask() {
476                    return _columnBitmask;
477            }
478    
479            @Override
480            public ExpandoBridge getExpandoBridge() {
481                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
482                            TrashEntry.class.getName(), getPrimaryKey());
483            }
484    
485            @Override
486            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
487                    ExpandoBridge expandoBridge = getExpandoBridge();
488    
489                    expandoBridge.setAttributes(serviceContext);
490            }
491    
492            @Override
493            public TrashEntry toEscapedModel() {
494                    if (_escapedModel == null) {
495                            _escapedModel = (TrashEntry)ProxyUtil.newProxyInstance(_classLoader,
496                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
497                    }
498    
499                    return _escapedModel;
500            }
501    
502            @Override
503            public Object clone() {
504                    TrashEntryImpl trashEntryImpl = new TrashEntryImpl();
505    
506                    trashEntryImpl.setEntryId(getEntryId());
507                    trashEntryImpl.setGroupId(getGroupId());
508                    trashEntryImpl.setCompanyId(getCompanyId());
509                    trashEntryImpl.setUserId(getUserId());
510                    trashEntryImpl.setUserName(getUserName());
511                    trashEntryImpl.setCreateDate(getCreateDate());
512                    trashEntryImpl.setClassNameId(getClassNameId());
513                    trashEntryImpl.setClassPK(getClassPK());
514                    trashEntryImpl.setTypeSettings(getTypeSettings());
515                    trashEntryImpl.setStatus(getStatus());
516    
517                    trashEntryImpl.resetOriginalValues();
518    
519                    return trashEntryImpl;
520            }
521    
522            @Override
523            public int compareTo(TrashEntry trashEntry) {
524                    int value = 0;
525    
526                    value = DateUtil.compareTo(getCreateDate(), trashEntry.getCreateDate());
527    
528                    value = value * -1;
529    
530                    if (value != 0) {
531                            return value;
532                    }
533    
534                    return 0;
535            }
536    
537            @Override
538            public boolean equals(Object obj) {
539                    if (this == obj) {
540                            return true;
541                    }
542    
543                    if (!(obj instanceof TrashEntry)) {
544                            return false;
545                    }
546    
547                    TrashEntry trashEntry = (TrashEntry)obj;
548    
549                    long primaryKey = trashEntry.getPrimaryKey();
550    
551                    if (getPrimaryKey() == primaryKey) {
552                            return true;
553                    }
554                    else {
555                            return false;
556                    }
557            }
558    
559            @Override
560            public int hashCode() {
561                    return (int)getPrimaryKey();
562            }
563    
564            @Override
565            public void resetOriginalValues() {
566                    TrashEntryModelImpl trashEntryModelImpl = this;
567    
568                    trashEntryModelImpl._originalGroupId = trashEntryModelImpl._groupId;
569    
570                    trashEntryModelImpl._setOriginalGroupId = false;
571    
572                    trashEntryModelImpl._originalCompanyId = trashEntryModelImpl._companyId;
573    
574                    trashEntryModelImpl._setOriginalCompanyId = false;
575    
576                    trashEntryModelImpl._originalCreateDate = trashEntryModelImpl._createDate;
577    
578                    trashEntryModelImpl._originalClassNameId = trashEntryModelImpl._classNameId;
579    
580                    trashEntryModelImpl._setOriginalClassNameId = false;
581    
582                    trashEntryModelImpl._originalClassPK = trashEntryModelImpl._classPK;
583    
584                    trashEntryModelImpl._setOriginalClassPK = false;
585    
586                    trashEntryModelImpl._columnBitmask = 0;
587            }
588    
589            @Override
590            public CacheModel<TrashEntry> toCacheModel() {
591                    TrashEntryCacheModel trashEntryCacheModel = new TrashEntryCacheModel();
592    
593                    trashEntryCacheModel.entryId = getEntryId();
594    
595                    trashEntryCacheModel.groupId = getGroupId();
596    
597                    trashEntryCacheModel.companyId = getCompanyId();
598    
599                    trashEntryCacheModel.userId = getUserId();
600    
601                    trashEntryCacheModel.userName = getUserName();
602    
603                    String userName = trashEntryCacheModel.userName;
604    
605                    if ((userName != null) && (userName.length() == 0)) {
606                            trashEntryCacheModel.userName = null;
607                    }
608    
609                    Date createDate = getCreateDate();
610    
611                    if (createDate != null) {
612                            trashEntryCacheModel.createDate = createDate.getTime();
613                    }
614                    else {
615                            trashEntryCacheModel.createDate = Long.MIN_VALUE;
616                    }
617    
618                    trashEntryCacheModel.classNameId = getClassNameId();
619    
620                    trashEntryCacheModel.classPK = getClassPK();
621    
622                    trashEntryCacheModel.typeSettings = getTypeSettings();
623    
624                    String typeSettings = trashEntryCacheModel.typeSettings;
625    
626                    if ((typeSettings != null) && (typeSettings.length() == 0)) {
627                            trashEntryCacheModel.typeSettings = null;
628                    }
629    
630                    trashEntryCacheModel.status = getStatus();
631    
632                    return trashEntryCacheModel;
633            }
634    
635            @Override
636            public String toString() {
637                    StringBundler sb = new StringBundler(21);
638    
639                    sb.append("{entryId=");
640                    sb.append(getEntryId());
641                    sb.append(", groupId=");
642                    sb.append(getGroupId());
643                    sb.append(", companyId=");
644                    sb.append(getCompanyId());
645                    sb.append(", userId=");
646                    sb.append(getUserId());
647                    sb.append(", userName=");
648                    sb.append(getUserName());
649                    sb.append(", createDate=");
650                    sb.append(getCreateDate());
651                    sb.append(", classNameId=");
652                    sb.append(getClassNameId());
653                    sb.append(", classPK=");
654                    sb.append(getClassPK());
655                    sb.append(", typeSettings=");
656                    sb.append(getTypeSettings());
657                    sb.append(", status=");
658                    sb.append(getStatus());
659                    sb.append("}");
660    
661                    return sb.toString();
662            }
663    
664            @Override
665            public String toXmlString() {
666                    StringBundler sb = new StringBundler(34);
667    
668                    sb.append("<model><model-name>");
669                    sb.append("com.liferay.portlet.trash.model.TrashEntry");
670                    sb.append("</model-name>");
671    
672                    sb.append(
673                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
674                    sb.append(getEntryId());
675                    sb.append("]]></column-value></column>");
676                    sb.append(
677                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
678                    sb.append(getGroupId());
679                    sb.append("]]></column-value></column>");
680                    sb.append(
681                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
682                    sb.append(getCompanyId());
683                    sb.append("]]></column-value></column>");
684                    sb.append(
685                            "<column><column-name>userId</column-name><column-value><![CDATA[");
686                    sb.append(getUserId());
687                    sb.append("]]></column-value></column>");
688                    sb.append(
689                            "<column><column-name>userName</column-name><column-value><![CDATA[");
690                    sb.append(getUserName());
691                    sb.append("]]></column-value></column>");
692                    sb.append(
693                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
694                    sb.append(getCreateDate());
695                    sb.append("]]></column-value></column>");
696                    sb.append(
697                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
698                    sb.append(getClassNameId());
699                    sb.append("]]></column-value></column>");
700                    sb.append(
701                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
702                    sb.append(getClassPK());
703                    sb.append("]]></column-value></column>");
704                    sb.append(
705                            "<column><column-name>typeSettings</column-name><column-value><![CDATA[");
706                    sb.append(getTypeSettings());
707                    sb.append("]]></column-value></column>");
708                    sb.append(
709                            "<column><column-name>status</column-name><column-value><![CDATA[");
710                    sb.append(getStatus());
711                    sb.append("]]></column-value></column>");
712    
713                    sb.append("</model>");
714    
715                    return sb.toString();
716            }
717    
718            private static ClassLoader _classLoader = TrashEntry.class.getClassLoader();
719            private static Class<?>[] _escapedModelInterfaces = new Class[] {
720                            TrashEntry.class
721                    };
722            private long _entryId;
723            private long _groupId;
724            private long _originalGroupId;
725            private boolean _setOriginalGroupId;
726            private long _companyId;
727            private long _originalCompanyId;
728            private boolean _setOriginalCompanyId;
729            private long _userId;
730            private String _userUuid;
731            private String _userName;
732            private Date _createDate;
733            private Date _originalCreateDate;
734            private long _classNameId;
735            private long _originalClassNameId;
736            private boolean _setOriginalClassNameId;
737            private long _classPK;
738            private long _originalClassPK;
739            private boolean _setOriginalClassPK;
740            private String _typeSettings;
741            private int _status;
742            private long _columnBitmask;
743            private TrashEntry _escapedModel;
744    }