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