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 com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="UserIdMapperModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>UserIdMapper</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.model.UserIdMapper
59   * @see com.liferay.portal.model.UserIdMapperModel
60   * @see com.liferay.portal.model.impl.UserIdMapperImpl
61   *
62   */
63  public class UserIdMapperModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "UserIdMapper";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "userIdMapperId", new Integer(Types.BIGINT) },
67              
68  
69              { "userId", new Integer(Types.BIGINT) },
70              
71  
72              { "type_", new Integer(Types.VARCHAR) },
73              
74  
75              { "description", new Integer(Types.VARCHAR) },
76              
77  
78              { "externalUserId", new Integer(Types.VARCHAR) }
79          };
80      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)";
81      public static final String TABLE_SQL_DROP = "drop table UserIdMapper";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean 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         if (userIdMapperId != _userIdMapperId) {
135             _userIdMapperId = userIdMapperId;
136         }
137     }
138 
139     public long getUserId() {
140         return _userId;
141     }
142 
143     public void setUserId(long userId) {
144         if (userId != _userId) {
145             _userId = userId;
146         }
147     }
148 
149     public String getType() {
150         return GetterUtil.getString(_type);
151     }
152 
153     public void setType(String type) {
154         if (((type == null) && (_type != null)) ||
155                 ((type != null) && (_type == null)) ||
156                 ((type != null) && (_type != null) && !type.equals(_type))) {
157             _type = type;
158         }
159     }
160 
161     public String getDescription() {
162         return GetterUtil.getString(_description);
163     }
164 
165     public void setDescription(String description) {
166         if (((description == null) && (_description != null)) ||
167                 ((description != null) && (_description == null)) ||
168                 ((description != null) && (_description != null) &&
169                 !description.equals(_description))) {
170             _description = description;
171         }
172     }
173 
174     public String getExternalUserId() {
175         return GetterUtil.getString(_externalUserId);
176     }
177 
178     public void setExternalUserId(String externalUserId) {
179         if (((externalUserId == null) && (_externalUserId != null)) ||
180                 ((externalUserId != null) && (_externalUserId == null)) ||
181                 ((externalUserId != null) && (_externalUserId != null) &&
182                 !externalUserId.equals(_externalUserId))) {
183             _externalUserId = externalUserId;
184         }
185     }
186 
187     public UserIdMapper toEscapedModel() {
188         if (isEscapedModel()) {
189             return (UserIdMapper)this;
190         }
191         else {
192             UserIdMapper model = new UserIdMapperImpl();
193 
194             model.setNew(isNew());
195             model.setEscapedModel(true);
196 
197             model.setUserIdMapperId(getUserIdMapperId());
198             model.setUserId(getUserId());
199             model.setType(HtmlUtil.escape(getType()));
200             model.setDescription(HtmlUtil.escape(getDescription()));
201             model.setExternalUserId(HtmlUtil.escape(getExternalUserId()));
202 
203             model = (UserIdMapper)Proxy.newProxyInstance(UserIdMapper.class.getClassLoader(),
204                     new Class[] { UserIdMapper.class },
205                     new ReadOnlyBeanHandler(model));
206 
207             return model;
208         }
209     }
210 
211     public ExpandoBridge getExpandoBridge() {
212         if (_expandoBridge == null) {
213             _expandoBridge = new ExpandoBridgeImpl(UserIdMapper.class.getName(),
214                     getPrimaryKey());
215         }
216 
217         return _expandoBridge;
218     }
219 
220     public Object clone() {
221         UserIdMapperImpl clone = new UserIdMapperImpl();
222 
223         clone.setUserIdMapperId(getUserIdMapperId());
224         clone.setUserId(getUserId());
225         clone.setType(getType());
226         clone.setDescription(getDescription());
227         clone.setExternalUserId(getExternalUserId());
228 
229         return clone;
230     }
231 
232     public int compareTo(Object obj) {
233         if (obj == null) {
234             return -1;
235         }
236 
237         UserIdMapperImpl userIdMapper = (UserIdMapperImpl)obj;
238 
239         long pk = userIdMapper.getPrimaryKey();
240 
241         if (getPrimaryKey() < pk) {
242             return -1;
243         }
244         else if (getPrimaryKey() > pk) {
245             return 1;
246         }
247         else {
248             return 0;
249         }
250     }
251 
252     public boolean equals(Object obj) {
253         if (obj == null) {
254             return false;
255         }
256 
257         UserIdMapperImpl userIdMapper = null;
258 
259         try {
260             userIdMapper = (UserIdMapperImpl)obj;
261         }
262         catch (ClassCastException cce) {
263             return false;
264         }
265 
266         long pk = userIdMapper.getPrimaryKey();
267 
268         if (getPrimaryKey() == pk) {
269             return true;
270         }
271         else {
272             return false;
273         }
274     }
275 
276     public int hashCode() {
277         return (int)getPrimaryKey();
278     }
279 
280     private long _userIdMapperId;
281     private long _userId;
282     private String _type;
283     private String _description;
284     private String _externalUserId;
285     private transient ExpandoBridge _expandoBridge;
286 }