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.portal.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.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.PasswordTracker;
026    import com.liferay.portal.model.PasswordTrackerModel;
027    import com.liferay.portal.service.ServiceContext;
028    import com.liferay.portal.util.PortalUtil;
029    
030    import com.liferay.portlet.expando.model.ExpandoBridge;
031    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.Date;
038    
039    /**
040     * 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.
041     *
042     * <p>
043     * 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}.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see PasswordTrackerImpl
048     * @see com.liferay.portal.model.PasswordTracker
049     * @see com.liferay.portal.model.PasswordTrackerModel
050     * @generated
051     */
052    public class PasswordTrackerModelImpl extends BaseModelImpl<PasswordTracker>
053            implements PasswordTrackerModel {
054            /*
055             * NOTE FOR DEVELOPERS:
056             *
057             * 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.
058             */
059            public static final String TABLE_NAME = "PasswordTracker";
060            public static final Object[][] TABLE_COLUMNS = {
061                            { "passwordTrackerId", Types.BIGINT },
062                            { "userId", Types.BIGINT },
063                            { "createDate", Types.TIMESTAMP },
064                            { "password_", Types.VARCHAR }
065                    };
066            public static final String TABLE_SQL_CREATE = "create table PasswordTracker (passwordTrackerId LONG not null primary key,userId LONG,createDate DATE null,password_ VARCHAR(75) null)";
067            public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
068            public static final String ORDER_BY_JPQL = " ORDER BY passwordTracker.userId DESC, passwordTracker.createDate DESC";
069            public static final String ORDER_BY_SQL = " ORDER BY PasswordTracker.userId DESC, PasswordTracker.createDate DESC";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordTracker"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
078                            true);
079            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PasswordTracker"),
081                            true);
082            public static long USERID_COLUMN_BITMASK = 1L;
083            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
084                                    "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
085    
086            public PasswordTrackerModelImpl() {
087            }
088    
089            public long getPrimaryKey() {
090                    return _passwordTrackerId;
091            }
092    
093            public void setPrimaryKey(long primaryKey) {
094                    setPasswordTrackerId(primaryKey);
095            }
096    
097            public Serializable getPrimaryKeyObj() {
098                    return new Long(_passwordTrackerId);
099            }
100    
101            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
102                    setPrimaryKey(((Long)primaryKeyObj).longValue());
103            }
104    
105            public Class<?> getModelClass() {
106                    return PasswordTracker.class;
107            }
108    
109            public String getModelClassName() {
110                    return PasswordTracker.class.getName();
111            }
112    
113            public long getPasswordTrackerId() {
114                    return _passwordTrackerId;
115            }
116    
117            public void setPasswordTrackerId(long passwordTrackerId) {
118                    _passwordTrackerId = passwordTrackerId;
119            }
120    
121            public long getUserId() {
122                    return _userId;
123            }
124    
125            public void setUserId(long userId) {
126                    _columnBitmask = -1L;
127    
128                    if (!_setOriginalUserId) {
129                            _setOriginalUserId = true;
130    
131                            _originalUserId = _userId;
132                    }
133    
134                    _userId = userId;
135            }
136    
137            public String getUserUuid() throws SystemException {
138                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
139            }
140    
141            public void setUserUuid(String userUuid) {
142                    _userUuid = userUuid;
143            }
144    
145            public long getOriginalUserId() {
146                    return _originalUserId;
147            }
148    
149            public Date getCreateDate() {
150                    return _createDate;
151            }
152    
153            public void setCreateDate(Date createDate) {
154                    _columnBitmask = -1L;
155    
156                    _createDate = createDate;
157            }
158    
159            public String getPassword() {
160                    if (_password == null) {
161                            return StringPool.BLANK;
162                    }
163                    else {
164                            return _password;
165                    }
166            }
167    
168            public void setPassword(String password) {
169                    _password = password;
170            }
171    
172            public long getColumnBitmask() {
173                    return _columnBitmask;
174            }
175    
176            @Override
177            public PasswordTracker toEscapedModel() {
178                    if (_escapedModelProxy == null) {
179                            _escapedModelProxy = (PasswordTracker)ProxyUtil.newProxyInstance(_classLoader,
180                                            _escapedModelProxyInterfaces,
181                                            new AutoEscapeBeanHandler(this));
182                    }
183    
184                    return _escapedModelProxy;
185            }
186    
187            @Override
188            public ExpandoBridge getExpandoBridge() {
189                    if (_expandoBridge == null) {
190                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
191                                            PasswordTracker.class.getName(), getPrimaryKey());
192                    }
193    
194                    return _expandoBridge;
195            }
196    
197            @Override
198            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
199                    getExpandoBridge().setAttributes(serviceContext);
200            }
201    
202            @Override
203            public Object clone() {
204                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
205    
206                    passwordTrackerImpl.setPasswordTrackerId(getPasswordTrackerId());
207                    passwordTrackerImpl.setUserId(getUserId());
208                    passwordTrackerImpl.setCreateDate(getCreateDate());
209                    passwordTrackerImpl.setPassword(getPassword());
210    
211                    passwordTrackerImpl.resetOriginalValues();
212    
213                    return passwordTrackerImpl;
214            }
215    
216            public int compareTo(PasswordTracker passwordTracker) {
217                    int value = 0;
218    
219                    if (getUserId() < passwordTracker.getUserId()) {
220                            value = -1;
221                    }
222                    else if (getUserId() > passwordTracker.getUserId()) {
223                            value = 1;
224                    }
225                    else {
226                            value = 0;
227                    }
228    
229                    value = value * -1;
230    
231                    if (value != 0) {
232                            return value;
233                    }
234    
235                    value = DateUtil.compareTo(getCreateDate(),
236                                    passwordTracker.getCreateDate());
237    
238                    value = value * -1;
239    
240                    if (value != 0) {
241                            return value;
242                    }
243    
244                    return 0;
245            }
246    
247            @Override
248            public boolean equals(Object obj) {
249                    if (obj == null) {
250                            return false;
251                    }
252    
253                    PasswordTracker passwordTracker = null;
254    
255                    try {
256                            passwordTracker = (PasswordTracker)obj;
257                    }
258                    catch (ClassCastException cce) {
259                            return false;
260                    }
261    
262                    long primaryKey = passwordTracker.getPrimaryKey();
263    
264                    if (getPrimaryKey() == primaryKey) {
265                            return true;
266                    }
267                    else {
268                            return false;
269                    }
270            }
271    
272            @Override
273            public int hashCode() {
274                    return (int)getPrimaryKey();
275            }
276    
277            @Override
278            public void resetOriginalValues() {
279                    PasswordTrackerModelImpl passwordTrackerModelImpl = this;
280    
281                    passwordTrackerModelImpl._originalUserId = passwordTrackerModelImpl._userId;
282    
283                    passwordTrackerModelImpl._setOriginalUserId = false;
284    
285                    passwordTrackerModelImpl._columnBitmask = 0;
286            }
287    
288            @Override
289            public CacheModel<PasswordTracker> toCacheModel() {
290                    PasswordTrackerCacheModel passwordTrackerCacheModel = new PasswordTrackerCacheModel();
291    
292                    passwordTrackerCacheModel.passwordTrackerId = getPasswordTrackerId();
293    
294                    passwordTrackerCacheModel.userId = getUserId();
295    
296                    Date createDate = getCreateDate();
297    
298                    if (createDate != null) {
299                            passwordTrackerCacheModel.createDate = createDate.getTime();
300                    }
301                    else {
302                            passwordTrackerCacheModel.createDate = Long.MIN_VALUE;
303                    }
304    
305                    passwordTrackerCacheModel.password = getPassword();
306    
307                    String password = passwordTrackerCacheModel.password;
308    
309                    if ((password != null) && (password.length() == 0)) {
310                            passwordTrackerCacheModel.password = null;
311                    }
312    
313                    return passwordTrackerCacheModel;
314            }
315    
316            @Override
317            public String toString() {
318                    StringBundler sb = new StringBundler(9);
319    
320                    sb.append("{passwordTrackerId=");
321                    sb.append(getPasswordTrackerId());
322                    sb.append(", userId=");
323                    sb.append(getUserId());
324                    sb.append(", createDate=");
325                    sb.append(getCreateDate());
326                    sb.append(", password=");
327                    sb.append(getPassword());
328                    sb.append("}");
329    
330                    return sb.toString();
331            }
332    
333            public String toXmlString() {
334                    StringBundler sb = new StringBundler(16);
335    
336                    sb.append("<model><model-name>");
337                    sb.append("com.liferay.portal.model.PasswordTracker");
338                    sb.append("</model-name>");
339    
340                    sb.append(
341                            "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
342                    sb.append(getPasswordTrackerId());
343                    sb.append("]]></column-value></column>");
344                    sb.append(
345                            "<column><column-name>userId</column-name><column-value><![CDATA[");
346                    sb.append(getUserId());
347                    sb.append("]]></column-value></column>");
348                    sb.append(
349                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
350                    sb.append(getCreateDate());
351                    sb.append("]]></column-value></column>");
352                    sb.append(
353                            "<column><column-name>password</column-name><column-value><![CDATA[");
354                    sb.append(getPassword());
355                    sb.append("]]></column-value></column>");
356    
357                    sb.append("</model>");
358    
359                    return sb.toString();
360            }
361    
362            private static ClassLoader _classLoader = PasswordTracker.class.getClassLoader();
363            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
364                            PasswordTracker.class
365                    };
366            private long _passwordTrackerId;
367            private long _userId;
368            private String _userUuid;
369            private long _originalUserId;
370            private boolean _setOriginalUserId;
371            private Date _createDate;
372            private String _password;
373            private transient ExpandoBridge _expandoBridge;
374            private long _columnBitmask;
375            private PasswordTracker _escapedModelProxy;
376    }