1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.DateUtil;
24  import com.liferay.portal.kernel.util.GetterUtil;
25  import com.liferay.portal.kernel.util.HtmlUtil;
26  import com.liferay.portal.model.PasswordTracker;
27  import com.liferay.portal.model.PasswordTrackerSoap;
28  
29  import com.liferay.portlet.expando.model.ExpandoBridge;
30  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 ExpandoBridge getExpandoBridge() {
184         if (_expandoBridge == null) {
185             _expandoBridge = new ExpandoBridgeImpl(PasswordTracker.class.getName(),
186                     getPrimaryKey());
187         }
188 
189         return _expandoBridge;
190     }
191 
192     public Object clone() {
193         PasswordTrackerImpl clone = new PasswordTrackerImpl();
194 
195         clone.setPasswordTrackerId(getPasswordTrackerId());
196         clone.setUserId(getUserId());
197         clone.setCreateDate(getCreateDate());
198         clone.setPassword(getPassword());
199 
200         return clone;
201     }
202 
203     public int compareTo(PasswordTracker passwordTracker) {
204         int value = 0;
205 
206         if (getUserId() < passwordTracker.getUserId()) {
207             value = -1;
208         }
209         else if (getUserId() > passwordTracker.getUserId()) {
210             value = 1;
211         }
212         else {
213             value = 0;
214         }
215 
216         value = value * -1;
217 
218         if (value != 0) {
219             return value;
220         }
221 
222         value = DateUtil.compareTo(getCreateDate(),
223                 passwordTracker.getCreateDate());
224 
225         value = value * -1;
226 
227         if (value != 0) {
228             return value;
229         }
230 
231         return 0;
232     }
233 
234     public boolean equals(Object obj) {
235         if (obj == null) {
236             return false;
237         }
238 
239         PasswordTracker passwordTracker = null;
240 
241         try {
242             passwordTracker = (PasswordTracker)obj;
243         }
244         catch (ClassCastException cce) {
245             return false;
246         }
247 
248         long pk = passwordTracker.getPrimaryKey();
249 
250         if (getPrimaryKey() == pk) {
251             return true;
252         }
253         else {
254             return false;
255         }
256     }
257 
258     public int hashCode() {
259         return (int)getPrimaryKey();
260     }
261 
262     public String toString() {
263         StringBuilder sb = new StringBuilder();
264 
265         sb.append("{passwordTrackerId=");
266         sb.append(getPasswordTrackerId());
267         sb.append(", userId=");
268         sb.append(getUserId());
269         sb.append(", createDate=");
270         sb.append(getCreateDate());
271         sb.append(", password=");
272         sb.append(getPassword());
273         sb.append("}");
274 
275         return sb.toString();
276     }
277 
278     public String toXmlString() {
279         StringBuilder sb = new StringBuilder();
280 
281         sb.append("<model><model-name>");
282         sb.append("com.liferay.portal.model.PasswordTracker");
283         sb.append("</model-name>");
284 
285         sb.append(
286             "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
287         sb.append(getPasswordTrackerId());
288         sb.append("]]></column-value></column>");
289         sb.append(
290             "<column><column-name>userId</column-name><column-value><![CDATA[");
291         sb.append(getUserId());
292         sb.append("]]></column-value></column>");
293         sb.append(
294             "<column><column-name>createDate</column-name><column-value><![CDATA[");
295         sb.append(getCreateDate());
296         sb.append("]]></column-value></column>");
297         sb.append(
298             "<column><column-name>password</column-name><column-value><![CDATA[");
299         sb.append(getPassword());
300         sb.append("]]></column-value></column>");
301 
302         sb.append("</model>");
303 
304         return sb.toString();
305     }
306 
307     private long _passwordTrackerId;
308     private long _userId;
309     private Date _createDate;
310     private String _password;
311     private transient ExpandoBridge _expandoBridge;
312 }