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