1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.PasswordTracker;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.util.Html;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.Date;
40  
41  /**
42   * <a href="PasswordTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>PasswordTracker</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.PasswordTracker
57   * @see com.liferay.portal.service.model.PasswordTrackerModel
58   * @see com.liferay.portal.service.model.impl.PasswordTrackerImpl
59   *
60   */
61  public class PasswordTrackerModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "PasswordTracker";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "passwordTrackerId", new Integer(Types.BIGINT) },
65              
66  
67              { "userId", new Integer(Types.BIGINT) },
68              
69  
70              { "createDate", new Integer(Types.TIMESTAMP) },
71              
72  
73              { "password_", new Integer(Types.VARCHAR) }
74          };
75      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)";
76      public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
77      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
79              true);
80      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
81                  "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
82  
83      public PasswordTrackerModelImpl() {
84      }
85  
86      public long getPrimaryKey() {
87          return _passwordTrackerId;
88      }
89  
90      public void setPrimaryKey(long pk) {
91          setPasswordTrackerId(pk);
92      }
93  
94      public Serializable getPrimaryKeyObj() {
95          return new Long(_passwordTrackerId);
96      }
97  
98      public long getPasswordTrackerId() {
99          return _passwordTrackerId;
100     }
101 
102     public void setPasswordTrackerId(long passwordTrackerId) {
103         if (passwordTrackerId != _passwordTrackerId) {
104             _passwordTrackerId = passwordTrackerId;
105         }
106     }
107 
108     public long getUserId() {
109         return _userId;
110     }
111 
112     public void setUserId(long userId) {
113         if (userId != _userId) {
114             _userId = userId;
115         }
116     }
117 
118     public Date getCreateDate() {
119         return _createDate;
120     }
121 
122     public void setCreateDate(Date createDate) {
123         if (((createDate == null) && (_createDate != null)) ||
124                 ((createDate != null) && (_createDate == null)) ||
125                 ((createDate != null) && (_createDate != null) &&
126                 !createDate.equals(_createDate))) {
127             _createDate = createDate;
128         }
129     }
130 
131     public String getPassword() {
132         return GetterUtil.getString(_password);
133     }
134 
135     public void setPassword(String password) {
136         if (((password == null) && (_password != null)) ||
137                 ((password != null) && (_password == null)) ||
138                 ((password != null) && (_password != null) &&
139                 !password.equals(_password))) {
140             _password = password;
141         }
142     }
143 
144     public PasswordTracker toEscapedModel() {
145         if (isEscapedModel()) {
146             return (PasswordTracker)this;
147         }
148         else {
149             PasswordTracker model = new PasswordTrackerImpl();
150 
151             model.setEscapedModel(true);
152 
153             model.setPasswordTrackerId(getPasswordTrackerId());
154             model.setUserId(getUserId());
155             model.setCreateDate(getCreateDate());
156             model.setPassword(Html.escape(getPassword()));
157 
158             model = (PasswordTracker)Proxy.newProxyInstance(PasswordTracker.class.getClassLoader(),
159                     new Class[] { PasswordTracker.class },
160                     new ReadOnlyBeanHandler(model));
161 
162             return model;
163         }
164     }
165 
166     public Object clone() {
167         PasswordTrackerImpl clone = new PasswordTrackerImpl();
168 
169         clone.setPasswordTrackerId(getPasswordTrackerId());
170         clone.setUserId(getUserId());
171         clone.setCreateDate(getCreateDate());
172         clone.setPassword(getPassword());
173 
174         return clone;
175     }
176 
177     public int compareTo(Object obj) {
178         if (obj == null) {
179             return -1;
180         }
181 
182         PasswordTrackerImpl passwordTracker = (PasswordTrackerImpl)obj;
183 
184         int value = 0;
185 
186         if (getUserId() < passwordTracker.getUserId()) {
187             value = -1;
188         }
189         else if (getUserId() > passwordTracker.getUserId()) {
190             value = 1;
191         }
192         else {
193             value = 0;
194         }
195 
196         value = value * -1;
197 
198         if (value != 0) {
199             return value;
200         }
201 
202         value = DateUtil.compareTo(getCreateDate(),
203                 passwordTracker.getCreateDate());
204 
205         value = value * -1;
206 
207         if (value != 0) {
208             return value;
209         }
210 
211         return 0;
212     }
213 
214     public boolean equals(Object obj) {
215         if (obj == null) {
216             return false;
217         }
218 
219         PasswordTrackerImpl passwordTracker = null;
220 
221         try {
222             passwordTracker = (PasswordTrackerImpl)obj;
223         }
224         catch (ClassCastException cce) {
225             return false;
226         }
227 
228         long pk = passwordTracker.getPrimaryKey();
229 
230         if (getPrimaryKey() == pk) {
231             return true;
232         }
233         else {
234             return false;
235         }
236     }
237 
238     public int hashCode() {
239         return (int)getPrimaryKey();
240     }
241 
242     private long _passwordTrackerId;
243     private long _userId;
244     private Date _createDate;
245     private String _password;
246 }