1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.UserTracker;
26  import com.liferay.portal.model.UserTrackerSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.Date;
36  import java.util.List;
37  
38  /**
39   * <a href="UserTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>UserTracker</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.model.UserTracker
54   * @see com.liferay.portal.model.UserTrackerModel
55   * @see com.liferay.portal.model.impl.UserTrackerImpl
56   *
57   */
58  public class UserTrackerModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "UserTracker";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "userTrackerId", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "userId", new Integer(Types.BIGINT) },
68              
69  
70              { "modifiedDate", new Integer(Types.TIMESTAMP) },
71              
72  
73              { "sessionId", new Integer(Types.VARCHAR) },
74              
75  
76              { "remoteAddr", new Integer(Types.VARCHAR) },
77              
78  
79              { "remoteHost", new Integer(Types.VARCHAR) },
80              
81  
82              { "userAgent", new Integer(Types.VARCHAR) }
83          };
84      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)";
85      public static final String TABLE_SQL_DROP = "drop table UserTracker";
86      public static final String DATA_SOURCE = "liferayDataSource";
87      public static final String SESSION_FACTORY = "liferaySessionFactory";
88      public static final String TX_MANAGER = "liferayTransactionManager";
89      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserTracker"),
91              true);
92  
93      public static UserTracker toModel(UserTrackerSoap soapModel) {
94          UserTracker model = new UserTrackerImpl();
95  
96          model.setUserTrackerId(soapModel.getUserTrackerId());
97          model.setCompanyId(soapModel.getCompanyId());
98          model.setUserId(soapModel.getUserId());
99          model.setModifiedDate(soapModel.getModifiedDate());
100         model.setSessionId(soapModel.getSessionId());
101         model.setRemoteAddr(soapModel.getRemoteAddr());
102         model.setRemoteHost(soapModel.getRemoteHost());
103         model.setUserAgent(soapModel.getUserAgent());
104 
105         return model;
106     }
107 
108     public static List<UserTracker> toModels(UserTrackerSoap[] soapModels) {
109         List<UserTracker> models = new ArrayList<UserTracker>(soapModels.length);
110 
111         for (UserTrackerSoap soapModel : soapModels) {
112             models.add(toModel(soapModel));
113         }
114 
115         return models;
116     }
117 
118     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
119                 "lock.expiration.time.com.liferay.portal.model.UserTracker"));
120 
121     public UserTrackerModelImpl() {
122     }
123 
124     public long getPrimaryKey() {
125         return _userTrackerId;
126     }
127 
128     public void setPrimaryKey(long pk) {
129         setUserTrackerId(pk);
130     }
131 
132     public Serializable getPrimaryKeyObj() {
133         return new Long(_userTrackerId);
134     }
135 
136     public long getUserTrackerId() {
137         return _userTrackerId;
138     }
139 
140     public void setUserTrackerId(long userTrackerId) {
141         if (userTrackerId != _userTrackerId) {
142             _userTrackerId = userTrackerId;
143         }
144     }
145 
146     public long getCompanyId() {
147         return _companyId;
148     }
149 
150     public void setCompanyId(long companyId) {
151         if (companyId != _companyId) {
152             _companyId = companyId;
153         }
154     }
155 
156     public long getUserId() {
157         return _userId;
158     }
159 
160     public void setUserId(long userId) {
161         if (userId != _userId) {
162             _userId = userId;
163         }
164     }
165 
166     public Date getModifiedDate() {
167         return _modifiedDate;
168     }
169 
170     public void setModifiedDate(Date modifiedDate) {
171         if (((modifiedDate == null) && (_modifiedDate != null)) ||
172                 ((modifiedDate != null) && (_modifiedDate == null)) ||
173                 ((modifiedDate != null) && (_modifiedDate != null) &&
174                 !modifiedDate.equals(_modifiedDate))) {
175             _modifiedDate = modifiedDate;
176         }
177     }
178 
179     public String getSessionId() {
180         return GetterUtil.getString(_sessionId);
181     }
182 
183     public void setSessionId(String sessionId) {
184         if (((sessionId == null) && (_sessionId != null)) ||
185                 ((sessionId != null) && (_sessionId == null)) ||
186                 ((sessionId != null) && (_sessionId != null) &&
187                 !sessionId.equals(_sessionId))) {
188             _sessionId = sessionId;
189         }
190     }
191 
192     public String getRemoteAddr() {
193         return GetterUtil.getString(_remoteAddr);
194     }
195 
196     public void setRemoteAddr(String remoteAddr) {
197         if (((remoteAddr == null) && (_remoteAddr != null)) ||
198                 ((remoteAddr != null) && (_remoteAddr == null)) ||
199                 ((remoteAddr != null) && (_remoteAddr != null) &&
200                 !remoteAddr.equals(_remoteAddr))) {
201             _remoteAddr = remoteAddr;
202         }
203     }
204 
205     public String getRemoteHost() {
206         return GetterUtil.getString(_remoteHost);
207     }
208 
209     public void setRemoteHost(String remoteHost) {
210         if (((remoteHost == null) && (_remoteHost != null)) ||
211                 ((remoteHost != null) && (_remoteHost == null)) ||
212                 ((remoteHost != null) && (_remoteHost != null) &&
213                 !remoteHost.equals(_remoteHost))) {
214             _remoteHost = remoteHost;
215         }
216     }
217 
218     public String getUserAgent() {
219         return GetterUtil.getString(_userAgent);
220     }
221 
222     public void setUserAgent(String userAgent) {
223         if (((userAgent == null) && (_userAgent != null)) ||
224                 ((userAgent != null) && (_userAgent == null)) ||
225                 ((userAgent != null) && (_userAgent != null) &&
226                 !userAgent.equals(_userAgent))) {
227             _userAgent = userAgent;
228         }
229     }
230 
231     public UserTracker toEscapedModel() {
232         if (isEscapedModel()) {
233             return (UserTracker)this;
234         }
235         else {
236             UserTracker model = new UserTrackerImpl();
237 
238             model.setNew(isNew());
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 }