1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.HtmlUtil;
22  import com.liferay.portal.kernel.util.StringBundler;
23  import com.liferay.portal.model.PasswordTracker;
24  import com.liferay.portal.model.PasswordTrackerSoap;
25  import com.liferay.portal.util.PortalUtil;
26  
27  import java.io.Serializable;
28  
29  import java.lang.reflect.Proxy;
30  
31  import java.sql.Types;
32  
33  import java.util.ArrayList;
34  import java.util.Date;
35  import java.util.List;
36  
37  /**
38   * <a href="PasswordTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the PasswordTracker table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       PasswordTrackerImpl
52   * @see       com.liferay.portal.model.PasswordTracker
53   * @see       com.liferay.portal.model.PasswordTrackerModel
54   * @generated
55   */
56  public class PasswordTrackerModelImpl extends BaseModelImpl<PasswordTracker> {
57      public static final String TABLE_NAME = "PasswordTracker";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "passwordTrackerId", new Integer(Types.BIGINT) },
60              { "userId", new Integer(Types.BIGINT) },
61              { "createDate", new Integer(Types.TIMESTAMP) },
62              { "password_", new Integer(Types.VARCHAR) }
63          };
64      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)";
65      public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
66      public static final String ORDER_BY_JPQL = " ORDER BY passwordTracker.userId DESC, passwordTracker.createDate DESC";
67      public static final String ORDER_BY_SQL = " ORDER BY PasswordTracker.userId DESC, PasswordTracker.createDate DESC";
68      public static final String DATA_SOURCE = "liferayDataSource";
69      public static final String SESSION_FACTORY = "liferaySessionFactory";
70      public static final String TX_MANAGER = "liferayTransactionManager";
71      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72                  "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordTracker"),
73              true);
74      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
76              true);
77  
78      public static PasswordTracker toModel(PasswordTrackerSoap soapModel) {
79          PasswordTracker model = new PasswordTrackerImpl();
80  
81          model.setPasswordTrackerId(soapModel.getPasswordTrackerId());
82          model.setUserId(soapModel.getUserId());
83          model.setCreateDate(soapModel.getCreateDate());
84          model.setPassword(soapModel.getPassword());
85  
86          return model;
87      }
88  
89      public static List<PasswordTracker> toModels(
90          PasswordTrackerSoap[] soapModels) {
91          List<PasswordTracker> models = new ArrayList<PasswordTracker>(soapModels.length);
92  
93          for (PasswordTrackerSoap soapModel : soapModels) {
94              models.add(toModel(soapModel));
95          }
96  
97          return models;
98      }
99  
100     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
101                 "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
102 
103     public PasswordTrackerModelImpl() {
104     }
105 
106     public long getPrimaryKey() {
107         return _passwordTrackerId;
108     }
109 
110     public void setPrimaryKey(long pk) {
111         setPasswordTrackerId(pk);
112     }
113 
114     public Serializable getPrimaryKeyObj() {
115         return new Long(_passwordTrackerId);
116     }
117 
118     public long getPasswordTrackerId() {
119         return _passwordTrackerId;
120     }
121 
122     public void setPasswordTrackerId(long passwordTrackerId) {
123         _passwordTrackerId = passwordTrackerId;
124     }
125 
126     public long getUserId() {
127         return _userId;
128     }
129 
130     public void setUserId(long userId) {
131         _userId = userId;
132     }
133 
134     public String getUserUuid() throws SystemException {
135         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
136     }
137 
138     public void setUserUuid(String userUuid) {
139         _userUuid = userUuid;
140     }
141 
142     public Date getCreateDate() {
143         return _createDate;
144     }
145 
146     public void setCreateDate(Date createDate) {
147         _createDate = createDate;
148     }
149 
150     public String getPassword() {
151         return GetterUtil.getString(_password);
152     }
153 
154     public void setPassword(String password) {
155         _password = password;
156     }
157 
158     public PasswordTracker toEscapedModel() {
159         if (isEscapedModel()) {
160             return (PasswordTracker)this;
161         }
162         else {
163             PasswordTracker model = new PasswordTrackerImpl();
164 
165             model.setNew(isNew());
166             model.setEscapedModel(true);
167 
168             model.setPasswordTrackerId(getPasswordTrackerId());
169             model.setUserId(getUserId());
170             model.setCreateDate(getCreateDate());
171             model.setPassword(HtmlUtil.escape(getPassword()));
172 
173             model = (PasswordTracker)Proxy.newProxyInstance(PasswordTracker.class.getClassLoader(),
174                     new Class[] { PasswordTracker.class },
175                     new ReadOnlyBeanHandler(model));
176 
177             return model;
178         }
179     }
180 
181     public Object clone() {
182         PasswordTrackerImpl clone = new PasswordTrackerImpl();
183 
184         clone.setPasswordTrackerId(getPasswordTrackerId());
185         clone.setUserId(getUserId());
186         clone.setCreateDate(getCreateDate());
187         clone.setPassword(getPassword());
188 
189         return clone;
190     }
191 
192     public int compareTo(PasswordTracker passwordTracker) {
193         int value = 0;
194 
195         if (getUserId() < passwordTracker.getUserId()) {
196             value = -1;
197         }
198         else if (getUserId() > passwordTracker.getUserId()) {
199             value = 1;
200         }
201         else {
202             value = 0;
203         }
204 
205         value = value * -1;
206 
207         if (value != 0) {
208             return value;
209         }
210 
211         value = DateUtil.compareTo(getCreateDate(),
212                 passwordTracker.getCreateDate());
213 
214         value = value * -1;
215 
216         if (value != 0) {
217             return value;
218         }
219 
220         return 0;
221     }
222 
223     public boolean equals(Object obj) {
224         if (obj == null) {
225             return false;
226         }
227 
228         PasswordTracker passwordTracker = null;
229 
230         try {
231             passwordTracker = (PasswordTracker)obj;
232         }
233         catch (ClassCastException cce) {
234             return false;
235         }
236 
237         long pk = passwordTracker.getPrimaryKey();
238 
239         if (getPrimaryKey() == pk) {
240             return true;
241         }
242         else {
243             return false;
244         }
245     }
246 
247     public int hashCode() {
248         return (int)getPrimaryKey();
249     }
250 
251     public String toString() {
252         StringBundler sb = new StringBundler(9);
253 
254         sb.append("{passwordTrackerId=");
255         sb.append(getPasswordTrackerId());
256         sb.append(", userId=");
257         sb.append(getUserId());
258         sb.append(", createDate=");
259         sb.append(getCreateDate());
260         sb.append(", password=");
261         sb.append(getPassword());
262         sb.append("}");
263 
264         return sb.toString();
265     }
266 
267     public String toXmlString() {
268         StringBundler sb = new StringBundler(16);
269 
270         sb.append("<model><model-name>");
271         sb.append("com.liferay.portal.model.PasswordTracker");
272         sb.append("</model-name>");
273 
274         sb.append(
275             "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
276         sb.append(getPasswordTrackerId());
277         sb.append("]]></column-value></column>");
278         sb.append(
279             "<column><column-name>userId</column-name><column-value><![CDATA[");
280         sb.append(getUserId());
281         sb.append("]]></column-value></column>");
282         sb.append(
283             "<column><column-name>createDate</column-name><column-value><![CDATA[");
284         sb.append(getCreateDate());
285         sb.append("]]></column-value></column>");
286         sb.append(
287             "<column><column-name>password</column-name><column-value><![CDATA[");
288         sb.append(getPassword());
289         sb.append("]]></column-value></column>");
290 
291         sb.append("</model>");
292 
293         return sb.toString();
294     }
295 
296     private long _passwordTrackerId;
297     private long _userId;
298     private String _userUuid;
299     private Date _createDate;
300     private String _password;
301 }