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