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