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