001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                    _groupId = groupId;
210    
211                    if (!_setOriginalGroupId) {
212                            _setOriginalGroupId = true;
213    
214                            _originalGroupId = groupId;
215                    }
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                    _name = name;
233    
234                    if (_originalName == null) {
235                            _originalName = name;
236                    }
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 clone = new TeamImpl();
281    
282                    clone.setTeamId(getTeamId());
283                    clone.setCompanyId(getCompanyId());
284                    clone.setUserId(getUserId());
285                    clone.setUserName(getUserName());
286                    clone.setCreateDate(getCreateDate());
287                    clone.setModifiedDate(getModifiedDate());
288                    clone.setGroupId(getGroupId());
289                    clone.setName(getName());
290                    clone.setDescription(getDescription());
291    
292                    return clone;
293            }
294    
295            public int compareTo(Team team) {
296                    int value = 0;
297    
298                    value = getName().compareTo(team.getName());
299    
300                    if (value != 0) {
301                            return value;
302                    }
303    
304                    return 0;
305            }
306    
307            public boolean equals(Object obj) {
308                    if (obj == null) {
309                            return false;
310                    }
311    
312                    Team team = null;
313    
314                    try {
315                            team = (Team)obj;
316                    }
317                    catch (ClassCastException cce) {
318                            return false;
319                    }
320    
321                    long pk = team.getPrimaryKey();
322    
323                    if (getPrimaryKey() == pk) {
324                            return true;
325                    }
326                    else {
327                            return false;
328                    }
329            }
330    
331            public int hashCode() {
332                    return (int)getPrimaryKey();
333            }
334    
335            public String toString() {
336                    StringBundler sb = new StringBundler(19);
337    
338                    sb.append("{teamId=");
339                    sb.append(getTeamId());
340                    sb.append(", companyId=");
341                    sb.append(getCompanyId());
342                    sb.append(", userId=");
343                    sb.append(getUserId());
344                    sb.append(", userName=");
345                    sb.append(getUserName());
346                    sb.append(", createDate=");
347                    sb.append(getCreateDate());
348                    sb.append(", modifiedDate=");
349                    sb.append(getModifiedDate());
350                    sb.append(", groupId=");
351                    sb.append(getGroupId());
352                    sb.append(", name=");
353                    sb.append(getName());
354                    sb.append(", description=");
355                    sb.append(getDescription());
356                    sb.append("}");
357    
358                    return sb.toString();
359            }
360    
361            public String toXmlString() {
362                    StringBundler sb = new StringBundler(31);
363    
364                    sb.append("<model><model-name>");
365                    sb.append("com.liferay.portal.model.Team");
366                    sb.append("</model-name>");
367    
368                    sb.append(
369                            "<column><column-name>teamId</column-name><column-value><![CDATA[");
370                    sb.append(getTeamId());
371                    sb.append("]]></column-value></column>");
372                    sb.append(
373                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
374                    sb.append(getCompanyId());
375                    sb.append("]]></column-value></column>");
376                    sb.append(
377                            "<column><column-name>userId</column-name><column-value><![CDATA[");
378                    sb.append(getUserId());
379                    sb.append("]]></column-value></column>");
380                    sb.append(
381                            "<column><column-name>userName</column-name><column-value><![CDATA[");
382                    sb.append(getUserName());
383                    sb.append("]]></column-value></column>");
384                    sb.append(
385                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
386                    sb.append(getCreateDate());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
390                    sb.append(getModifiedDate());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
394                    sb.append(getGroupId());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>name</column-name><column-value><![CDATA[");
398                    sb.append(getName());
399                    sb.append("]]></column-value></column>");
400                    sb.append(
401                            "<column><column-name>description</column-name><column-value><![CDATA[");
402                    sb.append(getDescription());
403                    sb.append("]]></column-value></column>");
404    
405                    sb.append("</model>");
406    
407                    return sb.toString();
408            }
409    
410            private long _teamId;
411            private long _companyId;
412            private long _userId;
413            private String _userUuid;
414            private String _userName;
415            private Date _createDate;
416            private Date _modifiedDate;
417            private long _groupId;
418            private long _originalGroupId;
419            private boolean _setOriginalGroupId;
420            private String _name;
421            private String _originalName;
422            private String _description;
423            private transient ExpandoBridge _expandoBridge;
424    }