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