001    /**
002     * Copyright (c) 2000-2013 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 final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
086                                    "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
087    
088            public PasswordTrackerModelImpl() {
089            }
090    
091            public long getPrimaryKey() {
092                    return _passwordTrackerId;
093            }
094    
095            public void setPrimaryKey(long primaryKey) {
096                    setPasswordTrackerId(primaryKey);
097            }
098    
099            public Serializable getPrimaryKeyObj() {
100                    return new Long(_passwordTrackerId);
101            }
102    
103            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
104                    setPrimaryKey(((Long)primaryKeyObj).longValue());
105            }
106    
107            public Class<?> getModelClass() {
108                    return PasswordTracker.class;
109            }
110    
111            public String getModelClassName() {
112                    return PasswordTracker.class.getName();
113            }
114    
115            @Override
116            public Map<String, Object> getModelAttributes() {
117                    Map<String, Object> attributes = new HashMap<String, Object>();
118    
119                    attributes.put("passwordTrackerId", getPasswordTrackerId());
120                    attributes.put("userId", getUserId());
121                    attributes.put("createDate", getCreateDate());
122                    attributes.put("password", getPassword());
123    
124                    return attributes;
125            }
126    
127            @Override
128            public void setModelAttributes(Map<String, Object> attributes) {
129                    Long passwordTrackerId = (Long)attributes.get("passwordTrackerId");
130    
131                    if (passwordTrackerId != null) {
132                            setPasswordTrackerId(passwordTrackerId);
133                    }
134    
135                    Long userId = (Long)attributes.get("userId");
136    
137                    if (userId != null) {
138                            setUserId(userId);
139                    }
140    
141                    Date createDate = (Date)attributes.get("createDate");
142    
143                    if (createDate != null) {
144                            setCreateDate(createDate);
145                    }
146    
147                    String password = (String)attributes.get("password");
148    
149                    if (password != null) {
150                            setPassword(password);
151                    }
152            }
153    
154            public long getPasswordTrackerId() {
155                    return _passwordTrackerId;
156            }
157    
158            public void setPasswordTrackerId(long passwordTrackerId) {
159                    _passwordTrackerId = passwordTrackerId;
160            }
161    
162            public long getUserId() {
163                    return _userId;
164            }
165    
166            public void setUserId(long userId) {
167                    _columnBitmask = -1L;
168    
169                    if (!_setOriginalUserId) {
170                            _setOriginalUserId = true;
171    
172                            _originalUserId = _userId;
173                    }
174    
175                    _userId = userId;
176            }
177    
178            public String getUserUuid() throws SystemException {
179                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
180            }
181    
182            public void setUserUuid(String userUuid) {
183                    _userUuid = userUuid;
184            }
185    
186            public long getOriginalUserId() {
187                    return _originalUserId;
188            }
189    
190            public Date getCreateDate() {
191                    return _createDate;
192            }
193    
194            public void setCreateDate(Date createDate) {
195                    _columnBitmask = -1L;
196    
197                    _createDate = createDate;
198            }
199    
200            public String getPassword() {
201                    if (_password == null) {
202                            return StringPool.BLANK;
203                    }
204                    else {
205                            return _password;
206                    }
207            }
208    
209            public void setPassword(String password) {
210                    _password = password;
211            }
212    
213            public long getColumnBitmask() {
214                    return _columnBitmask;
215            }
216    
217            @Override
218            public ExpandoBridge getExpandoBridge() {
219                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
220                            PasswordTracker.class.getName(), getPrimaryKey());
221            }
222    
223            @Override
224            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
225                    ExpandoBridge expandoBridge = getExpandoBridge();
226    
227                    expandoBridge.setAttributes(serviceContext);
228            }
229    
230            @Override
231            public PasswordTracker toEscapedModel() {
232                    if (_escapedModel == null) {
233                            _escapedModel = (PasswordTracker)ProxyUtil.newProxyInstance(_classLoader,
234                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
235                    }
236    
237                    return _escapedModel;
238            }
239    
240            public PasswordTracker toUnescapedModel() {
241                    return (PasswordTracker)this;
242            }
243    
244            @Override
245            public Object clone() {
246                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
247    
248                    passwordTrackerImpl.setPasswordTrackerId(getPasswordTrackerId());
249                    passwordTrackerImpl.setUserId(getUserId());
250                    passwordTrackerImpl.setCreateDate(getCreateDate());
251                    passwordTrackerImpl.setPassword(getPassword());
252    
253                    passwordTrackerImpl.resetOriginalValues();
254    
255                    return passwordTrackerImpl;
256            }
257    
258            public int compareTo(PasswordTracker passwordTracker) {
259                    int value = 0;
260    
261                    if (getUserId() < passwordTracker.getUserId()) {
262                            value = -1;
263                    }
264                    else if (getUserId() > passwordTracker.getUserId()) {
265                            value = 1;
266                    }
267                    else {
268                            value = 0;
269                    }
270    
271                    value = value * -1;
272    
273                    if (value != 0) {
274                            return value;
275                    }
276    
277                    value = DateUtil.compareTo(getCreateDate(),
278                                    passwordTracker.getCreateDate());
279    
280                    value = value * -1;
281    
282                    if (value != 0) {
283                            return value;
284                    }
285    
286                    return 0;
287            }
288    
289            @Override
290            public boolean equals(Object obj) {
291                    if (this == obj) {
292                            return true;
293                    }
294    
295                    if (!(obj instanceof PasswordTracker)) {
296                            return false;
297                    }
298    
299                    PasswordTracker passwordTracker = (PasswordTracker)obj;
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    }