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.kernel.util.StringBundler;
29  import com.liferay.portal.model.BrowserTracker;
30  import com.liferay.portal.model.BrowserTrackerSoap;
31  import com.liferay.portal.service.ServiceContext;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.List;
45  
46  /**
47   * <a href="BrowserTrackerModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the BrowserTracker table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       BrowserTrackerImpl
61   * @see       com.liferay.portal.model.BrowserTracker
62   * @see       com.liferay.portal.model.BrowserTrackerModel
63   * @generated
64   */
65  public class BrowserTrackerModelImpl extends BaseModelImpl<BrowserTracker> {
66      public static final String TABLE_NAME = "BrowserTracker";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "browserTrackerId", new Integer(Types.BIGINT) },
69              { "userId", new Integer(Types.BIGINT) },
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 ExpandoBridge getExpandoBridge() {
187         if (_expandoBridge == null) {
188             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(BrowserTracker.class.getName(),
189                     getPrimaryKey());
190         }
191 
192         return _expandoBridge;
193     }
194 
195     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
196         getExpandoBridge().setAttributes(serviceContext);
197     }
198 
199     public Object clone() {
200         BrowserTrackerImpl clone = new BrowserTrackerImpl();
201 
202         clone.setBrowserTrackerId(getBrowserTrackerId());
203         clone.setUserId(getUserId());
204         clone.setBrowserKey(getBrowserKey());
205 
206         return clone;
207     }
208 
209     public int compareTo(BrowserTracker browserTracker) {
210         long pk = browserTracker.getPrimaryKey();
211 
212         if (getPrimaryKey() < pk) {
213             return -1;
214         }
215         else if (getPrimaryKey() > pk) {
216             return 1;
217         }
218         else {
219             return 0;
220         }
221     }
222 
223     public boolean equals(Object obj) {
224         if (obj == null) {
225             return false;
226         }
227 
228         BrowserTracker browserTracker = null;
229 
230         try {
231             browserTracker = (BrowserTracker)obj;
232         }
233         catch (ClassCastException cce) {
234             return false;
235         }
236 
237         long pk = browserTracker.getPrimaryKey();
238 
239         if (getPrimaryKey() == pk) {
240             return true;
241         }
242         else {
243             return false;
244         }
245     }
246 
247     public int hashCode() {
248         return (int)getPrimaryKey();
249     }
250 
251     public String toString() {
252         StringBundler sb = new StringBundler(7);
253 
254         sb.append("{browserTrackerId=");
255         sb.append(getBrowserTrackerId());
256         sb.append(", userId=");
257         sb.append(getUserId());
258         sb.append(", browserKey=");
259         sb.append(getBrowserKey());
260         sb.append("}");
261 
262         return sb.toString();
263     }
264 
265     public String toXmlString() {
266         StringBundler sb = new StringBundler(13);
267 
268         sb.append("<model><model-name>");
269         sb.append("com.liferay.portal.model.BrowserTracker");
270         sb.append("</model-name>");
271 
272         sb.append(
273             "<column><column-name>browserTrackerId</column-name><column-value><![CDATA[");
274         sb.append(getBrowserTrackerId());
275         sb.append("]]></column-value></column>");
276         sb.append(
277             "<column><column-name>userId</column-name><column-value><![CDATA[");
278         sb.append(getUserId());
279         sb.append("]]></column-value></column>");
280         sb.append(
281             "<column><column-name>browserKey</column-name><column-value><![CDATA[");
282         sb.append(getBrowserKey());
283         sb.append("]]></column-value></column>");
284 
285         sb.append("</model>");
286 
287         return sb.toString();
288     }
289 
290     private long _browserTrackerId;
291     private long _userId;
292     private String _userUuid;
293     private long _originalUserId;
294     private boolean _setOriginalUserId;
295     private long _browserKey;
296     private transient ExpandoBridge _expandoBridge;
297 }