1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.UserTracker;
29  import com.liferay.portal.model.UserTrackerSoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="UserTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>UserTracker</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portal.service.model.UserTracker
58   * @see com.liferay.portal.service.model.UserTrackerModel
59   * @see com.liferay.portal.service.model.impl.UserTrackerImpl
60   *
61   */
62  public class UserTrackerModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "UserTracker";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "userTrackerId", new Integer(Types.BIGINT) },
66              
67  
68              { "companyId", new Integer(Types.BIGINT) },
69              
70  
71              { "userId", new Integer(Types.BIGINT) },
72              
73  
74              { "modifiedDate", new Integer(Types.TIMESTAMP) },
75              
76  
77              { "sessionId", new Integer(Types.VARCHAR) },
78              
79  
80              { "remoteAddr", new Integer(Types.VARCHAR) },
81              
82  
83              { "remoteHost", new Integer(Types.VARCHAR) },
84              
85  
86              { "userAgent", new Integer(Types.VARCHAR) }
87          };
88      public static final String TABLE_SQL_CREATE = "create table UserTracker (userTrackerId LONG not null primary key,companyId LONG,userId LONG,modifiedDate DATE null,sessionId VARCHAR(200) null,remoteAddr VARCHAR(75) null,remoteHost VARCHAR(75) null,userAgent VARCHAR(200) null)";
89      public static final String TABLE_SQL_DROP = "drop table UserTracker";
90      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
91                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserTracker"),
92              true);
93  
94      public static UserTracker toModel(UserTrackerSoap soapModel) {
95          UserTracker model = new UserTrackerImpl();
96  
97          model.setUserTrackerId(soapModel.getUserTrackerId());
98          model.setCompanyId(soapModel.getCompanyId());
99          model.setUserId(soapModel.getUserId());
100         model.setModifiedDate(soapModel.getModifiedDate());
101         model.setSessionId(soapModel.getSessionId());
102         model.setRemoteAddr(soapModel.getRemoteAddr());
103         model.setRemoteHost(soapModel.getRemoteHost());
104         model.setUserAgent(soapModel.getUserAgent());
105 
106         return model;
107     }
108 
109     public static List<UserTracker> toModels(UserTrackerSoap[] soapModels) {
110         List<UserTracker> models = new ArrayList<UserTracker>(soapModels.length);
111 
112         for (UserTrackerSoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portal.model.UserTracker"));
121 
122     public UserTrackerModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _userTrackerId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setUserTrackerId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_userTrackerId);
135     }
136 
137     public long getUserTrackerId() {
138         return _userTrackerId;
139     }
140 
141     public void setUserTrackerId(long userTrackerId) {
142         if (userTrackerId != _userTrackerId) {
143             _userTrackerId = userTrackerId;
144         }
145     }
146 
147     public long getCompanyId() {
148         return _companyId;
149     }
150 
151     public void setCompanyId(long companyId) {
152         if (companyId != _companyId) {
153             _companyId = companyId;
154         }
155     }
156 
157     public long getUserId() {
158         return _userId;
159     }
160 
161     public void setUserId(long userId) {
162         if (userId != _userId) {
163             _userId = userId;
164         }
165     }
166 
167     public Date getModifiedDate() {
168         return _modifiedDate;
169     }
170 
171     public void setModifiedDate(Date modifiedDate) {
172         if (((modifiedDate == null) && (_modifiedDate != null)) ||
173                 ((modifiedDate != null) && (_modifiedDate == null)) ||
174                 ((modifiedDate != null) && (_modifiedDate != null) &&
175                 !modifiedDate.equals(_modifiedDate))) {
176             _modifiedDate = modifiedDate;
177         }
178     }
179 
180     public String getSessionId() {
181         return GetterUtil.getString(_sessionId);
182     }
183 
184     public void setSessionId(String sessionId) {
185         if (((sessionId == null) && (_sessionId != null)) ||
186                 ((sessionId != null) && (_sessionId == null)) ||
187                 ((sessionId != null) && (_sessionId != null) &&
188                 !sessionId.equals(_sessionId))) {
189             _sessionId = sessionId;
190         }
191     }
192 
193     public String getRemoteAddr() {
194         return GetterUtil.getString(_remoteAddr);
195     }
196 
197     public void setRemoteAddr(String remoteAddr) {
198         if (((remoteAddr == null) && (_remoteAddr != null)) ||
199                 ((remoteAddr != null) && (_remoteAddr == null)) ||
200                 ((remoteAddr != null) && (_remoteAddr != null) &&
201                 !remoteAddr.equals(_remoteAddr))) {
202             _remoteAddr = remoteAddr;
203         }
204     }
205 
206     public String getRemoteHost() {
207         return GetterUtil.getString(_remoteHost);
208     }
209 
210     public void setRemoteHost(String remoteHost) {
211         if (((remoteHost == null) && (_remoteHost != null)) ||
212                 ((remoteHost != null) && (_remoteHost == null)) ||
213                 ((remoteHost != null) && (_remoteHost != null) &&
214                 !remoteHost.equals(_remoteHost))) {
215             _remoteHost = remoteHost;
216         }
217     }
218 
219     public String getUserAgent() {
220         return GetterUtil.getString(_userAgent);
221     }
222 
223     public void setUserAgent(String userAgent) {
224         if (((userAgent == null) && (_userAgent != null)) ||
225                 ((userAgent != null) && (_userAgent == null)) ||
226                 ((userAgent != null) && (_userAgent != null) &&
227                 !userAgent.equals(_userAgent))) {
228             _userAgent = userAgent;
229         }
230     }
231 
232     public UserTracker toEscapedModel() {
233         if (isEscapedModel()) {
234             return (UserTracker)this;
235         }
236         else {
237             UserTracker model = new UserTrackerImpl();
238 
239             model.setEscapedModel(true);
240 
241             model.setUserTrackerId(getUserTrackerId());
242             model.setCompanyId(getCompanyId());
243             model.setUserId(getUserId());
244             model.setModifiedDate(getModifiedDate());
245             model.setSessionId(HtmlUtil.escape(getSessionId()));
246             model.setRemoteAddr(HtmlUtil.escape(getRemoteAddr()));
247             model.setRemoteHost(HtmlUtil.escape(getRemoteHost()));
248             model.setUserAgent(HtmlUtil.escape(getUserAgent()));
249 
250             model = (UserTracker)Proxy.newProxyInstance(UserTracker.class.getClassLoader(),
251                     new Class[] { UserTracker.class },
252                     new ReadOnlyBeanHandler(model));
253 
254             return model;
255         }
256     }
257 
258     public Object clone() {
259         UserTrackerImpl clone = new UserTrackerImpl();
260 
261         clone.setUserTrackerId(getUserTrackerId());
262         clone.setCompanyId(getCompanyId());
263         clone.setUserId(getUserId());
264         clone.setModifiedDate(getModifiedDate());
265         clone.setSessionId(getSessionId());
266         clone.setRemoteAddr(getRemoteAddr());
267         clone.setRemoteHost(getRemoteHost());
268         clone.setUserAgent(getUserAgent());
269 
270         return clone;
271     }
272 
273     public int compareTo(Object obj) {
274         if (obj == null) {
275             return -1;
276         }
277 
278         UserTrackerImpl userTracker = (UserTrackerImpl)obj;
279 
280         long pk = userTracker.getPrimaryKey();
281 
282         if (getPrimaryKey() < pk) {
283             return -1;
284         }
285         else if (getPrimaryKey() > pk) {
286             return 1;
287         }
288         else {
289             return 0;
290         }
291     }
292 
293     public boolean equals(Object obj) {
294         if (obj == null) {
295             return false;
296         }
297 
298         UserTrackerImpl userTracker = null;
299 
300         try {
301             userTracker = (UserTrackerImpl)obj;
302         }
303         catch (ClassCastException cce) {
304             return false;
305         }
306 
307         long pk = userTracker.getPrimaryKey();
308 
309         if (getPrimaryKey() == pk) {
310             return true;
311         }
312         else {
313             return false;
314         }
315     }
316 
317     public int hashCode() {
318         return (int)getPrimaryKey();
319     }
320 
321     private long _userTrackerId;
322     private long _companyId;
323     private long _userId;
324     private Date _modifiedDate;
325     private String _sessionId;
326     private String _remoteAddr;
327     private String _remoteHost;
328     private String _userAgent;
329 }