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