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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.BrowserTracker;
29  import com.liferay.portal.model.BrowserTrackerSoap;
30  import com.liferay.portal.util.PortalUtil;
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.List;
40  
41  /**
42   * <a href="BrowserTrackerModelImpl.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>BrowserTracker</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.model.BrowserTracker
57   * @see com.liferay.portal.model.BrowserTrackerModel
58   * @see com.liferay.portal.model.impl.BrowserTrackerImpl
59   *
60   */
61  public class BrowserTrackerModelImpl extends BaseModelImpl<BrowserTracker> {
62      public static final String TABLE_NAME = "BrowserTracker";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "browserTrackerId", new Integer(Types.BIGINT) },
65              
66  
67              { "userId", new Integer(Types.BIGINT) },
68              
69  
70              { "browserKey", new Integer(Types.BIGINT) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table BrowserTracker (browserTrackerId LONG not null primary key,userId LONG,browserKey LONG)";
73      public static final String TABLE_SQL_DROP = "drop table BrowserTracker";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portal.model.BrowserTracker"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portal.model.BrowserTracker"),
82              true);
83  
84      public static BrowserTracker toModel(BrowserTrackerSoap soapModel) {
85          BrowserTracker model = new BrowserTrackerImpl();
86  
87          model.setBrowserTrackerId(soapModel.getBrowserTrackerId());
88          model.setUserId(soapModel.getUserId());
89          model.setBrowserKey(soapModel.getBrowserKey());
90  
91          return model;
92      }
93  
94      public static List<BrowserTracker> toModels(BrowserTrackerSoap[] soapModels) {
95          List<BrowserTracker> models = new ArrayList<BrowserTracker>(soapModels.length);
96  
97          for (BrowserTrackerSoap soapModel : soapModels) {
98              models.add(toModel(soapModel));
99          }
100 
101         return models;
102     }
103 
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portal.model.BrowserTracker"));
106 
107     public BrowserTrackerModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _browserTrackerId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setBrowserTrackerId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_browserTrackerId);
120     }
121 
122     public long getBrowserTrackerId() {
123         return _browserTrackerId;
124     }
125 
126     public void setBrowserTrackerId(long browserTrackerId) {
127         _browserTrackerId = browserTrackerId;
128     }
129 
130     public long getUserId() {
131         return _userId;
132     }
133 
134     public void setUserId(long userId) {
135         _userId = userId;
136 
137         if (!_setOriginalUserId) {
138             _setOriginalUserId = true;
139 
140             _originalUserId = userId;
141         }
142     }
143 
144     public String getUserUuid() throws SystemException {
145         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
146     }
147 
148     public void setUserUuid(String userUuid) {
149         _userUuid = userUuid;
150     }
151 
152     public long getOriginalUserId() {
153         return _originalUserId;
154     }
155 
156     public long getBrowserKey() {
157         return _browserKey;
158     }
159 
160     public void setBrowserKey(long browserKey) {
161         _browserKey = browserKey;
162     }
163 
164     public BrowserTracker toEscapedModel() {
165         if (isEscapedModel()) {
166             return (BrowserTracker)this;
167         }
168         else {
169             BrowserTracker model = new BrowserTrackerImpl();
170 
171             model.setNew(isNew());
172             model.setEscapedModel(true);
173 
174             model.setBrowserTrackerId(getBrowserTrackerId());
175             model.setUserId(getUserId());
176             model.setBrowserKey(getBrowserKey());
177 
178             model = (BrowserTracker)Proxy.newProxyInstance(BrowserTracker.class.getClassLoader(),
179                     new Class[] { BrowserTracker.class },
180                     new ReadOnlyBeanHandler(model));
181 
182             return model;
183         }
184     }
185 
186     public Object clone() {
187         BrowserTrackerImpl clone = new BrowserTrackerImpl();
188 
189         clone.setBrowserTrackerId(getBrowserTrackerId());
190         clone.setUserId(getUserId());
191         clone.setBrowserKey(getBrowserKey());
192 
193         return clone;
194     }
195 
196     public int compareTo(BrowserTracker browserTracker) {
197         long pk = browserTracker.getPrimaryKey();
198 
199         if (getPrimaryKey() < pk) {
200             return -1;
201         }
202         else if (getPrimaryKey() > pk) {
203             return 1;
204         }
205         else {
206             return 0;
207         }
208     }
209 
210     public boolean equals(Object obj) {
211         if (obj == null) {
212             return false;
213         }
214 
215         BrowserTracker browserTracker = null;
216 
217         try {
218             browserTracker = (BrowserTracker)obj;
219         }
220         catch (ClassCastException cce) {
221             return false;
222         }
223 
224         long pk = browserTracker.getPrimaryKey();
225 
226         if (getPrimaryKey() == pk) {
227             return true;
228         }
229         else {
230             return false;
231         }
232     }
233 
234     public int hashCode() {
235         return (int)getPrimaryKey();
236     }
237 
238     public String toString() {
239         StringBuilder sb = new StringBuilder();
240 
241         sb.append("{browserTrackerId=");
242         sb.append(getBrowserTrackerId());
243         sb.append(", userId=");
244         sb.append(getUserId());
245         sb.append(", browserKey=");
246         sb.append(getBrowserKey());
247         sb.append("}");
248 
249         return sb.toString();
250     }
251 
252     public String toXmlString() {
253         StringBuilder sb = new StringBuilder();
254 
255         sb.append("<model><model-name>");
256         sb.append("com.liferay.portal.model.BrowserTracker");
257         sb.append("</model-name>");
258 
259         sb.append(
260             "<column><column-name>browserTrackerId</column-name><column-value><![CDATA[");
261         sb.append(getBrowserTrackerId());
262         sb.append("]]></column-value></column>");
263         sb.append(
264             "<column><column-name>userId</column-name><column-value><![CDATA[");
265         sb.append(getUserId());
266         sb.append("]]></column-value></column>");
267         sb.append(
268             "<column><column-name>browserKey</column-name><column-value><![CDATA[");
269         sb.append(getBrowserKey());
270         sb.append("]]></column-value></column>");
271 
272         sb.append("</model>");
273 
274         return sb.toString();
275     }
276 
277     private long _browserTrackerId;
278     private long _userId;
279     private long _originalUserId;
280     private boolean _setOriginalUserId;
281     private String _userUuid;
282     private long _browserKey;
283 }