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.service.model.PasswordTracker
58   * @see com.liferay.portal.service.model.PasswordTrackerModel
59   * @see com.liferay.portal.service.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.setEscapedModel(true);
179 
180             model.setPasswordTrackerId(getPasswordTrackerId());
181             model.setUserId(getUserId());
182             model.setCreateDate(getCreateDate());
183             model.setPassword(HtmlUtil.escape(getPassword()));
184 
185             model = (PasswordTracker)Proxy.newProxyInstance(PasswordTracker.class.getClassLoader(),
186                     new Class[] { PasswordTracker.class },
187                     new ReadOnlyBeanHandler(model));
188 
189             return model;
190         }
191     }
192 
193     public Object clone() {
194         PasswordTrackerImpl clone = new PasswordTrackerImpl();
195 
196         clone.setPasswordTrackerId(getPasswordTrackerId());
197         clone.setUserId(getUserId());
198         clone.setCreateDate(getCreateDate());
199         clone.setPassword(getPassword());
200 
201         return clone;
202     }
203 
204     public int compareTo(Object obj) {
205         if (obj == null) {
206             return -1;
207         }
208 
209         PasswordTrackerImpl passwordTracker = (PasswordTrackerImpl)obj;
210 
211         int value = 0;
212 
213         if (getUserId() < passwordTracker.getUserId()) {
214             value = -1;
215         }
216         else if (getUserId() > passwordTracker.getUserId()) {
217             value = 1;
218         }
219         else {
220             value = 0;
221         }
222 
223         value = value * -1;
224 
225         if (value != 0) {
226             return value;
227         }
228 
229         value = DateUtil.compareTo(getCreateDate(),
230                 passwordTracker.getCreateDate());
231 
232         value = value * -1;
233 
234         if (value != 0) {
235             return value;
236         }
237 
238         return 0;
239     }
240 
241     public boolean equals(Object obj) {
242         if (obj == null) {
243             return false;
244         }
245 
246         PasswordTrackerImpl passwordTracker = null;
247 
248         try {
249             passwordTracker = (PasswordTrackerImpl)obj;
250         }
251         catch (ClassCastException cce) {
252             return false;
253         }
254 
255         long pk = passwordTracker.getPrimaryKey();
256 
257         if (getPrimaryKey() == pk) {
258             return true;
259         }
260         else {
261             return false;
262         }
263     }
264 
265     public int hashCode() {
266         return (int)getPrimaryKey();
267     }
268 
269     private long _passwordTrackerId;
270     private long _userId;
271     private Date _createDate;
272     private String _password;
273 }