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