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  
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.service.model.UserIdMapper
56   * @see com.liferay.portal.service.model.UserIdMapperModel
57   * @see com.liferay.portal.service.model.impl.UserIdMapperImpl
58   *
59   */
60  public class UserIdMapperModelImpl extends BaseModelImpl {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserIdMapper"),
84              true);
85  
86      public static UserIdMapper toModel(UserIdMapperSoap soapModel) {
87          UserIdMapper model = new UserIdMapperImpl();
88  
89          model.setUserIdMapperId(soapModel.getUserIdMapperId());
90          model.setUserId(soapModel.getUserId());
91          model.setType(soapModel.getType());
92          model.setDescription(soapModel.getDescription());
93          model.setExternalUserId(soapModel.getExternalUserId());
94  
95          return model;
96      }
97  
98      public static List<UserIdMapper> toModels(UserIdMapperSoap[] soapModels) {
99          List<UserIdMapper> models = new ArrayList<UserIdMapper>(soapModels.length);
100 
101         for (UserIdMapperSoap soapModel : soapModels) {
102             models.add(toModel(soapModel));
103         }
104 
105         return models;
106     }
107 
108     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
109                 "lock.expiration.time.com.liferay.portal.model.UserIdMapper"));
110 
111     public UserIdMapperModelImpl() {
112     }
113 
114     public long getPrimaryKey() {
115         return _userIdMapperId;
116     }
117 
118     public void setPrimaryKey(long pk) {
119         setUserIdMapperId(pk);
120     }
121 
122     public Serializable getPrimaryKeyObj() {
123         return new Long(_userIdMapperId);
124     }
125 
126     public long getUserIdMapperId() {
127         return _userIdMapperId;
128     }
129 
130     public void setUserIdMapperId(long userIdMapperId) {
131         if (userIdMapperId != _userIdMapperId) {
132             _userIdMapperId = userIdMapperId;
133         }
134     }
135 
136     public long getUserId() {
137         return _userId;
138     }
139 
140     public void setUserId(long userId) {
141         if (userId != _userId) {
142             _userId = userId;
143         }
144     }
145 
146     public String getType() {
147         return GetterUtil.getString(_type);
148     }
149 
150     public void setType(String type) {
151         if (((type == null) && (_type != null)) ||
152                 ((type != null) && (_type == null)) ||
153                 ((type != null) && (_type != null) && !type.equals(_type))) {
154             _type = type;
155         }
156     }
157 
158     public String getDescription() {
159         return GetterUtil.getString(_description);
160     }
161 
162     public void setDescription(String description) {
163         if (((description == null) && (_description != null)) ||
164                 ((description != null) && (_description == null)) ||
165                 ((description != null) && (_description != null) &&
166                 !description.equals(_description))) {
167             _description = description;
168         }
169     }
170 
171     public String getExternalUserId() {
172         return GetterUtil.getString(_externalUserId);
173     }
174 
175     public void setExternalUserId(String externalUserId) {
176         if (((externalUserId == null) && (_externalUserId != null)) ||
177                 ((externalUserId != null) && (_externalUserId == null)) ||
178                 ((externalUserId != null) && (_externalUserId != null) &&
179                 !externalUserId.equals(_externalUserId))) {
180             _externalUserId = externalUserId;
181         }
182     }
183 
184     public UserIdMapper toEscapedModel() {
185         if (isEscapedModel()) {
186             return (UserIdMapper)this;
187         }
188         else {
189             UserIdMapper model = new UserIdMapperImpl();
190 
191             model.setEscapedModel(true);
192 
193             model.setUserIdMapperId(getUserIdMapperId());
194             model.setUserId(getUserId());
195             model.setType(HtmlUtil.escape(getType()));
196             model.setDescription(HtmlUtil.escape(getDescription()));
197             model.setExternalUserId(HtmlUtil.escape(getExternalUserId()));
198 
199             model = (UserIdMapper)Proxy.newProxyInstance(UserIdMapper.class.getClassLoader(),
200                     new Class[] { UserIdMapper.class },
201                     new ReadOnlyBeanHandler(model));
202 
203             return model;
204         }
205     }
206 
207     public Object clone() {
208         UserIdMapperImpl clone = new UserIdMapperImpl();
209 
210         clone.setUserIdMapperId(getUserIdMapperId());
211         clone.setUserId(getUserId());
212         clone.setType(getType());
213         clone.setDescription(getDescription());
214         clone.setExternalUserId(getExternalUserId());
215 
216         return clone;
217     }
218 
219     public int compareTo(Object obj) {
220         if (obj == null) {
221             return -1;
222         }
223 
224         UserIdMapperImpl userIdMapper = (UserIdMapperImpl)obj;
225 
226         long pk = userIdMapper.getPrimaryKey();
227 
228         if (getPrimaryKey() < pk) {
229             return -1;
230         }
231         else if (getPrimaryKey() > pk) {
232             return 1;
233         }
234         else {
235             return 0;
236         }
237     }
238 
239     public boolean equals(Object obj) {
240         if (obj == null) {
241             return false;
242         }
243 
244         UserIdMapperImpl userIdMapper = null;
245 
246         try {
247             userIdMapper = (UserIdMapperImpl)obj;
248         }
249         catch (ClassCastException cce) {
250             return false;
251         }
252 
253         long pk = userIdMapper.getPrimaryKey();
254 
255         if (getPrimaryKey() == pk) {
256             return true;
257         }
258         else {
259             return false;
260         }
261     }
262 
263     public int hashCode() {
264         return (int)getPrimaryKey();
265     }
266 
267     private long _userIdMapperId;
268     private long _userId;
269     private String _type;
270     private String _description;
271     private String _externalUserId;
272 }