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 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            @Override
093            public long getPrimaryKey() {
094                    return _passwordTrackerId;
095            }
096    
097            @Override
098            public void setPrimaryKey(long primaryKey) {
099                    setPasswordTrackerId(primaryKey);
100            }
101    
102            @Override
103            public Serializable getPrimaryKeyObj() {
104                    return _passwordTrackerId;
105            }
106    
107            @Override
108            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
109                    setPrimaryKey(((Long)primaryKeyObj).longValue());
110            }
111    
112            @Override
113            public Class<?> getModelClass() {
114                    return PasswordTracker.class;
115            }
116    
117            @Override
118            public String getModelClassName() {
119                    return PasswordTracker.class.getName();
120            }
121    
122            @Override
123            public Map<String, Object> getModelAttributes() {
124                    Map<String, Object> attributes = new HashMap<String, Object>();
125    
126                    attributes.put("passwordTrackerId", getPasswordTrackerId());
127                    attributes.put("userId", getUserId());
128                    attributes.put("createDate", getCreateDate());
129                    attributes.put("password", getPassword());
130    
131                    return attributes;
132            }
133    
134            @Override
135            public void setModelAttributes(Map<String, Object> attributes) {
136                    Long passwordTrackerId = (Long)attributes.get("passwordTrackerId");
137    
138                    if (passwordTrackerId != null) {
139                            setPasswordTrackerId(passwordTrackerId);
140                    }
141    
142                    Long userId = (Long)attributes.get("userId");
143    
144                    if (userId != null) {
145                            setUserId(userId);
146                    }
147    
148                    Date createDate = (Date)attributes.get("createDate");
149    
150                    if (createDate != null) {
151                            setCreateDate(createDate);
152                    }
153    
154                    String password = (String)attributes.get("password");
155    
156                    if (password != null) {
157                            setPassword(password);
158                    }
159            }
160    
161            @Override
162            public long getPasswordTrackerId() {
163                    return _passwordTrackerId;
164            }
165    
166            @Override
167            public void setPasswordTrackerId(long passwordTrackerId) {
168                    _passwordTrackerId = passwordTrackerId;
169            }
170    
171            @Override
172            public long getUserId() {
173                    return _userId;
174            }
175    
176            @Override
177            public void setUserId(long userId) {
178                    _columnBitmask = -1L;
179    
180                    if (!_setOriginalUserId) {
181                            _setOriginalUserId = true;
182    
183                            _originalUserId = _userId;
184                    }
185    
186                    _userId = userId;
187            }
188    
189            @Override
190            public String getUserUuid() throws SystemException {
191                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
192            }
193    
194            @Override
195            public void setUserUuid(String userUuid) {
196                    _userUuid = userUuid;
197            }
198    
199            public long getOriginalUserId() {
200                    return _originalUserId;
201            }
202    
203            @Override
204            public Date getCreateDate() {
205                    return _createDate;
206            }
207    
208            @Override
209            public void setCreateDate(Date createDate) {
210                    _columnBitmask = -1L;
211    
212                    _createDate = createDate;
213            }
214    
215            @Override
216            public String getPassword() {
217                    if (_password == null) {
218                            return StringPool.BLANK;
219                    }
220                    else {
221                            return _password;
222                    }
223            }
224    
225            @Override
226            public void setPassword(String password) {
227                    _password = password;
228            }
229    
230            public long getColumnBitmask() {
231                    return _columnBitmask;
232            }
233    
234            @Override
235            public ExpandoBridge getExpandoBridge() {
236                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
237                            PasswordTracker.class.getName(), getPrimaryKey());
238            }
239    
240            @Override
241            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
242                    ExpandoBridge expandoBridge = getExpandoBridge();
243    
244                    expandoBridge.setAttributes(serviceContext);
245            }
246    
247            @Override
248            public PasswordTracker toEscapedModel() {
249                    if (_escapedModel == null) {
250                            _escapedModel = (PasswordTracker)ProxyUtil.newProxyInstance(_classLoader,
251                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
252                    }
253    
254                    return _escapedModel;
255            }
256    
257            @Override
258            public Object clone() {
259                    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();
260    
261                    passwordTrackerImpl.setPasswordTrackerId(getPasswordTrackerId());
262                    passwordTrackerImpl.setUserId(getUserId());
263                    passwordTrackerImpl.setCreateDate(getCreateDate());
264                    passwordTrackerImpl.setPassword(getPassword());
265    
266                    passwordTrackerImpl.resetOriginalValues();
267    
268                    return passwordTrackerImpl;
269            }
270    
271            @Override
272            public int compareTo(PasswordTracker passwordTracker) {
273                    int value = 0;
274    
275                    if (getUserId() < passwordTracker.getUserId()) {
276                            value = -1;
277                    }
278                    else if (getUserId() > passwordTracker.getUserId()) {
279                            value = 1;
280                    }
281                    else {
282                            value = 0;
283                    }
284    
285                    value = value * -1;
286    
287                    if (value != 0) {
288                            return value;
289                    }
290    
291                    value = DateUtil.compareTo(getCreateDate(),
292                                    passwordTracker.getCreateDate());
293    
294                    value = value * -1;
295    
296                    if (value != 0) {
297                            return value;
298                    }
299    
300                    return 0;
301            }
302    
303            @Override
304            public boolean equals(Object obj) {
305                    if (this == obj) {
306                            return true;
307                    }
308    
309                    if (!(obj instanceof PasswordTracker)) {
310                            return false;
311                    }
312    
313                    PasswordTracker passwordTracker = (PasswordTracker)obj;
314    
315                    long primaryKey = passwordTracker.getPrimaryKey();
316    
317                    if (getPrimaryKey() == primaryKey) {
318                            return true;
319                    }
320                    else {
321                            return false;
322                    }
323            }
324    
325            @Override
326            public int hashCode() {
327                    return (int)getPrimaryKey();
328            }
329    
330            @Override
331            public void resetOriginalValues() {
332                    PasswordTrackerModelImpl passwordTrackerModelImpl = this;
333    
334                    passwordTrackerModelImpl._originalUserId = passwordTrackerModelImpl._userId;
335    
336                    passwordTrackerModelImpl._setOriginalUserId = false;
337    
338                    passwordTrackerModelImpl._columnBitmask = 0;
339            }
340    
341            @Override
342            public CacheModel<PasswordTracker> toCacheModel() {
343                    PasswordTrackerCacheModel passwordTrackerCacheModel = new PasswordTrackerCacheModel();
344    
345                    passwordTrackerCacheModel.passwordTrackerId = getPasswordTrackerId();
346    
347                    passwordTrackerCacheModel.userId = getUserId();
348    
349                    Date createDate = getCreateDate();
350    
351                    if (createDate != null) {
352                            passwordTrackerCacheModel.createDate = createDate.getTime();
353                    }
354                    else {
355                            passwordTrackerCacheModel.createDate = Long.MIN_VALUE;
356                    }
357    
358                    passwordTrackerCacheModel.password = getPassword();
359    
360                    String password = passwordTrackerCacheModel.password;
361    
362                    if ((password != null) && (password.length() == 0)) {
363                            passwordTrackerCacheModel.password = null;
364                    }
365    
366                    return passwordTrackerCacheModel;
367            }
368    
369            @Override
370            public String toString() {
371                    StringBundler sb = new StringBundler(9);
372    
373                    sb.append("{passwordTrackerId=");
374                    sb.append(getPasswordTrackerId());
375                    sb.append(", userId=");
376                    sb.append(getUserId());
377                    sb.append(", createDate=");
378                    sb.append(getCreateDate());
379                    sb.append(", password=");
380                    sb.append(getPassword());
381                    sb.append("}");
382    
383                    return sb.toString();
384            }
385    
386            @Override
387            public String toXmlString() {
388                    StringBundler sb = new StringBundler(16);
389    
390                    sb.append("<model><model-name>");
391                    sb.append("com.liferay.portal.model.PasswordTracker");
392                    sb.append("</model-name>");
393    
394                    sb.append(
395                            "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
396                    sb.append(getPasswordTrackerId());
397                    sb.append("]]></column-value></column>");
398                    sb.append(
399                            "<column><column-name>userId</column-name><column-value><![CDATA[");
400                    sb.append(getUserId());
401                    sb.append("]]></column-value></column>");
402                    sb.append(
403                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
404                    sb.append(getCreateDate());
405                    sb.append("]]></column-value></column>");
406                    sb.append(
407                            "<column><column-name>password</column-name><column-value><![CDATA[");
408                    sb.append(getPassword());
409                    sb.append("]]></column-value></column>");
410    
411                    sb.append("</model>");
412    
413                    return sb.toString();
414            }
415    
416            private static ClassLoader _classLoader = PasswordTracker.class.getClassLoader();
417            private static Class<?>[] _escapedModelInterfaces = new Class[] {
418                            PasswordTracker.class
419                    };
420            private long _passwordTrackerId;
421            private long _userId;
422            private String _userUuid;
423            private long _originalUserId;
424            private boolean _setOriginalUserId;
425            private Date _createDate;
426            private String _password;
427            private long _columnBitmask;
428            private PasswordTracker _escapedModel;
429    }