1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.Team;
23  import com.liferay.portal.model.TeamSoap;
24  import com.liferay.portal.service.ServiceContext;
25  import com.liferay.portal.util.PortalUtil;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="TeamModelImpl.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 interface is a model that represents the Team table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       TeamImpl
55   * @see       com.liferay.portal.model.Team
56   * @see       com.liferay.portal.model.TeamModel
57   * @generated
58   */
59  public class TeamModelImpl extends BaseModelImpl<Team> {
60      public static final String TABLE_NAME = "Team";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "teamId", new Integer(Types.BIGINT) },
63              { "companyId", new Integer(Types.BIGINT) },
64              { "userId", new Integer(Types.BIGINT) },
65              { "userName", new Integer(Types.VARCHAR) },
66              { "createDate", new Integer(Types.TIMESTAMP) },
67              { "modifiedDate", new Integer(Types.TIMESTAMP) },
68              { "groupId", new Integer(Types.BIGINT) },
69              { "name", new Integer(Types.VARCHAR) },
70              { "description", new Integer(Types.VARCHAR) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table Team (teamId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,groupId LONG,name VARCHAR(75) null,description STRING null)";
73      public static final String TABLE_SQL_DROP = "drop table Team";
74      public static final String ORDER_BY_JPQL = " ORDER BY team.name ASC";
75      public static final String ORDER_BY_SQL = " ORDER BY Team.name ASC";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.entity.cache.enabled.com.liferay.portal.model.Team"),
81              true);
82      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portal.model.Team"),
84              true);
85  
86      public static Team toModel(TeamSoap soapModel) {
87          Team model = new TeamImpl();
88  
89          model.setTeamId(soapModel.getTeamId());
90          model.setCompanyId(soapModel.getCompanyId());
91          model.setUserId(soapModel.getUserId());
92          model.setUserName(soapModel.getUserName());
93          model.setCreateDate(soapModel.getCreateDate());
94          model.setModifiedDate(soapModel.getModifiedDate());
95          model.setGroupId(soapModel.getGroupId());
96          model.setName(soapModel.getName());
97          model.setDescription(soapModel.getDescription());
98  
99          return model;
100     }
101 
102     public static List<Team> toModels(TeamSoap[] soapModels) {
103         List<Team> models = new ArrayList<Team>(soapModels.length);
104 
105         for (TeamSoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final String MAPPING_TABLE_USERS_TEAMS_NAME = com.liferay.portal.model.impl.UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME;
113     public static final boolean FINDER_CACHE_ENABLED_USERS_TEAMS = com.liferay.portal.model.impl.UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS;
114     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115                 "lock.expiration.time.com.liferay.portal.model.Team"));
116 
117     public TeamModelImpl() {
118     }
119 
120     public long getPrimaryKey() {
121         return _teamId;
122     }
123 
124     public void setPrimaryKey(long pk) {
125         setTeamId(pk);
126     }
127 
128     public Serializable getPrimaryKeyObj() {
129         return new Long(_teamId);
130     }
131 
132     public long getTeamId() {
133         return _teamId;
134     }
135 
136     public void setTeamId(long teamId) {
137         _teamId = teamId;
138     }
139 
140     public long getCompanyId() {
141         return _companyId;
142     }
143 
144     public void setCompanyId(long companyId) {
145         _companyId = companyId;
146     }
147 
148     public long getUserId() {
149         return _userId;
150     }
151 
152     public void setUserId(long userId) {
153         _userId = userId;
154     }
155 
156     public String getUserUuid() throws SystemException {
157         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
158     }
159 
160     public void setUserUuid(String userUuid) {
161         _userUuid = userUuid;
162     }
163 
164     public String getUserName() {
165         if (_userName == null) {
166             return StringPool.BLANK;
167         }
168         else {
169             return _userName;
170         }
171     }
172 
173     public void setUserName(String userName) {
174         _userName = userName;
175     }
176 
177     public Date getCreateDate() {
178         return _createDate;
179     }
180 
181     public void setCreateDate(Date createDate) {
182         _createDate = createDate;
183     }
184 
185     public Date getModifiedDate() {
186         return _modifiedDate;
187     }
188 
189     public void setModifiedDate(Date modifiedDate) {
190         _modifiedDate = modifiedDate;
191     }
192 
193     public long getGroupId() {
194         return _groupId;
195     }
196 
197     public void setGroupId(long groupId) {
198         _groupId = groupId;
199 
200         if (!_setOriginalGroupId) {
201             _setOriginalGroupId = true;
202 
203             _originalGroupId = groupId;
204         }
205     }
206 
207     public long getOriginalGroupId() {
208         return _originalGroupId;
209     }
210 
211     public String getName() {
212         if (_name == null) {
213             return StringPool.BLANK;
214         }
215         else {
216             return _name;
217         }
218     }
219 
220     public void setName(String name) {
221         _name = name;
222 
223         if (_originalName == null) {
224             _originalName = name;
225         }
226     }
227 
228     public String getOriginalName() {
229         return GetterUtil.getString(_originalName);
230     }
231 
232     public String getDescription() {
233         if (_description == null) {
234             return StringPool.BLANK;
235         }
236         else {
237             return _description;
238         }
239     }
240 
241     public void setDescription(String description) {
242         _description = description;
243     }
244 
245     public Team toEscapedModel() {
246         if (isEscapedModel()) {
247             return (Team)this;
248         }
249         else {
250             return (Team)Proxy.newProxyInstance(Team.class.getClassLoader(),
251                 new Class[] { Team.class }, new AutoEscapeBeanHandler(this));
252         }
253     }
254 
255     public ExpandoBridge getExpandoBridge() {
256         if (_expandoBridge == null) {
257             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
258                     Team.class.getName(), getPrimaryKey());
259         }
260 
261         return _expandoBridge;
262     }
263 
264     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
265         getExpandoBridge().setAttributes(serviceContext);
266     }
267 
268     public Object clone() {
269         TeamImpl clone = new TeamImpl();
270 
271         clone.setTeamId(getTeamId());
272         clone.setCompanyId(getCompanyId());
273         clone.setUserId(getUserId());
274         clone.setUserName(getUserName());
275         clone.setCreateDate(getCreateDate());
276         clone.setModifiedDate(getModifiedDate());
277         clone.setGroupId(getGroupId());
278         clone.setName(getName());
279         clone.setDescription(getDescription());
280 
281         return clone;
282     }
283 
284     public int compareTo(Team team) {
285         int value = 0;
286 
287         value = getName().compareTo(team.getName());
288 
289         if (value != 0) {
290             return value;
291         }
292 
293         return 0;
294     }
295 
296     public boolean equals(Object obj) {
297         if (obj == null) {
298             return false;
299         }
300 
301         Team team = null;
302 
303         try {
304             team = (Team)obj;
305         }
306         catch (ClassCastException cce) {
307             return false;
308         }
309 
310         long pk = team.getPrimaryKey();
311 
312         if (getPrimaryKey() == pk) {
313             return true;
314         }
315         else {
316             return false;
317         }
318     }
319 
320     public int hashCode() {
321         return (int)getPrimaryKey();
322     }
323 
324     public String toString() {
325         StringBundler sb = new StringBundler(19);
326 
327         sb.append("{teamId=");
328         sb.append(getTeamId());
329         sb.append(", companyId=");
330         sb.append(getCompanyId());
331         sb.append(", userId=");
332         sb.append(getUserId());
333         sb.append(", userName=");
334         sb.append(getUserName());
335         sb.append(", createDate=");
336         sb.append(getCreateDate());
337         sb.append(", modifiedDate=");
338         sb.append(getModifiedDate());
339         sb.append(", groupId=");
340         sb.append(getGroupId());
341         sb.append(", name=");
342         sb.append(getName());
343         sb.append(", description=");
344         sb.append(getDescription());
345         sb.append("}");
346 
347         return sb.toString();
348     }
349 
350     public String toXmlString() {
351         StringBundler sb = new StringBundler(31);
352 
353         sb.append("<model><model-name>");
354         sb.append("com.liferay.portal.model.Team");
355         sb.append("</model-name>");
356 
357         sb.append(
358             "<column><column-name>teamId</column-name><column-value><![CDATA[");
359         sb.append(getTeamId());
360         sb.append("]]></column-value></column>");
361         sb.append(
362             "<column><column-name>companyId</column-name><column-value><![CDATA[");
363         sb.append(getCompanyId());
364         sb.append("]]></column-value></column>");
365         sb.append(
366             "<column><column-name>userId</column-name><column-value><![CDATA[");
367         sb.append(getUserId());
368         sb.append("]]></column-value></column>");
369         sb.append(
370             "<column><column-name>userName</column-name><column-value><![CDATA[");
371         sb.append(getUserName());
372         sb.append("]]></column-value></column>");
373         sb.append(
374             "<column><column-name>createDate</column-name><column-value><![CDATA[");
375         sb.append(getCreateDate());
376         sb.append("]]></column-value></column>");
377         sb.append(
378             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
379         sb.append(getModifiedDate());
380         sb.append("]]></column-value></column>");
381         sb.append(
382             "<column><column-name>groupId</column-name><column-value><![CDATA[");
383         sb.append(getGroupId());
384         sb.append("]]></column-value></column>");
385         sb.append(
386             "<column><column-name>name</column-name><column-value><![CDATA[");
387         sb.append(getName());
388         sb.append("]]></column-value></column>");
389         sb.append(
390             "<column><column-name>description</column-name><column-value><![CDATA[");
391         sb.append(getDescription());
392         sb.append("]]></column-value></column>");
393 
394         sb.append("</model>");
395 
396         return sb.toString();
397     }
398 
399     private long _teamId;
400     private long _companyId;
401     private long _userId;
402     private String _userUuid;
403     private String _userName;
404     private Date _createDate;
405     private Date _modifiedDate;
406     private long _groupId;
407     private long _originalGroupId;
408     private boolean _setOriginalGroupId;
409     private String _name;
410     private String _originalName;
411     private String _description;
412     private transient ExpandoBridge _expandoBridge;
413 }