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