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 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 PasswordTracker
054     * @see 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 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 Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
074    
075            static {
076                    TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
077                    TABLE_COLUMNS_MAP.put("passwordTrackerId", Types.BIGINT);
078                    TABLE_COLUMNS_MAP.put("userId", Types.BIGINT);
079                    TABLE_COLUMNS_MAP.put("createDate", Types.TIMESTAMP);
080                    TABLE_COLUMNS_MAP.put("password_", Types.VARCHAR);
081            }
082    
083            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)";
084            public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
085            public static final String ORDER_BY_JPQL = " ORDER BY passwordTracker.userId DESC, passwordTracker.createDate DESC";
086            public static final String ORDER_BY_SQL = " ORDER BY PasswordTracker.userId DESC, PasswordTracker.createDate DESC";
087            public static final String DATA_SOURCE = "liferayDataSource";
088            public static final String SESSION_FACTORY = "liferaySessionFactory";
089            public static final String TX_MANAGER = "liferayTransactionManager";
090            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordTracker"),
092                            true);
093            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
095                            true);
096            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
097                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PasswordTracker"),
098                            true);
099            public static final long USERID_COLUMN_BITMASK = 1L;
100            public static final long CREATEDATE_COLUMN_BITMASK = 2L;
101            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102                                    "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
103    
104            public PasswordTrackerModelImpl() {
105            }
106    
107            @Override
108            public long getPrimaryKey() {
109                    return _passwordTrackerId;
110            }
111    
112            @Override
113            public void setPrimaryKey(long primaryKey) {
114                    setPasswordTrackerId(primaryKey);
115            }
116    
117            @Override
118            public Serializable getPrimaryKeyObj() {
119                    return _passwordTrackerId;
120            }
121    
122            @Override
123            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
124                    setPrimaryKey(((Long)primaryKeyObj).longValue());
125            }
126    
127            @Override
128            public Class<?> getModelClass() {
129                    return PasswordTracker.class;
130            }
131    
132            @Override
133            public String getModelClassName() {
134                    return PasswordTracker.class.getName();
135            }
136    
137            @Override
138            public Map<String, Object> getModelAttributes() {
139                    Map<String, Object> attributes = new HashMap<String, Object>();
140    
141                    attributes.put("mvccVersion", getMvccVersion());
142                    attributes.put("passwordTrackerId", getPasswordTrackerId());
143                    attributes.put("userId", getUserId());
144                    attributes.put("createDate", getCreateDate());
145                    attributes.put("password", getPassword());
146    
147                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
148                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
149    
150                    return attributes;
151            }
152    
153            @Override
154            public void setModelAttributes(Map<String, Object> attributes) {
155                    Long mvccVersion = (Long)attributes.get("mvccVersion");
156    
157                    if (mvccVersion != null) {
158                            setMvccVersion(mvccVersion);
159                    }
160    
161                    Long passwordTrackerId = (Long)attributes.get("passwordTrackerId");
162    
163                    if (passwordTrackerId != null) {
164                            setPasswordTrackerId(passwordTrackerId);
165                    }
166    
167                    Long userId = (Long)attributes.get("userId");
168    
169                    if (userId != null) {
170                            setUserId(userId);
171                    }
172    
173                    Date createDate = (Date)attributes.get("createDate");
174    
175                    if (createDate != null) {
176                            setCreateDate(createDate);
177                    }
178    
179                    String password = (String)attributes.get("password");
180    
181                    if (password != null) {
182                            setPassword(password);
183                    }
184            }
185    
186            @Override
187            public long getMvccVersion() {
188                    return _mvccVersion;
189            }
190    
191            @Override
192            public void setMvccVersion(long mvccVersion) {
193                    _mvccVersion = mvccVersion;
194            }
195    
196            @Override
197            public long getPasswordTrackerId() {
198                    return _passwordTrackerId;
199            }
200    
201            @Override
202            public void setPasswordTrackerId(long passwordTrackerId) {
203                    _passwordTrackerId = passwordTrackerId;
204            }
205    
206            @Override
207            public long getUserId() {
208                    return _userId;
209            }
210    
211            @Override
212            public void setUserId(long userId) {
213                    _columnBitmask = -1L;
214    
215                    if (!_setOriginalUserId) {
216                            _setOriginalUserId = true;
217    
218                            _originalUserId = _userId;
219                    }
220    
221                    _userId = userId;
222            }
223    
224            @Override
225            public String getUserUuid() {
226                    try {
227                            User user = UserLocalServiceUtil.getUserById(getUserId());
228    
229                            return user.getUuid();
230                    }
231                    catch (PortalException pe) {
232                            return StringPool.BLANK;
233                    }
234            }
235    
236            @Override
237            public void setUserUuid(String userUuid) {
238            }
239    
240            public long getOriginalUserId() {
241                    return _originalUserId;
242            }
243    
244            @Override
245            public Date getCreateDate() {
246                    return _createDate;
247            }
248    
249            @Override
250            public void setCreateDate(Date createDate) {
251                    _columnBitmask = -1L;
252    
253                    _createDate = createDate;
254            }
255    
256            @Override
257            public String getPassword() {
258                    if (_password == null) {
259                            return StringPool.BLANK;
260                    }
261                    else {
262                            return _password;
263                    }
264            }
265    
266            @Override
267            public void setPassword(String password) {
268                    _password = password;
269            }
270    
271            public long getColumnBitmask() {
272                    return _columnBitmask;
273            }
274    
275            @Override
276            public ExpandoBridge getExpandoBridge() {
277                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
278                            PasswordTracker.class.getName(), getPrimaryKey());
279            }
280    
281            @Override
282            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
283                    ExpandoBridge expandoBridge = getExpandoBridge();
284    
285                    expandoBridge.setAttributes(serviceContext);
286            }
287    
288            @Override
289            public PasswordTracker toEscapedModel() {
290                    if (_escapedModel == null) {
291                            _escapedModel = (PasswordTracker)ProxyUtil.newProxyInstance(_classLoader,
292                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
293                    }
294    
295                    return _escapedModel;
296            }
297    
298            @Override
299            public Object clone() {
300                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
301    
302                    passwordTrackerImpl.setMvccVersion(getMvccVersion());
303                    passwordTrackerImpl.setPasswordTrackerId(getPasswordTrackerId());
304                    passwordTrackerImpl.setUserId(getUserId());
305                    passwordTrackerImpl.setCreateDate(getCreateDate());
306                    passwordTrackerImpl.setPassword(getPassword());
307    
308                    passwordTrackerImpl.resetOriginalValues();
309    
310                    return passwordTrackerImpl;
311            }
312    
313            @Override
314            public int compareTo(PasswordTracker passwordTracker) {
315                    int value = 0;
316    
317                    if (getUserId() < passwordTracker.getUserId()) {
318                            value = -1;
319                    }
320                    else if (getUserId() > passwordTracker.getUserId()) {
321                            value = 1;
322                    }
323                    else {
324                            value = 0;
325                    }
326    
327                    value = value * -1;
328    
329                    if (value != 0) {
330                            return value;
331                    }
332    
333                    value = DateUtil.compareTo(getCreateDate(),
334                                    passwordTracker.getCreateDate());
335    
336                    value = value * -1;
337    
338                    if (value != 0) {
339                            return value;
340                    }
341    
342                    return 0;
343            }
344    
345            @Override
346            public boolean equals(Object obj) {
347                    if (this == obj) {
348                            return true;
349                    }
350    
351                    if (!(obj instanceof PasswordTracker)) {
352                            return false;
353                    }
354    
355                    PasswordTracker passwordTracker = (PasswordTracker)obj;
356    
357                    long primaryKey = passwordTracker.getPrimaryKey();
358    
359                    if (getPrimaryKey() == primaryKey) {
360                            return true;
361                    }
362                    else {
363                            return false;
364                    }
365            }
366    
367            @Override
368            public int hashCode() {
369                    return (int)getPrimaryKey();
370            }
371    
372            @Override
373            public boolean isEntityCacheEnabled() {
374                    return ENTITY_CACHE_ENABLED;
375            }
376    
377            @Override
378            public boolean isFinderCacheEnabled() {
379                    return FINDER_CACHE_ENABLED;
380            }
381    
382            @Override
383            public void resetOriginalValues() {
384                    PasswordTrackerModelImpl passwordTrackerModelImpl = this;
385    
386                    passwordTrackerModelImpl._originalUserId = passwordTrackerModelImpl._userId;
387    
388                    passwordTrackerModelImpl._setOriginalUserId = false;
389    
390                    passwordTrackerModelImpl._columnBitmask = 0;
391            }
392    
393            @Override
394            public CacheModel<PasswordTracker> toCacheModel() {
395                    PasswordTrackerCacheModel passwordTrackerCacheModel = new PasswordTrackerCacheModel();
396    
397                    passwordTrackerCacheModel.mvccVersion = getMvccVersion();
398    
399                    passwordTrackerCacheModel.passwordTrackerId = getPasswordTrackerId();
400    
401                    passwordTrackerCacheModel.userId = getUserId();
402    
403                    Date createDate = getCreateDate();
404    
405                    if (createDate != null) {
406                            passwordTrackerCacheModel.createDate = createDate.getTime();
407                    }
408                    else {
409                            passwordTrackerCacheModel.createDate = Long.MIN_VALUE;
410                    }
411    
412                    passwordTrackerCacheModel.password = getPassword();
413    
414                    String password = passwordTrackerCacheModel.password;
415    
416                    if ((password != null) && (password.length() == 0)) {
417                            passwordTrackerCacheModel.password = null;
418                    }
419    
420                    return passwordTrackerCacheModel;
421            }
422    
423            @Override
424            public String toString() {
425                    StringBundler sb = new StringBundler(11);
426    
427                    sb.append("{mvccVersion=");
428                    sb.append(getMvccVersion());
429                    sb.append(", passwordTrackerId=");
430                    sb.append(getPasswordTrackerId());
431                    sb.append(", userId=");
432                    sb.append(getUserId());
433                    sb.append(", createDate=");
434                    sb.append(getCreateDate());
435                    sb.append(", password=");
436                    sb.append(getPassword());
437                    sb.append("}");
438    
439                    return sb.toString();
440            }
441    
442            @Override
443            public String toXmlString() {
444                    StringBundler sb = new StringBundler(19);
445    
446                    sb.append("<model><model-name>");
447                    sb.append("com.liferay.portal.model.PasswordTracker");
448                    sb.append("</model-name>");
449    
450                    sb.append(
451                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
452                    sb.append(getMvccVersion());
453                    sb.append("]]></column-value></column>");
454                    sb.append(
455                            "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
456                    sb.append(getPasswordTrackerId());
457                    sb.append("]]></column-value></column>");
458                    sb.append(
459                            "<column><column-name>userId</column-name><column-value><![CDATA[");
460                    sb.append(getUserId());
461                    sb.append("]]></column-value></column>");
462                    sb.append(
463                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
464                    sb.append(getCreateDate());
465                    sb.append("]]></column-value></column>");
466                    sb.append(
467                            "<column><column-name>password</column-name><column-value><![CDATA[");
468                    sb.append(getPassword());
469                    sb.append("]]></column-value></column>");
470    
471                    sb.append("</model>");
472    
473                    return sb.toString();
474            }
475    
476            private static final ClassLoader _classLoader = PasswordTracker.class.getClassLoader();
477            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
478                            PasswordTracker.class
479                    };
480            private long _mvccVersion;
481            private long _passwordTrackerId;
482            private long _userId;
483            private long _originalUserId;
484            private boolean _setOriginalUserId;
485            private Date _createDate;
486            private String _password;
487            private long _columnBitmask;
488            private PasswordTracker _escapedModel;
489    }