001    /**
002     * Copyright (c) 2000-2012 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            public long getPrimaryKey() {
157                    return _entryId;
158            }
159    
160            public void setPrimaryKey(long primaryKey) {
161                    setEntryId(primaryKey);
162            }
163    
164            public Serializable getPrimaryKeyObj() {
165                    return new Long(_entryId);
166            }
167    
168            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
169                    setPrimaryKey(((Long)primaryKeyObj).longValue());
170            }
171    
172            public Class<?> getModelClass() {
173                    return TrashEntry.class;
174            }
175    
176            public String getModelClassName() {
177                    return TrashEntry.class.getName();
178            }
179    
180            @Override
181            public Map<String, Object> getModelAttributes() {
182                    Map<String, Object> attributes = new HashMap<String, Object>();
183    
184                    attributes.put("entryId", getEntryId());
185                    attributes.put("groupId", getGroupId());
186                    attributes.put("companyId", getCompanyId());
187                    attributes.put("userId", getUserId());
188                    attributes.put("userName", getUserName());
189                    attributes.put("createDate", getCreateDate());
190                    attributes.put("classNameId", getClassNameId());
191                    attributes.put("classPK", getClassPK());
192                    attributes.put("typeSettings", getTypeSettings());
193                    attributes.put("status", getStatus());
194    
195                    return attributes;
196            }
197    
198            @Override
199            public void setModelAttributes(Map<String, Object> attributes) {
200                    Long entryId = (Long)attributes.get("entryId");
201    
202                    if (entryId != null) {
203                            setEntryId(entryId);
204                    }
205    
206                    Long groupId = (Long)attributes.get("groupId");
207    
208                    if (groupId != null) {
209                            setGroupId(groupId);
210                    }
211    
212                    Long companyId = (Long)attributes.get("companyId");
213    
214                    if (companyId != null) {
215                            setCompanyId(companyId);
216                    }
217    
218                    Long userId = (Long)attributes.get("userId");
219    
220                    if (userId != null) {
221                            setUserId(userId);
222                    }
223    
224                    String userName = (String)attributes.get("userName");
225    
226                    if (userName != null) {
227                            setUserName(userName);
228                    }
229    
230                    Date createDate = (Date)attributes.get("createDate");
231    
232                    if (createDate != null) {
233                            setCreateDate(createDate);
234                    }
235    
236                    Long classNameId = (Long)attributes.get("classNameId");
237    
238                    if (classNameId != null) {
239                            setClassNameId(classNameId);
240                    }
241    
242                    Long classPK = (Long)attributes.get("classPK");
243    
244                    if (classPK != null) {
245                            setClassPK(classPK);
246                    }
247    
248                    String typeSettings = (String)attributes.get("typeSettings");
249    
250                    if (typeSettings != null) {
251                            setTypeSettings(typeSettings);
252                    }
253    
254                    Integer status = (Integer)attributes.get("status");
255    
256                    if (status != null) {
257                            setStatus(status);
258                    }
259            }
260    
261            @JSON
262            public long getEntryId() {
263                    return _entryId;
264            }
265    
266            public void setEntryId(long entryId) {
267                    _entryId = entryId;
268            }
269    
270            @JSON
271            public long getGroupId() {
272                    return _groupId;
273            }
274    
275            public void setGroupId(long groupId) {
276                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
277    
278                    if (!_setOriginalGroupId) {
279                            _setOriginalGroupId = true;
280    
281                            _originalGroupId = _groupId;
282                    }
283    
284                    _groupId = groupId;
285            }
286    
287            public long getOriginalGroupId() {
288                    return _originalGroupId;
289            }
290    
291            @JSON
292            public long getCompanyId() {
293                    return _companyId;
294            }
295    
296            public void setCompanyId(long companyId) {
297                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
298    
299                    if (!_setOriginalCompanyId) {
300                            _setOriginalCompanyId = true;
301    
302                            _originalCompanyId = _companyId;
303                    }
304    
305                    _companyId = companyId;
306            }
307    
308            public long getOriginalCompanyId() {
309                    return _originalCompanyId;
310            }
311    
312            @JSON
313            public long getUserId() {
314                    return _userId;
315            }
316    
317            public void setUserId(long userId) {
318                    _userId = userId;
319            }
320    
321            public String getUserUuid() throws SystemException {
322                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
323            }
324    
325            public void setUserUuid(String userUuid) {
326                    _userUuid = userUuid;
327            }
328    
329            @JSON
330            public String getUserName() {
331                    if (_userName == null) {
332                            return StringPool.BLANK;
333                    }
334                    else {
335                            return _userName;
336                    }
337            }
338    
339            public void setUserName(String userName) {
340                    _userName = userName;
341            }
342    
343            @JSON
344            public Date getCreateDate() {
345                    return _createDate;
346            }
347    
348            public void setCreateDate(Date createDate) {
349                    _columnBitmask = -1L;
350    
351                    if (_originalCreateDate == null) {
352                            _originalCreateDate = _createDate;
353                    }
354    
355                    _createDate = createDate;
356            }
357    
358            public Date getOriginalCreateDate() {
359                    return _originalCreateDate;
360            }
361    
362            public String getClassName() {
363                    if (getClassNameId() <= 0) {
364                            return StringPool.BLANK;
365                    }
366    
367                    return PortalUtil.getClassName(getClassNameId());
368            }
369    
370            public void setClassName(String className) {
371                    long classNameId = 0;
372    
373                    if (Validator.isNotNull(className)) {
374                            classNameId = PortalUtil.getClassNameId(className);
375                    }
376    
377                    setClassNameId(classNameId);
378            }
379    
380            @JSON
381            public long getClassNameId() {
382                    return _classNameId;
383            }
384    
385            public void setClassNameId(long classNameId) {
386                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
387    
388                    if (!_setOriginalClassNameId) {
389                            _setOriginalClassNameId = true;
390    
391                            _originalClassNameId = _classNameId;
392                    }
393    
394                    _classNameId = classNameId;
395            }
396    
397            public long getOriginalClassNameId() {
398                    return _originalClassNameId;
399            }
400    
401            @JSON
402            public long getClassPK() {
403                    return _classPK;
404            }
405    
406            public void setClassPK(long classPK) {
407                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
408    
409                    if (!_setOriginalClassPK) {
410                            _setOriginalClassPK = true;
411    
412                            _originalClassPK = _classPK;
413                    }
414    
415                    _classPK = classPK;
416            }
417    
418            public long getOriginalClassPK() {
419                    return _originalClassPK;
420            }
421    
422            @JSON
423            public String getTypeSettings() {
424                    if (_typeSettings == null) {
425                            return StringPool.BLANK;
426                    }
427                    else {
428                            return _typeSettings;
429                    }
430            }
431    
432            public void setTypeSettings(String typeSettings) {
433                    _typeSettings = typeSettings;
434            }
435    
436            @JSON
437            public int getStatus() {
438                    return _status;
439            }
440    
441            public void setStatus(int status) {
442                    _status = status;
443            }
444    
445            public long getColumnBitmask() {
446                    return _columnBitmask;
447            }
448    
449            @Override
450            public ExpandoBridge getExpandoBridge() {
451                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
452                            TrashEntry.class.getName(), getPrimaryKey());
453            }
454    
455            @Override
456            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
457                    ExpandoBridge expandoBridge = getExpandoBridge();
458    
459                    expandoBridge.setAttributes(serviceContext);
460            }
461    
462            @Override
463            public TrashEntry toEscapedModel() {
464                    if (_escapedModelProxy == null) {
465                            _escapedModelProxy = (TrashEntry)ProxyUtil.newProxyInstance(_classLoader,
466                                            _escapedModelProxyInterfaces,
467                                            new AutoEscapeBeanHandler(this));
468                    }
469    
470                    return _escapedModelProxy;
471            }
472    
473            @Override
474            public Object clone() {
475                    TrashEntryImpl trashEntryImpl = new TrashEntryImpl();
476    
477                    trashEntryImpl.setEntryId(getEntryId());
478                    trashEntryImpl.setGroupId(getGroupId());
479                    trashEntryImpl.setCompanyId(getCompanyId());
480                    trashEntryImpl.setUserId(getUserId());
481                    trashEntryImpl.setUserName(getUserName());
482                    trashEntryImpl.setCreateDate(getCreateDate());
483                    trashEntryImpl.setClassNameId(getClassNameId());
484                    trashEntryImpl.setClassPK(getClassPK());
485                    trashEntryImpl.setTypeSettings(getTypeSettings());
486                    trashEntryImpl.setStatus(getStatus());
487    
488                    trashEntryImpl.resetOriginalValues();
489    
490                    return trashEntryImpl;
491            }
492    
493            public int compareTo(TrashEntry trashEntry) {
494                    int value = 0;
495    
496                    value = DateUtil.compareTo(getCreateDate(), trashEntry.getCreateDate());
497    
498                    value = value * -1;
499    
500                    if (value != 0) {
501                            return value;
502                    }
503    
504                    return 0;
505            }
506    
507            @Override
508            public boolean equals(Object obj) {
509                    if (obj == null) {
510                            return false;
511                    }
512    
513                    TrashEntry trashEntry = null;
514    
515                    try {
516                            trashEntry = (TrashEntry)obj;
517                    }
518                    catch (ClassCastException cce) {
519                            return false;
520                    }
521    
522                    long primaryKey = trashEntry.getPrimaryKey();
523    
524                    if (getPrimaryKey() == primaryKey) {
525                            return true;
526                    }
527                    else {
528                            return false;
529                    }
530            }
531    
532            @Override
533            public int hashCode() {
534                    return (int)getPrimaryKey();
535            }
536    
537            @Override
538            public void resetOriginalValues() {
539                    TrashEntryModelImpl trashEntryModelImpl = this;
540    
541                    trashEntryModelImpl._originalGroupId = trashEntryModelImpl._groupId;
542    
543                    trashEntryModelImpl._setOriginalGroupId = false;
544    
545                    trashEntryModelImpl._originalCompanyId = trashEntryModelImpl._companyId;
546    
547                    trashEntryModelImpl._setOriginalCompanyId = false;
548    
549                    trashEntryModelImpl._originalCreateDate = trashEntryModelImpl._createDate;
550    
551                    trashEntryModelImpl._originalClassNameId = trashEntryModelImpl._classNameId;
552    
553                    trashEntryModelImpl._setOriginalClassNameId = false;
554    
555                    trashEntryModelImpl._originalClassPK = trashEntryModelImpl._classPK;
556    
557                    trashEntryModelImpl._setOriginalClassPK = false;
558    
559                    trashEntryModelImpl._columnBitmask = 0;
560            }
561    
562            @Override
563            public CacheModel<TrashEntry> toCacheModel() {
564                    TrashEntryCacheModel trashEntryCacheModel = new TrashEntryCacheModel();
565    
566                    trashEntryCacheModel.entryId = getEntryId();
567    
568                    trashEntryCacheModel.groupId = getGroupId();
569    
570                    trashEntryCacheModel.companyId = getCompanyId();
571    
572                    trashEntryCacheModel.userId = getUserId();
573    
574                    trashEntryCacheModel.userName = getUserName();
575    
576                    String userName = trashEntryCacheModel.userName;
577    
578                    if ((userName != null) && (userName.length() == 0)) {
579                            trashEntryCacheModel.userName = null;
580                    }
581    
582                    Date createDate = getCreateDate();
583    
584                    if (createDate != null) {
585                            trashEntryCacheModel.createDate = createDate.getTime();
586                    }
587                    else {
588                            trashEntryCacheModel.createDate = Long.MIN_VALUE;
589                    }
590    
591                    trashEntryCacheModel.classNameId = getClassNameId();
592    
593                    trashEntryCacheModel.classPK = getClassPK();
594    
595                    trashEntryCacheModel.typeSettings = getTypeSettings();
596    
597                    String typeSettings = trashEntryCacheModel.typeSettings;
598    
599                    if ((typeSettings != null) && (typeSettings.length() == 0)) {
600                            trashEntryCacheModel.typeSettings = null;
601                    }
602    
603                    trashEntryCacheModel.status = getStatus();
604    
605                    return trashEntryCacheModel;
606            }
607    
608            @Override
609            public String toString() {
610                    StringBundler sb = new StringBundler(21);
611    
612                    sb.append("{entryId=");
613                    sb.append(getEntryId());
614                    sb.append(", groupId=");
615                    sb.append(getGroupId());
616                    sb.append(", companyId=");
617                    sb.append(getCompanyId());
618                    sb.append(", userId=");
619                    sb.append(getUserId());
620                    sb.append(", userName=");
621                    sb.append(getUserName());
622                    sb.append(", createDate=");
623                    sb.append(getCreateDate());
624                    sb.append(", classNameId=");
625                    sb.append(getClassNameId());
626                    sb.append(", classPK=");
627                    sb.append(getClassPK());
628                    sb.append(", typeSettings=");
629                    sb.append(getTypeSettings());
630                    sb.append(", status=");
631                    sb.append(getStatus());
632                    sb.append("}");
633    
634                    return sb.toString();
635            }
636    
637            public String toXmlString() {
638                    StringBundler sb = new StringBundler(34);
639    
640                    sb.append("<model><model-name>");
641                    sb.append("com.liferay.portlet.trash.model.TrashEntry");
642                    sb.append("</model-name>");
643    
644                    sb.append(
645                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
646                    sb.append(getEntryId());
647                    sb.append("]]></column-value></column>");
648                    sb.append(
649                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
650                    sb.append(getGroupId());
651                    sb.append("]]></column-value></column>");
652                    sb.append(
653                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
654                    sb.append(getCompanyId());
655                    sb.append("]]></column-value></column>");
656                    sb.append(
657                            "<column><column-name>userId</column-name><column-value><![CDATA[");
658                    sb.append(getUserId());
659                    sb.append("]]></column-value></column>");
660                    sb.append(
661                            "<column><column-name>userName</column-name><column-value><![CDATA[");
662                    sb.append(getUserName());
663                    sb.append("]]></column-value></column>");
664                    sb.append(
665                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
666                    sb.append(getCreateDate());
667                    sb.append("]]></column-value></column>");
668                    sb.append(
669                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
670                    sb.append(getClassNameId());
671                    sb.append("]]></column-value></column>");
672                    sb.append(
673                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
674                    sb.append(getClassPK());
675                    sb.append("]]></column-value></column>");
676                    sb.append(
677                            "<column><column-name>typeSettings</column-name><column-value><![CDATA[");
678                    sb.append(getTypeSettings());
679                    sb.append("]]></column-value></column>");
680                    sb.append(
681                            "<column><column-name>status</column-name><column-value><![CDATA[");
682                    sb.append(getStatus());
683                    sb.append("]]></column-value></column>");
684    
685                    sb.append("</model>");
686    
687                    return sb.toString();
688            }
689    
690            private static ClassLoader _classLoader = TrashEntry.class.getClassLoader();
691            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
692                            TrashEntry.class
693                    };
694            private long _entryId;
695            private long _groupId;
696            private long _originalGroupId;
697            private boolean _setOriginalGroupId;
698            private long _companyId;
699            private long _originalCompanyId;
700            private boolean _setOriginalCompanyId;
701            private long _userId;
702            private String _userUuid;
703            private String _userName;
704            private Date _createDate;
705            private Date _originalCreateDate;
706            private long _classNameId;
707            private long _originalClassNameId;
708            private boolean _setOriginalClassNameId;
709            private long _classPK;
710            private long _originalClassPK;
711            private boolean _setOriginalClassPK;
712            private String _typeSettings;
713            private int _status;
714            private long _columnBitmask;
715            private TrashEntry _escapedModelProxy;
716    }