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