001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.Team;
023    import com.liferay.portal.model.TeamModel;
024    import com.liferay.portal.model.TeamSoap;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    
031    import java.io.Serializable;
032    
033    import java.lang.reflect.Proxy;
034    
035    import java.sql.Types;
036    
037    import java.util.ArrayList;
038    import java.util.Date;
039    import java.util.List;
040    
041    /**
042     * <p>
043     * This interface is a model that represents the Team table in the
044     * database.
045     * </p>
046     *
047     * @author    Brian Wing Shun Chan
048     * @see       TeamImpl
049     * @see       com.liferay.portal.model.Team
050     * @see       com.liferay.portal.model.TeamModel
051     * @generated
052     */
053    public class TeamModelImpl extends BaseModelImpl<Team> implements TeamModel {
054            public static final String TABLE_NAME = "Team";
055            public static final Object[][] TABLE_COLUMNS = {
056                            { "teamId", new Integer(Types.BIGINT) },
057                            { "companyId", new Integer(Types.BIGINT) },
058                            { "userId", new Integer(Types.BIGINT) },
059                            { "userName", new Integer(Types.VARCHAR) },
060                            { "createDate", new Integer(Types.TIMESTAMP) },
061                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
062                            { "groupId", new Integer(Types.BIGINT) },
063                            { "name", new Integer(Types.VARCHAR) },
064                            { "description", new Integer(Types.VARCHAR) }
065                    };
066            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)";
067            public static final String TABLE_SQL_DROP = "drop table Team";
068            public static final String ORDER_BY_JPQL = " ORDER BY team.name ASC";
069            public static final String ORDER_BY_SQL = " ORDER BY Team.name ASC";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Team"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Team"),
078                            true);
079    
080            public static Team toModel(TeamSoap soapModel) {
081                    Team model = new TeamImpl();
082    
083                    model.setTeamId(soapModel.getTeamId());
084                    model.setCompanyId(soapModel.getCompanyId());
085                    model.setUserId(soapModel.getUserId());
086                    model.setUserName(soapModel.getUserName());
087                    model.setCreateDate(soapModel.getCreateDate());
088                    model.setModifiedDate(soapModel.getModifiedDate());
089                    model.setGroupId(soapModel.getGroupId());
090                    model.setName(soapModel.getName());
091                    model.setDescription(soapModel.getDescription());
092    
093                    return model;
094            }
095    
096            public static List<Team> toModels(TeamSoap[] soapModels) {
097                    List<Team> models = new ArrayList<Team>(soapModels.length);
098    
099                    for (TeamSoap soapModel : soapModels) {
100                            models.add(toModel(soapModel));
101                    }
102    
103                    return models;
104            }
105    
106            public static final String MAPPING_TABLE_USERS_TEAMS_NAME = com.liferay.portal.model.impl.UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME;
107            public static final boolean FINDER_CACHE_ENABLED_USERS_TEAMS = com.liferay.portal.model.impl.UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS;
108            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
109                                    "lock.expiration.time.com.liferay.portal.model.Team"));
110    
111            public TeamModelImpl() {
112            }
113    
114            public long getPrimaryKey() {
115                    return _teamId;
116            }
117    
118            public void setPrimaryKey(long pk) {
119                    setTeamId(pk);
120            }
121    
122            public Serializable getPrimaryKeyObj() {
123                    return new Long(_teamId);
124            }
125    
126            public long getTeamId() {
127                    return _teamId;
128            }
129    
130            public void setTeamId(long teamId) {
131                    _teamId = teamId;
132            }
133    
134            public long getCompanyId() {
135                    return _companyId;
136            }
137    
138            public void setCompanyId(long companyId) {
139                    _companyId = companyId;
140            }
141    
142            public long getUserId() {
143                    return _userId;
144            }
145    
146            public void setUserId(long userId) {
147                    _userId = userId;
148            }
149    
150            public String getUserUuid() throws SystemException {
151                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
152            }
153    
154            public void setUserUuid(String userUuid) {
155                    _userUuid = userUuid;
156            }
157    
158            public String getUserName() {
159                    if (_userName == null) {
160                            return StringPool.BLANK;
161                    }
162                    else {
163                            return _userName;
164                    }
165            }
166    
167            public void setUserName(String userName) {
168                    _userName = userName;
169            }
170    
171            public Date getCreateDate() {
172                    return _createDate;
173            }
174    
175            public void setCreateDate(Date createDate) {
176                    _createDate = createDate;
177            }
178    
179            public Date getModifiedDate() {
180                    return _modifiedDate;
181            }
182    
183            public void setModifiedDate(Date modifiedDate) {
184                    _modifiedDate = modifiedDate;
185            }
186    
187            public long getGroupId() {
188                    return _groupId;
189            }
190    
191            public void setGroupId(long groupId) {
192                    _groupId = groupId;
193    
194                    if (!_setOriginalGroupId) {
195                            _setOriginalGroupId = true;
196    
197                            _originalGroupId = groupId;
198                    }
199            }
200    
201            public long getOriginalGroupId() {
202                    return _originalGroupId;
203            }
204    
205            public String getName() {
206                    if (_name == null) {
207                            return StringPool.BLANK;
208                    }
209                    else {
210                            return _name;
211                    }
212            }
213    
214            public void setName(String name) {
215                    _name = name;
216    
217                    if (_originalName == null) {
218                            _originalName = name;
219                    }
220            }
221    
222            public String getOriginalName() {
223                    return GetterUtil.getString(_originalName);
224            }
225    
226            public String getDescription() {
227                    if (_description == null) {
228                            return StringPool.BLANK;
229                    }
230                    else {
231                            return _description;
232                    }
233            }
234    
235            public void setDescription(String description) {
236                    _description = description;
237            }
238    
239            public Team toEscapedModel() {
240                    if (isEscapedModel()) {
241                            return (Team)this;
242                    }
243                    else {
244                            return (Team)Proxy.newProxyInstance(Team.class.getClassLoader(),
245                                    new Class[] { Team.class }, new AutoEscapeBeanHandler(this));
246                    }
247            }
248    
249            public ExpandoBridge getExpandoBridge() {
250                    if (_expandoBridge == null) {
251                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
252                                            Team.class.getName(), getPrimaryKey());
253                    }
254    
255                    return _expandoBridge;
256            }
257    
258            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
259                    getExpandoBridge().setAttributes(serviceContext);
260            }
261    
262            public Object clone() {
263                    TeamImpl clone = new TeamImpl();
264    
265                    clone.setTeamId(getTeamId());
266                    clone.setCompanyId(getCompanyId());
267                    clone.setUserId(getUserId());
268                    clone.setUserName(getUserName());
269                    clone.setCreateDate(getCreateDate());
270                    clone.setModifiedDate(getModifiedDate());
271                    clone.setGroupId(getGroupId());
272                    clone.setName(getName());
273                    clone.setDescription(getDescription());
274    
275                    return clone;
276            }
277    
278            public int compareTo(Team team) {
279                    int value = 0;
280    
281                    value = getName().compareTo(team.getName());
282    
283                    if (value != 0) {
284                            return value;
285                    }
286    
287                    return 0;
288            }
289    
290            public boolean equals(Object obj) {
291                    if (obj == null) {
292                            return false;
293                    }
294    
295                    Team team = null;
296    
297                    try {
298                            team = (Team)obj;
299                    }
300                    catch (ClassCastException cce) {
301                            return false;
302                    }
303    
304                    long pk = team.getPrimaryKey();
305    
306                    if (getPrimaryKey() == pk) {
307                            return true;
308                    }
309                    else {
310                            return false;
311                    }
312            }
313    
314            public int hashCode() {
315                    return (int)getPrimaryKey();
316            }
317    
318            public String toString() {
319                    StringBundler sb = new StringBundler(19);
320    
321                    sb.append("{teamId=");
322                    sb.append(getTeamId());
323                    sb.append(", companyId=");
324                    sb.append(getCompanyId());
325                    sb.append(", userId=");
326                    sb.append(getUserId());
327                    sb.append(", userName=");
328                    sb.append(getUserName());
329                    sb.append(", createDate=");
330                    sb.append(getCreateDate());
331                    sb.append(", modifiedDate=");
332                    sb.append(getModifiedDate());
333                    sb.append(", groupId=");
334                    sb.append(getGroupId());
335                    sb.append(", name=");
336                    sb.append(getName());
337                    sb.append(", description=");
338                    sb.append(getDescription());
339                    sb.append("}");
340    
341                    return sb.toString();
342            }
343    
344            public String toXmlString() {
345                    StringBundler sb = new StringBundler(31);
346    
347                    sb.append("<model><model-name>");
348                    sb.append("com.liferay.portal.model.Team");
349                    sb.append("</model-name>");
350    
351                    sb.append(
352                            "<column><column-name>teamId</column-name><column-value><![CDATA[");
353                    sb.append(getTeamId());
354                    sb.append("]]></column-value></column>");
355                    sb.append(
356                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
357                    sb.append(getCompanyId());
358                    sb.append("]]></column-value></column>");
359                    sb.append(
360                            "<column><column-name>userId</column-name><column-value><![CDATA[");
361                    sb.append(getUserId());
362                    sb.append("]]></column-value></column>");
363                    sb.append(
364                            "<column><column-name>userName</column-name><column-value><![CDATA[");
365                    sb.append(getUserName());
366                    sb.append("]]></column-value></column>");
367                    sb.append(
368                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
369                    sb.append(getCreateDate());
370                    sb.append("]]></column-value></column>");
371                    sb.append(
372                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
373                    sb.append(getModifiedDate());
374                    sb.append("]]></column-value></column>");
375                    sb.append(
376                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
377                    sb.append(getGroupId());
378                    sb.append("]]></column-value></column>");
379                    sb.append(
380                            "<column><column-name>name</column-name><column-value><![CDATA[");
381                    sb.append(getName());
382                    sb.append("]]></column-value></column>");
383                    sb.append(
384                            "<column><column-name>description</column-name><column-value><![CDATA[");
385                    sb.append(getDescription());
386                    sb.append("]]></column-value></column>");
387    
388                    sb.append("</model>");
389    
390                    return sb.toString();
391            }
392    
393            private long _teamId;
394            private long _companyId;
395            private long _userId;
396            private String _userUuid;
397            private String _userName;
398            private Date _createDate;
399            private Date _modifiedDate;
400            private long _groupId;
401            private long _originalGroupId;
402            private boolean _setOriginalGroupId;
403            private String _name;
404            private String _originalName;
405            private String _description;
406            private transient ExpandoBridge _expandoBridge;
407    }