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