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.HtmlUtil;
29  import com.liferay.portal.model.UserIdMapper;
30  import com.liferay.portal.model.UserIdMapperSoap;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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="UserIdMapperModelImpl.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 class is a model that represents the <code>UserIdMapper</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portal.model.UserIdMapper
61   * @see com.liferay.portal.model.UserIdMapperModel
62   * @see com.liferay.portal.model.impl.UserIdMapperImpl
63   *
64   */
65  public class UserIdMapperModelImpl extends BaseModelImpl<UserIdMapper> {
66      public static final String TABLE_NAME = "UserIdMapper";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "userIdMapperId", new Integer(Types.BIGINT) },
69              
70  
71              { "userId", new Integer(Types.BIGINT) },
72              
73  
74              { "type_", new Integer(Types.VARCHAR) },
75              
76  
77              { "description", new Integer(Types.VARCHAR) },
78              
79  
80              { "externalUserId", new Integer(Types.VARCHAR) }
81          };
82      public static final String TABLE_SQL_CREATE = "create table UserIdMapper (userIdMapperId LONG not null primary key,userId LONG,type_ VARCHAR(75) null,description VARCHAR(75) null,externalUserId VARCHAR(75) null)";
83      public static final String TABLE_SQL_DROP = "drop table UserIdMapper";
84      public static final String DATA_SOURCE = "liferayDataSource";
85      public static final String SESSION_FACTORY = "liferaySessionFactory";
86      public static final String TX_MANAGER = "liferayTransactionManager";
87      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
88                  "value.object.entity.cache.enabled.com.liferay.portal.model.UserIdMapper"),
89              true);
90      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
91                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserIdMapper"),
92              true);
93  
94      public static UserIdMapper toModel(UserIdMapperSoap soapModel) {
95          UserIdMapper model = new UserIdMapperImpl();
96  
97          model.setUserIdMapperId(soapModel.getUserIdMapperId());
98          model.setUserId(soapModel.getUserId());
99          model.setType(soapModel.getType());
100         model.setDescription(soapModel.getDescription());
101         model.setExternalUserId(soapModel.getExternalUserId());
102 
103         return model;
104     }
105 
106     public static List<UserIdMapper> toModels(UserIdMapperSoap[] soapModels) {
107         List<UserIdMapper> models = new ArrayList<UserIdMapper>(soapModels.length);
108 
109         for (UserIdMapperSoap soapModel : soapModels) {
110             models.add(toModel(soapModel));
111         }
112 
113         return models;
114     }
115 
116     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
117                 "lock.expiration.time.com.liferay.portal.model.UserIdMapper"));
118 
119     public UserIdMapperModelImpl() {
120     }
121 
122     public long getPrimaryKey() {
123         return _userIdMapperId;
124     }
125 
126     public void setPrimaryKey(long pk) {
127         setUserIdMapperId(pk);
128     }
129 
130     public Serializable getPrimaryKeyObj() {
131         return new Long(_userIdMapperId);
132     }
133 
134     public long getUserIdMapperId() {
135         return _userIdMapperId;
136     }
137 
138     public void setUserIdMapperId(long userIdMapperId) {
139         _userIdMapperId = userIdMapperId;
140     }
141 
142     public long getUserId() {
143         return _userId;
144     }
145 
146     public void setUserId(long userId) {
147         _userId = userId;
148 
149         if (!_setOriginalUserId) {
150             _setOriginalUserId = true;
151 
152             _originalUserId = userId;
153         }
154     }
155 
156     public String getUserUuid() throws SystemException {
157         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
158     }
159 
160     public void setUserUuid(String userUuid) {
161         _userUuid = userUuid;
162     }
163 
164     public long getOriginalUserId() {
165         return _originalUserId;
166     }
167 
168     public String getType() {
169         return GetterUtil.getString(_type);
170     }
171 
172     public void setType(String type) {
173         _type = type;
174 
175         if (_originalType == null) {
176             _originalType = type;
177         }
178     }
179 
180     public String getOriginalType() {
181         return GetterUtil.getString(_originalType);
182     }
183 
184     public String getDescription() {
185         return GetterUtil.getString(_description);
186     }
187 
188     public void setDescription(String description) {
189         _description = description;
190     }
191 
192     public String getExternalUserId() {
193         return GetterUtil.getString(_externalUserId);
194     }
195 
196     public void setExternalUserId(String externalUserId) {
197         _externalUserId = externalUserId;
198 
199         if (_originalExternalUserId == null) {
200             _originalExternalUserId = externalUserId;
201         }
202     }
203 
204     public String getOriginalExternalUserId() {
205         return GetterUtil.getString(_originalExternalUserId);
206     }
207 
208     public UserIdMapper toEscapedModel() {
209         if (isEscapedModel()) {
210             return (UserIdMapper)this;
211         }
212         else {
213             UserIdMapper model = new UserIdMapperImpl();
214 
215             model.setNew(isNew());
216             model.setEscapedModel(true);
217 
218             model.setUserIdMapperId(getUserIdMapperId());
219             model.setUserId(getUserId());
220             model.setType(HtmlUtil.escape(getType()));
221             model.setDescription(HtmlUtil.escape(getDescription()));
222             model.setExternalUserId(HtmlUtil.escape(getExternalUserId()));
223 
224             model = (UserIdMapper)Proxy.newProxyInstance(UserIdMapper.class.getClassLoader(),
225                     new Class[] { UserIdMapper.class },
226                     new ReadOnlyBeanHandler(model));
227 
228             return model;
229         }
230     }
231 
232     public ExpandoBridge getExpandoBridge() {
233         if (_expandoBridge == null) {
234             _expandoBridge = new ExpandoBridgeImpl(UserIdMapper.class.getName(),
235                     getPrimaryKey());
236         }
237 
238         return _expandoBridge;
239     }
240 
241     public Object clone() {
242         UserIdMapperImpl clone = new UserIdMapperImpl();
243 
244         clone.setUserIdMapperId(getUserIdMapperId());
245         clone.setUserId(getUserId());
246         clone.setType(getType());
247         clone.setDescription(getDescription());
248         clone.setExternalUserId(getExternalUserId());
249 
250         return clone;
251     }
252 
253     public int compareTo(UserIdMapper userIdMapper) {
254         long pk = userIdMapper.getPrimaryKey();
255 
256         if (getPrimaryKey() < pk) {
257             return -1;
258         }
259         else if (getPrimaryKey() > pk) {
260             return 1;
261         }
262         else {
263             return 0;
264         }
265     }
266 
267     public boolean equals(Object obj) {
268         if (obj == null) {
269             return false;
270         }
271 
272         UserIdMapper userIdMapper = null;
273 
274         try {
275             userIdMapper = (UserIdMapper)obj;
276         }
277         catch (ClassCastException cce) {
278             return false;
279         }
280 
281         long pk = userIdMapper.getPrimaryKey();
282 
283         if (getPrimaryKey() == pk) {
284             return true;
285         }
286         else {
287             return false;
288         }
289     }
290 
291     public int hashCode() {
292         return (int)getPrimaryKey();
293     }
294 
295     public String toString() {
296         StringBuilder sb = new StringBuilder();
297 
298         sb.append("{userIdMapperId=");
299         sb.append(getUserIdMapperId());
300         sb.append(", userId=");
301         sb.append(getUserId());
302         sb.append(", type=");
303         sb.append(getType());
304         sb.append(", description=");
305         sb.append(getDescription());
306         sb.append(", externalUserId=");
307         sb.append(getExternalUserId());
308         sb.append("}");
309 
310         return sb.toString();
311     }
312 
313     public String toXmlString() {
314         StringBuilder sb = new StringBuilder();
315 
316         sb.append("<model><model-name>");
317         sb.append("com.liferay.portal.model.UserIdMapper");
318         sb.append("</model-name>");
319 
320         sb.append(
321             "<column><column-name>userIdMapperId</column-name><column-value><![CDATA[");
322         sb.append(getUserIdMapperId());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>userId</column-name><column-value><![CDATA[");
326         sb.append(getUserId());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>type</column-name><column-value><![CDATA[");
330         sb.append(getType());
331         sb.append("]]></column-value></column>");
332         sb.append(
333             "<column><column-name>description</column-name><column-value><![CDATA[");
334         sb.append(getDescription());
335         sb.append("]]></column-value></column>");
336         sb.append(
337             "<column><column-name>externalUserId</column-name><column-value><![CDATA[");
338         sb.append(getExternalUserId());
339         sb.append("]]></column-value></column>");
340 
341         sb.append("</model>");
342 
343         return sb.toString();
344     }
345 
346     private long _userIdMapperId;
347     private long _userId;
348     private String _userUuid;
349     private long _originalUserId;
350     private boolean _setOriginalUserId;
351     private String _type;
352     private String _originalType;
353     private String _description;
354     private String _externalUserId;
355     private String _originalExternalUserId;
356     private transient ExpandoBridge _expandoBridge;
357 }