1   /**
2    * Copyright (c) 2000-2009 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.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.PasswordTracker;
30  import com.liferay.portal.model.PasswordTrackerSoap;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="PasswordTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This class is a model that represents the <code>PasswordTracker</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portal.model.PasswordTracker
61   * @see com.liferay.portal.model.PasswordTrackerModel
62   * @see com.liferay.portal.model.impl.PasswordTrackerImpl
63   *
64   */
65  public class PasswordTrackerModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "PasswordTracker";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "passwordTrackerId", new Integer(Types.BIGINT) },
69              
70  
71              { "userId", new Integer(Types.BIGINT) },
72              
73  
74              { "createDate", new Integer(Types.TIMESTAMP) },
75              
76  
77              { "password_", new Integer(Types.VARCHAR) }
78          };
79      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)";
80      public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
81      public static final String DATA_SOURCE = "liferayDataSource";
82      public static final String SESSION_FACTORY = "liferaySessionFactory";
83      public static final String TX_MANAGER = "liferayTransactionManager";
84      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
86              true);
87  
88      public static PasswordTracker toModel(PasswordTrackerSoap soapModel) {
89          PasswordTracker model = new PasswordTrackerImpl();
90  
91          model.setPasswordTrackerId(soapModel.getPasswordTrackerId());
92          model.setUserId(soapModel.getUserId());
93          model.setCreateDate(soapModel.getCreateDate());
94          model.setPassword(soapModel.getPassword());
95  
96          return model;
97      }
98  
99      public static List<PasswordTracker> toModels(
100         PasswordTrackerSoap[] soapModels) {
101         List<PasswordTracker> models = new ArrayList<PasswordTracker>(soapModels.length);
102 
103         for (PasswordTrackerSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
112 
113     public PasswordTrackerModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _passwordTrackerId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setPasswordTrackerId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_passwordTrackerId);
126     }
127 
128     public long getPasswordTrackerId() {
129         return _passwordTrackerId;
130     }
131 
132     public void setPasswordTrackerId(long passwordTrackerId) {
133         if (passwordTrackerId != _passwordTrackerId) {
134             _passwordTrackerId = passwordTrackerId;
135         }
136     }
137 
138     public long getUserId() {
139         return _userId;
140     }
141 
142     public void setUserId(long userId) {
143         if (userId != _userId) {
144             _userId = userId;
145         }
146     }
147 
148     public Date getCreateDate() {
149         return _createDate;
150     }
151 
152     public void setCreateDate(Date createDate) {
153         if (((createDate == null) && (_createDate != null)) ||
154                 ((createDate != null) && (_createDate == null)) ||
155                 ((createDate != null) && (_createDate != null) &&
156                 !createDate.equals(_createDate))) {
157             _createDate = createDate;
158         }
159     }
160 
161     public String getPassword() {
162         return GetterUtil.getString(_password);
163     }
164 
165     public void setPassword(String password) {
166         if (((password == null) && (_password != null)) ||
167                 ((password != null) && (_password == null)) ||
168                 ((password != null) && (_password != null) &&
169                 !password.equals(_password))) {
170             _password = password;
171         }
172     }
173 
174     public PasswordTracker toEscapedModel() {
175         if (isEscapedModel()) {
176             return (PasswordTracker)this;
177         }
178         else {
179             PasswordTracker model = new PasswordTrackerImpl();
180 
181             model.setNew(isNew());
182             model.setEscapedModel(true);
183 
184             model.setPasswordTrackerId(getPasswordTrackerId());
185             model.setUserId(getUserId());
186             model.setCreateDate(getCreateDate());
187             model.setPassword(HtmlUtil.escape(getPassword()));
188 
189             model = (PasswordTracker)Proxy.newProxyInstance(PasswordTracker.class.getClassLoader(),
190                     new Class[] { PasswordTracker.class },
191                     new ReadOnlyBeanHandler(model));
192 
193             return model;
194         }
195     }
196 
197     public ExpandoBridge getExpandoBridge() {
198         if (_expandoBridge == null) {
199             _expandoBridge = new ExpandoBridgeImpl(PasswordTracker.class.getName(),
200                     getPrimaryKey());
201         }
202 
203         return _expandoBridge;
204     }
205 
206     public Object clone() {
207         PasswordTrackerImpl clone = new PasswordTrackerImpl();
208 
209         clone.setPasswordTrackerId(getPasswordTrackerId());
210         clone.setUserId(getUserId());
211         clone.setCreateDate(getCreateDate());
212         clone.setPassword(getPassword());
213 
214         return clone;
215     }
216 
217     public int compareTo(Object obj) {
218         if (obj == null) {
219             return -1;
220         }
221 
222         PasswordTrackerImpl passwordTracker = (PasswordTrackerImpl)obj;
223 
224         int value = 0;
225 
226         if (getUserId() < passwordTracker.getUserId()) {
227             value = -1;
228         }
229         else if (getUserId() > passwordTracker.getUserId()) {
230             value = 1;
231         }
232         else {
233             value = 0;
234         }
235 
236         value = value * -1;
237 
238         if (value != 0) {
239             return value;
240         }
241 
242         value = DateUtil.compareTo(getCreateDate(),
243                 passwordTracker.getCreateDate());
244 
245         value = value * -1;
246 
247         if (value != 0) {
248             return value;
249         }
250 
251         return 0;
252     }
253 
254     public boolean equals(Object obj) {
255         if (obj == null) {
256             return false;
257         }
258 
259         PasswordTrackerImpl passwordTracker = null;
260 
261         try {
262             passwordTracker = (PasswordTrackerImpl)obj;
263         }
264         catch (ClassCastException cce) {
265             return false;
266         }
267 
268         long pk = passwordTracker.getPrimaryKey();
269 
270         if (getPrimaryKey() == pk) {
271             return true;
272         }
273         else {
274             return false;
275         }
276     }
277 
278     public int hashCode() {
279         return (int)getPrimaryKey();
280     }
281 
282     private long _passwordTrackerId;
283     private long _userId;
284     private Date _createDate;
285     private String _password;
286     private transient ExpandoBridge _expandoBridge;
287 }