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 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<PasswordTracker> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordTracker"),
83              true);
84      public static final boolean FINDER_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         _passwordTrackerId = passwordTrackerId;
134     }
135 
136     public long getUserId() {
137         return _userId;
138     }
139 
140     public void setUserId(long userId) {
141         _userId = userId;
142     }
143 
144     public Date getCreateDate() {
145         return _createDate;
146     }
147 
148     public void setCreateDate(Date createDate) {
149         _createDate = createDate;
150     }
151 
152     public String getPassword() {
153         return GetterUtil.getString(_password);
154     }
155 
156     public void setPassword(String password) {
157         _password = password;
158     }
159 
160     public PasswordTracker toEscapedModel() {
161         if (isEscapedModel()) {
162             return (PasswordTracker)this;
163         }
164         else {
165             PasswordTracker model = new PasswordTrackerImpl();
166 
167             model.setNew(isNew());
168             model.setEscapedModel(true);
169 
170             model.setPasswordTrackerId(getPasswordTrackerId());
171             model.setUserId(getUserId());
172             model.setCreateDate(getCreateDate());
173             model.setPassword(HtmlUtil.escape(getPassword()));
174 
175             model = (PasswordTracker)Proxy.newProxyInstance(PasswordTracker.class.getClassLoader(),
176                     new Class[] { PasswordTracker.class },
177                     new ReadOnlyBeanHandler(model));
178 
179             return model;
180         }
181     }
182 
183     public Object clone() {
184         PasswordTrackerImpl clone = new PasswordTrackerImpl();
185 
186         clone.setPasswordTrackerId(getPasswordTrackerId());
187         clone.setUserId(getUserId());
188         clone.setCreateDate(getCreateDate());
189         clone.setPassword(getPassword());
190 
191         return clone;
192     }
193 
194     public int compareTo(PasswordTracker passwordTracker) {
195         int value = 0;
196 
197         if (getUserId() < passwordTracker.getUserId()) {
198             value = -1;
199         }
200         else if (getUserId() > passwordTracker.getUserId()) {
201             value = 1;
202         }
203         else {
204             value = 0;
205         }
206 
207         value = value * -1;
208 
209         if (value != 0) {
210             return value;
211         }
212 
213         value = DateUtil.compareTo(getCreateDate(),
214                 passwordTracker.getCreateDate());
215 
216         value = value * -1;
217 
218         if (value != 0) {
219             return value;
220         }
221 
222         return 0;
223     }
224 
225     public boolean equals(Object obj) {
226         if (obj == null) {
227             return false;
228         }
229 
230         PasswordTracker passwordTracker = null;
231 
232         try {
233             passwordTracker = (PasswordTracker)obj;
234         }
235         catch (ClassCastException cce) {
236             return false;
237         }
238 
239         long pk = passwordTracker.getPrimaryKey();
240 
241         if (getPrimaryKey() == pk) {
242             return true;
243         }
244         else {
245             return false;
246         }
247     }
248 
249     public int hashCode() {
250         return (int)getPrimaryKey();
251     }
252 
253     public String toString() {
254         StringBuilder sb = new StringBuilder();
255 
256         sb.append("{passwordTrackerId=");
257         sb.append(getPasswordTrackerId());
258         sb.append(", userId=");
259         sb.append(getUserId());
260         sb.append(", createDate=");
261         sb.append(getCreateDate());
262         sb.append(", password=");
263         sb.append(getPassword());
264         sb.append("}");
265 
266         return sb.toString();
267     }
268 
269     public String toXmlString() {
270         StringBuilder sb = new StringBuilder();
271 
272         sb.append("<model><model-name>");
273         sb.append("com.liferay.portal.model.PasswordTracker");
274         sb.append("</model-name>");
275 
276         sb.append(
277             "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
278         sb.append(getPasswordTrackerId());
279         sb.append("]]></column-value></column>");
280         sb.append(
281             "<column><column-name>userId</column-name><column-value><![CDATA[");
282         sb.append(getUserId());
283         sb.append("]]></column-value></column>");
284         sb.append(
285             "<column><column-name>createDate</column-name><column-value><![CDATA[");
286         sb.append(getCreateDate());
287         sb.append("]]></column-value></column>");
288         sb.append(
289             "<column><column-name>password</column-name><column-value><![CDATA[");
290         sb.append(getPassword());
291         sb.append("]]></column-value></column>");
292 
293         sb.append("</model>");
294 
295         return sb.toString();
296     }
297 
298     private long _passwordTrackerId;
299     private long _userId;
300     private Date _createDate;
301     private String _password;
302 }