1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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 interface is a model that represents the PasswordTracker table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       PasswordTrackerImpl
59   * @see       com.liferay.portal.model.PasswordTracker
60   * @see       com.liferay.portal.model.PasswordTrackerModel
61   * @generated
62   */
63  public class PasswordTrackerModelImpl extends BaseModelImpl<PasswordTracker> {
64      public static final String TABLE_NAME = "PasswordTracker";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "passwordTrackerId", new Integer(Types.BIGINT) },
67              { "userId", new Integer(Types.BIGINT) },
68              { "createDate", new Integer(Types.TIMESTAMP) },
69              { "password_", new Integer(Types.VARCHAR) }
70          };
71      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)";
72      public static final String TABLE_SQL_DROP = "drop table PasswordTracker";
73      public static final String DATA_SOURCE = "liferayDataSource";
74      public static final String SESSION_FACTORY = "liferaySessionFactory";
75      public static final String TX_MANAGER = "liferayTransactionManager";
76      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.entity.cache.enabled.com.liferay.portal.model.PasswordTracker"),
78              true);
79      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordTracker"),
81              true);
82  
83      public static PasswordTracker toModel(PasswordTrackerSoap soapModel) {
84          PasswordTracker model = new PasswordTrackerImpl();
85  
86          model.setPasswordTrackerId(soapModel.getPasswordTrackerId());
87          model.setUserId(soapModel.getUserId());
88          model.setCreateDate(soapModel.getCreateDate());
89          model.setPassword(soapModel.getPassword());
90  
91          return model;
92      }
93  
94      public static List<PasswordTracker> toModels(
95          PasswordTrackerSoap[] soapModels) {
96          List<PasswordTracker> models = new ArrayList<PasswordTracker>(soapModels.length);
97  
98          for (PasswordTrackerSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portal.model.PasswordTracker"));
107 
108     public PasswordTrackerModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _passwordTrackerId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setPasswordTrackerId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_passwordTrackerId);
121     }
122 
123     public long getPasswordTrackerId() {
124         return _passwordTrackerId;
125     }
126 
127     public void setPasswordTrackerId(long passwordTrackerId) {
128         _passwordTrackerId = passwordTrackerId;
129     }
130 
131     public long getUserId() {
132         return _userId;
133     }
134 
135     public void setUserId(long userId) {
136         _userId = userId;
137     }
138 
139     public String getUserUuid() throws SystemException {
140         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
141     }
142 
143     public void setUserUuid(String userUuid) {
144         _userUuid = userUuid;
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 Object clone() {
187         PasswordTrackerImpl clone = new PasswordTrackerImpl();
188 
189         clone.setPasswordTrackerId(getPasswordTrackerId());
190         clone.setUserId(getUserId());
191         clone.setCreateDate(getCreateDate());
192         clone.setPassword(getPassword());
193 
194         return clone;
195     }
196 
197     public int compareTo(PasswordTracker passwordTracker) {
198         int value = 0;
199 
200         if (getUserId() < passwordTracker.getUserId()) {
201             value = -1;
202         }
203         else if (getUserId() > passwordTracker.getUserId()) {
204             value = 1;
205         }
206         else {
207             value = 0;
208         }
209 
210         value = value * -1;
211 
212         if (value != 0) {
213             return value;
214         }
215 
216         value = DateUtil.compareTo(getCreateDate(),
217                 passwordTracker.getCreateDate());
218 
219         value = value * -1;
220 
221         if (value != 0) {
222             return value;
223         }
224 
225         return 0;
226     }
227 
228     public boolean equals(Object obj) {
229         if (obj == null) {
230             return false;
231         }
232 
233         PasswordTracker passwordTracker = null;
234 
235         try {
236             passwordTracker = (PasswordTracker)obj;
237         }
238         catch (ClassCastException cce) {
239             return false;
240         }
241 
242         long pk = passwordTracker.getPrimaryKey();
243 
244         if (getPrimaryKey() == pk) {
245             return true;
246         }
247         else {
248             return false;
249         }
250     }
251 
252     public int hashCode() {
253         return (int)getPrimaryKey();
254     }
255 
256     public String toString() {
257         StringBuilder sb = new StringBuilder();
258 
259         sb.append("{passwordTrackerId=");
260         sb.append(getPasswordTrackerId());
261         sb.append(", userId=");
262         sb.append(getUserId());
263         sb.append(", createDate=");
264         sb.append(getCreateDate());
265         sb.append(", password=");
266         sb.append(getPassword());
267         sb.append("}");
268 
269         return sb.toString();
270     }
271 
272     public String toXmlString() {
273         StringBuilder sb = new StringBuilder();
274 
275         sb.append("<model><model-name>");
276         sb.append("com.liferay.portal.model.PasswordTracker");
277         sb.append("</model-name>");
278 
279         sb.append(
280             "<column><column-name>passwordTrackerId</column-name><column-value><![CDATA[");
281         sb.append(getPasswordTrackerId());
282         sb.append("]]></column-value></column>");
283         sb.append(
284             "<column><column-name>userId</column-name><column-value><![CDATA[");
285         sb.append(getUserId());
286         sb.append("]]></column-value></column>");
287         sb.append(
288             "<column><column-name>createDate</column-name><column-value><![CDATA[");
289         sb.append(getCreateDate());
290         sb.append("]]></column-value></column>");
291         sb.append(
292             "<column><column-name>password</column-name><column-value><![CDATA[");
293         sb.append(getPassword());
294         sb.append("]]></column-value></column>");
295 
296         sb.append("</model>");
297 
298         return sb.toString();
299     }
300 
301     private long _passwordTrackerId;
302     private long _userId;
303     private String _userUuid;
304     private Date _createDate;
305     private String _password;
306 }