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