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.model.UserTracker;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.Date;
39  
40  /**
41   * <a href="UserTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>UserTracker</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.service.model.UserTracker
56   * @see com.liferay.portal.service.model.UserTrackerModel
57   * @see com.liferay.portal.service.model.impl.UserTrackerImpl
58   *
59   */
60  public class UserTrackerModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "UserTracker";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "userTrackerId", new Integer(Types.BIGINT) },
64              
65  
66              { "companyId", new Integer(Types.BIGINT) },
67              
68  
69              { "userId", new Integer(Types.BIGINT) },
70              
71  
72              { "modifiedDate", new Integer(Types.TIMESTAMP) },
73              
74  
75              { "sessionId", new Integer(Types.VARCHAR) },
76              
77  
78              { "remoteAddr", new Integer(Types.VARCHAR) },
79              
80  
81              { "remoteHost", new Integer(Types.VARCHAR) },
82              
83  
84              { "userAgent", new Integer(Types.VARCHAR) }
85          };
86      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)";
87      public static final String TABLE_SQL_DROP = "drop table UserTracker";
88      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserTracker"),
90              true);
91      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
92                  "lock.expiration.time.com.liferay.portal.model.UserTracker"));
93  
94      public UserTrackerModelImpl() {
95      }
96  
97      public long getPrimaryKey() {
98          return _userTrackerId;
99      }
100 
101     public void setPrimaryKey(long pk) {
102         setUserTrackerId(pk);
103     }
104 
105     public Serializable getPrimaryKeyObj() {
106         return new Long(_userTrackerId);
107     }
108 
109     public long getUserTrackerId() {
110         return _userTrackerId;
111     }
112 
113     public void setUserTrackerId(long userTrackerId) {
114         if (userTrackerId != _userTrackerId) {
115             _userTrackerId = userTrackerId;
116         }
117     }
118 
119     public long getCompanyId() {
120         return _companyId;
121     }
122 
123     public void setCompanyId(long companyId) {
124         if (companyId != _companyId) {
125             _companyId = companyId;
126         }
127     }
128 
129     public long getUserId() {
130         return _userId;
131     }
132 
133     public void setUserId(long userId) {
134         if (userId != _userId) {
135             _userId = userId;
136         }
137     }
138 
139     public Date getModifiedDate() {
140         return _modifiedDate;
141     }
142 
143     public void setModifiedDate(Date modifiedDate) {
144         if (((modifiedDate == null) && (_modifiedDate != null)) ||
145                 ((modifiedDate != null) && (_modifiedDate == null)) ||
146                 ((modifiedDate != null) && (_modifiedDate != null) &&
147                 !modifiedDate.equals(_modifiedDate))) {
148             _modifiedDate = modifiedDate;
149         }
150     }
151 
152     public String getSessionId() {
153         return GetterUtil.getString(_sessionId);
154     }
155 
156     public void setSessionId(String sessionId) {
157         if (((sessionId == null) && (_sessionId != null)) ||
158                 ((sessionId != null) && (_sessionId == null)) ||
159                 ((sessionId != null) && (_sessionId != null) &&
160                 !sessionId.equals(_sessionId))) {
161             _sessionId = sessionId;
162         }
163     }
164 
165     public String getRemoteAddr() {
166         return GetterUtil.getString(_remoteAddr);
167     }
168 
169     public void setRemoteAddr(String remoteAddr) {
170         if (((remoteAddr == null) && (_remoteAddr != null)) ||
171                 ((remoteAddr != null) && (_remoteAddr == null)) ||
172                 ((remoteAddr != null) && (_remoteAddr != null) &&
173                 !remoteAddr.equals(_remoteAddr))) {
174             _remoteAddr = remoteAddr;
175         }
176     }
177 
178     public String getRemoteHost() {
179         return GetterUtil.getString(_remoteHost);
180     }
181 
182     public void setRemoteHost(String remoteHost) {
183         if (((remoteHost == null) && (_remoteHost != null)) ||
184                 ((remoteHost != null) && (_remoteHost == null)) ||
185                 ((remoteHost != null) && (_remoteHost != null) &&
186                 !remoteHost.equals(_remoteHost))) {
187             _remoteHost = remoteHost;
188         }
189     }
190 
191     public String getUserAgent() {
192         return GetterUtil.getString(_userAgent);
193     }
194 
195     public void setUserAgent(String userAgent) {
196         if (((userAgent == null) && (_userAgent != null)) ||
197                 ((userAgent != null) && (_userAgent == null)) ||
198                 ((userAgent != null) && (_userAgent != null) &&
199                 !userAgent.equals(_userAgent))) {
200             _userAgent = userAgent;
201         }
202     }
203 
204     public UserTracker toEscapedModel() {
205         if (isEscapedModel()) {
206             return (UserTracker)this;
207         }
208         else {
209             UserTracker model = new UserTrackerImpl();
210 
211             model.setEscapedModel(true);
212 
213             model.setUserTrackerId(getUserTrackerId());
214             model.setCompanyId(getCompanyId());
215             model.setUserId(getUserId());
216             model.setModifiedDate(getModifiedDate());
217             model.setSessionId(Html.escape(getSessionId()));
218             model.setRemoteAddr(Html.escape(getRemoteAddr()));
219             model.setRemoteHost(Html.escape(getRemoteHost()));
220             model.setUserAgent(Html.escape(getUserAgent()));
221 
222             model = (UserTracker)Proxy.newProxyInstance(UserTracker.class.getClassLoader(),
223                     new Class[] { UserTracker.class },
224                     new ReadOnlyBeanHandler(model));
225 
226             return model;
227         }
228     }
229 
230     public Object clone() {
231         UserTrackerImpl clone = new UserTrackerImpl();
232 
233         clone.setUserTrackerId(getUserTrackerId());
234         clone.setCompanyId(getCompanyId());
235         clone.setUserId(getUserId());
236         clone.setModifiedDate(getModifiedDate());
237         clone.setSessionId(getSessionId());
238         clone.setRemoteAddr(getRemoteAddr());
239         clone.setRemoteHost(getRemoteHost());
240         clone.setUserAgent(getUserAgent());
241 
242         return clone;
243     }
244 
245     public int compareTo(Object obj) {
246         if (obj == null) {
247             return -1;
248         }
249 
250         UserTrackerImpl userTracker = (UserTrackerImpl)obj;
251 
252         long pk = userTracker.getPrimaryKey();
253 
254         if (getPrimaryKey() < pk) {
255             return -1;
256         }
257         else if (getPrimaryKey() > pk) {
258             return 1;
259         }
260         else {
261             return 0;
262         }
263     }
264 
265     public boolean equals(Object obj) {
266         if (obj == null) {
267             return false;
268         }
269 
270         UserTrackerImpl userTracker = null;
271 
272         try {
273             userTracker = (UserTrackerImpl)obj;
274         }
275         catch (ClassCastException cce) {
276             return false;
277         }
278 
279         long pk = userTracker.getPrimaryKey();
280 
281         if (getPrimaryKey() == pk) {
282             return true;
283         }
284         else {
285             return false;
286         }
287     }
288 
289     public int hashCode() {
290         return (int)getPrimaryKey();
291     }
292 
293     private long _userTrackerId;
294     private long _companyId;
295     private long _userId;
296     private Date _modifiedDate;
297     private String _sessionId;
298     private String _remoteAddr;
299     private String _remoteHost;
300     private String _userAgent;
301 }