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