001    /**
002     * Copyright (c) 2000-present 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.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.exception.PortalException;
021    import com.liferay.portal.kernel.util.DateUtil;
022    import com.liferay.portal.kernel.util.GetterUtil;
023    import com.liferay.portal.kernel.util.ProxyUtil;
024    import com.liferay.portal.kernel.util.StringBundler;
025    import com.liferay.portal.kernel.util.StringPool;
026    import com.liferay.portal.model.CacheModel;
027    import com.liferay.portal.model.PasswordTracker;
028    import com.liferay.portal.model.PasswordTrackerModel;
029    import com.liferay.portal.model.User;
030    import com.liferay.portal.service.ServiceContext;
031    import com.liferay.portal.service.UserLocalServiceUtil;
032    
033    import com.liferay.portlet.expando.model.ExpandoBridge;
034    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
035    
036    import java.io.Serializable;
037    
038    import java.sql.Types;
039    
040    import java.util.Date;
041    import java.util.HashMap;
042    import java.util.Map;
043    
044    /**
045     * The base model implementation for the PasswordTracker service. Represents a row in the "PasswordTracker" database table, with each column mapped to a property of this class.
046     *
047     * <p>
048     * This implementation and its corresponding interface {@link com.liferay.portal.model.PasswordTrackerModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PasswordTrackerImpl}.
049     * </p>
050     *
051     * @author Brian Wing Shun Chan
052     * @see PasswordTrackerImpl
053     * @see com.liferay.portal.model.PasswordTracker
054     * @see com.liferay.portal.model.PasswordTrackerModel
055     * @generated
056     */
057    @ProviderType
058    public class PasswordTrackerModelImpl extends BaseModelImpl<PasswordTracker>
059            implements PasswordTrackerModel {
060            /*
061             * NOTE FOR DEVELOPERS:
062             *
063             * Never modify or reference this class directly. All methods that expect a password tracker model instance should use the {@link com.liferay.portal.model.PasswordTracker} interface instead.
064             */
065            public static final String TABLE_NAME = "PasswordTracker";
066            public static final Object[][] TABLE_COLUMNS = {
067                            { "mvccVersion", Types.BIGINT },
068                            { "passwordTrackerId", Types.BIGINT },
069                            { "userId", Types.BIGINT },
070                            { "createDate", Types.TIMESTAMP },
071                            { "password_", Types.VARCHAR }
072                    };
073            public static final String TABLE_SQL_CREATE = "create table PasswordTracker (mvccVersion LONG default 0,passwordTrackerId LONG not null primary key,userId LONG,createDate DATE null,password_ VARCHAR(75) null)";
074            public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
075            public static final String ORDER_BY_JPQL = " ORDER BY passwordTracker.userId DESC, passwordTracker.createDate DESC";
076            public static final String ORDER_BY_SQL = " ORDER BY PasswordTracker.userId DESC, PasswordTracker.createDate DESC";
077            public static final String DATA_SOURCE = "liferayDataSource";
078            public static final String SESSION_FACTORY = "liferaySessionFactory";
079            public static final String TX_MANAGER = "liferayTransactionManager";
080            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordTracker"),
082                            true);
083            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
085                            true);
086            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PasswordTracker"),
088                            true);
089            public static final long USERID_COLUMN_BITMASK = 1L;
090            public static final long CREATEDATE_COLUMN_BITMASK = 2L;
091            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
092                                    "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
093    
094            public PasswordTrackerModelImpl() {
095            }
096    
097            @Override
098            public long getPrimaryKey() {
099                    return _passwordTrackerId;
100            }
101    
102            @Override
103            public void setPrimaryKey(long primaryKey) {
104                    setPasswordTrackerId(primaryKey);
105            }
106    
107            @Override
108            public Serializable getPrimaryKeyObj() {
109                    return _passwordTrackerId;
110            }
111    
112            @Override
113            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
114                    setPrimaryKey(((Long)primaryKeyObj).longValue());
115            }
116    
117            @Override
118            public Class<?> getModelClass() {
119                    return PasswordTracker.class;
120            }
121    
122            @Override
123            public String getModelClassName() {
124                    return PasswordTracker.class.getName();
125            }
126    
127            @Override
128            public Map<String, Object> getModelAttributes() {
129                    Map<String, Object> attributes = new HashMap<String, Object>();
130    
131                    attributes.put("mvccVersion", getMvccVersion());
132                    attributes.put("passwordTrackerId", getPasswordTrackerId());
133                    attributes.put("userId", getUserId());
134                    attributes.put("createDate", getCreateDate());
135                    attributes.put("password", getPassword());
136    
137                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
138                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
139    
140                    return attributes;
141            }
142    
143            @Override
144            public void setModelAttributes(Map<String, Object> attributes) {
145                    Long mvccVersion = (Long)attributes.get("mvccVersion");
146    
147                    if (mvccVersion != null) {
148                            setMvccVersion(mvccVersion);
149                    }
150    
151                    Long passwordTrackerId = (Long)attributes.get("passwordTrackerId");
152    
153                    if (passwordTrackerId != null) {
154                            setPasswordTrackerId(passwordTrackerId);
155                    }
156    
157                    Long userId = (Long)attributes.get("userId");
158    
159                    if (userId != null) {
160                            setUserId(userId);
161                    }
162    
163                    Date createDate = (Date)attributes.get("createDate");
164    
165                    if (createDate != null) {
166                            setCreateDate(createDate);
167                    }
168    
169                    String password = (String)attributes.get("password");
170    
171                    if (password != null) {
172                            setPassword(password);
173                    }
174            }
175    
176            @Override
177            public long getMvccVersion() {
178                    return _mvccVersion;
179            }
180    
181            @Override
182            public void setMvccVersion(long mvccVersion) {
183                    _mvccVersion = mvccVersion;
184            }
185    
186            @Override
187            public long getPasswordTrackerId() {
188                    return _passwordTrackerId;
189            }
190    
191            @Override
192            public void setPasswordTrackerId(long passwordTrackerId) {
193                    _passwordTrackerId = passwordTrackerId;
194            }
195    
196            @Override
197            public long getUserId() {
198                    return _userId;
199            }
200    
201            @Override
202            public void setUserId(long userId) {
203                    _columnBitmask = -1L;
204    
205                    if (!_setOriginalUserId) {
206                            _setOriginalUserId = true;
207    
208                            _originalUserId = _userId;
209                    }
210    
211                    _userId = userId;
212            }
213    
214            @Override
215            public String getUserUuid() {
216                    try {
217                            User user = UserLocalServiceUtil.getUserById(getUserId());
218    
219                            return user.getUuid();
220                    }
221                    catch (PortalException pe) {
222                            return StringPool.BLANK;
223                    }
224            }
225    
226            @Override
227            public void setUserUuid(String userUuid) {
228            }
229    
230            public long getOriginalUserId() {
231                    return _originalUserId;
232            }
233    
234            @Override
235            public Date getCreateDate() {
236                    return _createDate;
237            }
238    
239            @Override
240            public void setCreateDate(Date createDate) {
241                    _columnBitmask = -1L;
242    
243                    _createDate = createDate;
244            }
245    
246            @Override
247            public String getPassword() {
248                    if (_password == null) {
249                            return StringPool.BLANK;
250                    }
251                    else {
252                            return _password;
253                    }
254            }
255    
256            @Override
257            public void setPassword(String password) {
258                    _password = password;
259            }
260    
261            public long getColumnBitmask() {
262                    return _columnBitmask;
263            }
264    
265            @Override
266            public ExpandoBridge getExpandoBridge() {
267                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
268                            PasswordTracker.class.getName(), getPrimaryKey());
269            }
270    
271            @Override
272            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
273                    ExpandoBridge expandoBridge = getExpandoBridge();
274    
275                    expandoBridge.setAttributes(serviceContext);
276            }
277    
278            @Override
279            public PasswordTracker toEscapedModel() {
280                    if (_escapedModel == null) {
281                            _escapedModel = (PasswordTracker)ProxyUtil.newProxyInstance(_classLoader,
282                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
283                    }
284    
285                    return _escapedModel;
286            }
287    
288            @Override
289            public Object clone() {
290                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
291    
292                    passwordTrackerImpl.setMvccVersion(getMvccVersion());
293                    passwordTrackerImpl.setPasswordTrackerId(getPasswordTrackerId());
294                    passwordTrackerImpl.setUserId(getUserId());
295                    passwordTrackerImpl.setCreateDate(getCreateDate());
296                    passwordTrackerImpl.setPassword(getPassword());
297    
298                    passwordTrackerImpl.resetOriginalValues();
299    
300                    return passwordTrackerImpl;
301            }
302    
303            @Override
304            public int compareTo(PasswordTracker passwordTracker) {
305                    int value = 0;
306    
307                    if (getUserId() < passwordTracker.getUserId()) {
308                            value = -1;
309                    }
310                    else if (getUserId() > passwordTracker.getUserId()) {
311                            value = 1;
312                    }
313                    else {
314                            value = 0;
315                    }
316    
317                    value = value * -1;
318    
319                    if (value != 0) {
320                            return value;
321                    }
322    
323                    value = DateUtil.compareTo(getCreateDate(),
324                                    passwordTracker.getCreateDate());
325    
326                    value = value * -1;
327    
328                    if (value != 0) {
329                            return value;
330                    }
331    
332                    return 0;
333            }
334    
335            @Override
336            public boolean equals(Object obj) {
337                    if (this == obj) {
338                            return true;
339                    }
340    
341                    if (!(obj instanceof PasswordTracker)) {
342                            return false;
343                    }
344    
345                    PasswordTracker passwordTracker = (PasswordTracker)obj;
346    
347                    long primaryKey = passwordTracker.getPrimaryKey();
348    
349                    if (getPrimaryKey() == primaryKey) {
350                            return true;
351                    }
352                    else {
353                            return false;
354                    }
355            }
356    
357            @Override
358            public int hashCode() {
359                    return (int)getPrimaryKey();
360            }
361    
362            @Override
363            public boolean isEntityCacheEnabled() {
364                    return ENTITY_CACHE_ENABLED;
365            }
366    
367            @Override
368            public boolean isFinderCacheEnabled() {
369                    return FINDER_CACHE_ENABLED;
370            }
371    
372            @Override
373            public void resetOriginalValues() {
374                    PasswordTrackerModelImpl passwordTrackerModelImpl = this;
375    
376                    passwordTrackerModelImpl._originalUserId = passwordTrackerModelImpl._userId;
377    
378                    passwordTrackerModelImpl._setOriginalUserId = false;
379    
380                    passwordTrackerModelImpl._columnBitmask = 0;
381            }
382    
383            @Override
384            public CacheModel<PasswordTracker> toCacheModel() {
385                    PasswordTrackerCacheModel passwordTrackerCacheModel = new PasswordTrackerCacheModel();
386    
387                    passwordTrackerCacheModel.mvccVersion = getMvccVersion();
388    
389                    passwordTrackerCacheModel.passwordTrackerId = getPasswordTrackerId();
390    
391                    passwordTrackerCacheModel.userId = getUserId();
392    
393                    Date createDate = getCreateDate();
394    
395                    if (createDate != null) {
396                            passwordTrackerCacheModel.createDate = createDate.getTime();
397                    }
398                    else {
399                            passwordTrackerCacheModel.createDate = Long.MIN_VALUE;
400                    }
401    
402                    passwordTrackerCacheModel.password = getPassword();
403    
404                    String password = passwordTrackerCacheModel.password;
405    
406                    if ((password != null) && (password.length() == 0)) {
407                            passwordTrackerCacheModel.password = null;
408                    }
409    
410                    return passwordTrackerCacheModel;
411            }
412    
413            @Override
414            public String toString() {
415                    StringBundler sb = new StringBundler(11);
416    
417                    sb.append("{mvccVersion=");
418                    sb.append(getMvccVersion());
419                    sb.append(", passwordTrackerId=");
420                    sb.append(getPasswordTrackerId());
421                    sb.append(", userId=");
422                    sb.append(getUserId());
423                    sb.append(", createDate=");
424                    sb.append(getCreateDate());
425                    sb.append(", password=");
426                    sb.append(getPassword());
427                    sb.append("}");
428    
429                    return sb.toString();
430            }
431    
432            @Override
433            public String toXmlString() {
434                    StringBundler sb = new StringBundler(19);
435    
436                    sb.append("<model><model-name>");
437                    sb.append("com.liferay.portal.model.PasswordTracker");
438                    sb.append("</model-name>");
439    
440                    sb.append(
441                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
442                    sb.append(getMvccVersion());
443                    sb.append("]]></column-value></column>");
444                    sb.append(
445                            "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
446                    sb.append(getPasswordTrackerId());
447                    sb.append("]]></column-value></column>");
448                    sb.append(
449                            "<column><column-name>userId</column-name><column-value><![CDATA[");
450                    sb.append(getUserId());
451                    sb.append("]]></column-value></column>");
452                    sb.append(
453                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
454                    sb.append(getCreateDate());
455                    sb.append("]]></column-value></column>");
456                    sb.append(
457                            "<column><column-name>password</column-name><column-value><![CDATA[");
458                    sb.append(getPassword());
459                    sb.append("]]></column-value></column>");
460    
461                    sb.append("</model>");
462    
463                    return sb.toString();
464            }
465    
466            private static final ClassLoader _classLoader = PasswordTracker.class.getClassLoader();
467            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
468                            PasswordTracker.class
469                    };
470            private long _mvccVersion;
471            private long _passwordTrackerId;
472            private long _userId;
473            private long _originalUserId;
474            private boolean _setOriginalUserId;
475            private Date _createDate;
476            private String _password;
477            private long _columnBitmask;
478            private PasswordTracker _escapedModel;
479    }