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