001    /**
002     * Copyright (c) 2000-2011 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     * The base model implementation for the Team service. Represents a row in the "Team" database table, with each column mapped to a property of this class.
043     *
044     * <p>
045     * This implementation and its corresponding interface {@link com.liferay.portal.model.TeamModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link TeamImpl}.
046     * </p>
047     *
048     * <p>
049     * Never modify or reference this class directly. All methods that expect a team model instance should use the {@link com.liferay.portal.model.Team} interface instead.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @see TeamImpl
054     * @see com.liferay.portal.model.Team
055     * @see com.liferay.portal.model.TeamModel
056     * @generated
057     */
058    public class TeamModelImpl extends BaseModelImpl<Team> implements TeamModel {
059            public static final String TABLE_NAME = "Team";
060            public static final Object[][] TABLE_COLUMNS = {
061                            { "teamId", new Integer(Types.BIGINT) },
062                            { "companyId", new Integer(Types.BIGINT) },
063                            { "userId", new Integer(Types.BIGINT) },
064                            { "userName", new Integer(Types.VARCHAR) },
065                            { "createDate", new Integer(Types.TIMESTAMP) },
066                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
067                            { "groupId", new Integer(Types.BIGINT) },
068                            { "name", new Integer(Types.VARCHAR) },
069                            { "description", new Integer(Types.VARCHAR) }
070                    };
071            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)";
072            public static final String TABLE_SQL_DROP = "drop table Team";
073            public static final String ORDER_BY_JPQL = " ORDER BY team.name ASC";
074            public static final String ORDER_BY_SQL = " ORDER BY Team.name ASC";
075            public static final String DATA_SOURCE = "liferayDataSource";
076            public static final String SESSION_FACTORY = "liferaySessionFactory";
077            public static final String TX_MANAGER = "liferayTransactionManager";
078            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Team"),
080                            true);
081            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Team"),
083                            true);
084    
085            /**
086             * Converts the soap model instance into a normal model instance.
087             *
088             * @param soapModel the soap model instance to convert
089             * @return the normal model instance
090             */
091            public static Team toModel(TeamSoap soapModel) {
092                    Team model = new TeamImpl();
093    
094                    model.setTeamId(soapModel.getTeamId());
095                    model.setCompanyId(soapModel.getCompanyId());
096                    model.setUserId(soapModel.getUserId());
097                    model.setUserName(soapModel.getUserName());
098                    model.setCreateDate(soapModel.getCreateDate());
099                    model.setModifiedDate(soapModel.getModifiedDate());
100                    model.setGroupId(soapModel.getGroupId());
101                    model.setName(soapModel.getName());
102                    model.setDescription(soapModel.getDescription());
103    
104                    return model;
105            }
106    
107            /**
108             * Converts the soap model instances into normal model instances.
109             *
110             * @param soapModels the soap model instances to convert
111             * @return the normal model instances
112             */
113            public static List<Team> toModels(TeamSoap[] soapModels) {
114                    List<Team> models = new ArrayList<Team>(soapModels.length);
115    
116                    for (TeamSoap soapModel : soapModels) {
117                            models.add(toModel(soapModel));
118                    }
119    
120                    return models;
121            }
122    
123            public static final String MAPPING_TABLE_USERS_TEAMS_NAME = com.liferay.portal.model.impl.UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME;
124            public static final boolean FINDER_CACHE_ENABLED_USERS_TEAMS = com.liferay.portal.model.impl.UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS;
125            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
126                                    "lock.expiration.time.com.liferay.portal.model.Team"));
127    
128            public TeamModelImpl() {
129            }
130    
131            public long getPrimaryKey() {
132                    return _teamId;
133            }
134    
135            public void setPrimaryKey(long pk) {
136                    setTeamId(pk);
137            }
138    
139            public Serializable getPrimaryKeyObj() {
140                    return new Long(_teamId);
141            }
142    
143            public long getTeamId() {
144                    return _teamId;
145            }
146    
147            public void setTeamId(long teamId) {
148                    _teamId = teamId;
149            }
150    
151            public long getCompanyId() {
152                    return _companyId;
153            }
154    
155            public void setCompanyId(long companyId) {
156                    _companyId = companyId;
157            }
158    
159            public long getUserId() {
160                    return _userId;
161            }
162    
163            public void setUserId(long userId) {
164                    _userId = userId;
165            }
166    
167            public String getUserUuid() throws SystemException {
168                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
169            }
170    
171            public void setUserUuid(String userUuid) {
172                    _userUuid = userUuid;
173            }
174    
175            public String getUserName() {
176                    if (_userName == null) {
177                            return StringPool.BLANK;
178                    }
179                    else {
180                            return _userName;
181                    }
182            }
183    
184            public void setUserName(String userName) {
185                    _userName = userName;
186            }
187    
188            public Date getCreateDate() {
189                    return _createDate;
190            }
191    
192            public void setCreateDate(Date createDate) {
193                    _createDate = createDate;
194            }
195    
196            public Date getModifiedDate() {
197                    return _modifiedDate;
198            }
199    
200            public void setModifiedDate(Date modifiedDate) {
201                    _modifiedDate = modifiedDate;
202            }
203    
204            public long getGroupId() {
205                    return _groupId;
206            }
207    
208            public void setGroupId(long groupId) {
209                    if (!_setOriginalGroupId) {
210                            _setOriginalGroupId = true;
211    
212                            _originalGroupId = _groupId;
213                    }
214    
215                    _groupId = groupId;
216            }
217    
218            public long getOriginalGroupId() {
219                    return _originalGroupId;
220            }
221    
222            public String getName() {
223                    if (_name == null) {
224                            return StringPool.BLANK;
225                    }
226                    else {
227                            return _name;
228                    }
229            }
230    
231            public void setName(String name) {
232                    if (_originalName == null) {
233                            _originalName = _name;
234                    }
235    
236                    _name = name;
237            }
238    
239            public String getOriginalName() {
240                    return GetterUtil.getString(_originalName);
241            }
242    
243            public String getDescription() {
244                    if (_description == null) {
245                            return StringPool.BLANK;
246                    }
247                    else {
248                            return _description;
249                    }
250            }
251    
252            public void setDescription(String description) {
253                    _description = description;
254            }
255    
256            public Team toEscapedModel() {
257                    if (isEscapedModel()) {
258                            return (Team)this;
259                    }
260                    else {
261                            return (Team)Proxy.newProxyInstance(Team.class.getClassLoader(),
262                                    new Class[] { Team.class }, new AutoEscapeBeanHandler(this));
263                    }
264            }
265    
266            public ExpandoBridge getExpandoBridge() {
267                    if (_expandoBridge == null) {
268                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
269                                            Team.class.getName(), getPrimaryKey());
270                    }
271    
272                    return _expandoBridge;
273            }
274    
275            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
276                    getExpandoBridge().setAttributes(serviceContext);
277            }
278    
279            public Object clone() {
280                    TeamImpl teamImpl = new TeamImpl();
281    
282                    teamImpl.setTeamId(getTeamId());
283    
284                    teamImpl.setCompanyId(getCompanyId());
285    
286                    teamImpl.setUserId(getUserId());
287    
288                    teamImpl.setUserName(getUserName());
289    
290                    teamImpl.setCreateDate(getCreateDate());
291    
292                    teamImpl.setModifiedDate(getModifiedDate());
293    
294                    teamImpl.setGroupId(getGroupId());
295    
296                    TeamModelImpl teamModelImpl = teamImpl;
297    
298                    teamModelImpl._originalGroupId = teamModelImpl._groupId;
299    
300                    teamModelImpl._setOriginalGroupId = false;
301                    teamImpl.setName(getName());
302    
303                    teamModelImpl._originalName = teamModelImpl._name;
304    
305                    teamImpl.setDescription(getDescription());
306    
307                    return teamImpl;
308            }
309    
310            public int compareTo(Team team) {
311                    int value = 0;
312    
313                    value = getName().compareTo(team.getName());
314    
315                    if (value != 0) {
316                            return value;
317                    }
318    
319                    return 0;
320            }
321    
322            public boolean equals(Object obj) {
323                    if (obj == null) {
324                            return false;
325                    }
326    
327                    Team team = null;
328    
329                    try {
330                            team = (Team)obj;
331                    }
332                    catch (ClassCastException cce) {
333                            return false;
334                    }
335    
336                    long pk = team.getPrimaryKey();
337    
338                    if (getPrimaryKey() == pk) {
339                            return true;
340                    }
341                    else {
342                            return false;
343                    }
344            }
345    
346            public int hashCode() {
347                    return (int)getPrimaryKey();
348            }
349    
350            public String toString() {
351                    StringBundler sb = new StringBundler(19);
352    
353                    sb.append("{teamId=");
354                    sb.append(getTeamId());
355                    sb.append(", companyId=");
356                    sb.append(getCompanyId());
357                    sb.append(", userId=");
358                    sb.append(getUserId());
359                    sb.append(", userName=");
360                    sb.append(getUserName());
361                    sb.append(", createDate=");
362                    sb.append(getCreateDate());
363                    sb.append(", modifiedDate=");
364                    sb.append(getModifiedDate());
365                    sb.append(", groupId=");
366                    sb.append(getGroupId());
367                    sb.append(", name=");
368                    sb.append(getName());
369                    sb.append(", description=");
370                    sb.append(getDescription());
371                    sb.append("}");
372    
373                    return sb.toString();
374            }
375    
376            public String toXmlString() {
377                    StringBundler sb = new StringBundler(31);
378    
379                    sb.append("<model><model-name>");
380                    sb.append("com.liferay.portal.model.Team");
381                    sb.append("</model-name>");
382    
383                    sb.append(
384                            "<column><column-name>teamId</column-name><column-value><![CDATA[");
385                    sb.append(getTeamId());
386                    sb.append("]]></column-value></column>");
387                    sb.append(
388                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
389                    sb.append(getCompanyId());
390                    sb.append("]]></column-value></column>");
391                    sb.append(
392                            "<column><column-name>userId</column-name><column-value><![CDATA[");
393                    sb.append(getUserId());
394                    sb.append("]]></column-value></column>");
395                    sb.append(
396                            "<column><column-name>userName</column-name><column-value><![CDATA[");
397                    sb.append(getUserName());
398                    sb.append("]]></column-value></column>");
399                    sb.append(
400                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
401                    sb.append(getCreateDate());
402                    sb.append("]]></column-value></column>");
403                    sb.append(
404                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
405                    sb.append(getModifiedDate());
406                    sb.append("]]></column-value></column>");
407                    sb.append(
408                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
409                    sb.append(getGroupId());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>name</column-name><column-value><![CDATA[");
413                    sb.append(getName());
414                    sb.append("]]></column-value></column>");
415                    sb.append(
416                            "<column><column-name>description</column-name><column-value><![CDATA[");
417                    sb.append(getDescription());
418                    sb.append("]]></column-value></column>");
419    
420                    sb.append("</model>");
421    
422                    return sb.toString();
423            }
424    
425            private long _teamId;
426            private long _companyId;
427            private long _userId;
428            private String _userUuid;
429            private String _userName;
430            private Date _createDate;
431            private Date _modifiedDate;
432            private long _groupId;
433            private long _originalGroupId;
434            private boolean _setOriginalGroupId;
435            private String _name;
436            private String _originalName;
437            private String _description;
438            private transient ExpandoBridge _expandoBridge;
439    }