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