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