001    /**
002     * Copyright (c) 2000-2013 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.json.JSON;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.Team;
026    import com.liferay.portal.model.TeamModel;
027    import com.liferay.portal.model.TeamSoap;
028    import com.liferay.portal.service.ServiceContext;
029    import com.liferay.portal.util.PortalUtil;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.HashMap;
041    import java.util.List;
042    import java.util.Map;
043    
044    /**
045     * 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.
046     *
047     * <p>
048     * 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}.
049     * </p>
050     *
051     * @author Brian Wing Shun Chan
052     * @see TeamImpl
053     * @see com.liferay.portal.model.Team
054     * @see com.liferay.portal.model.TeamModel
055     * @generated
056     */
057    @JSON(strict = true)
058    public class TeamModelImpl extends BaseModelImpl<Team> implements TeamModel {
059            /*
060             * NOTE FOR DEVELOPERS:
061             *
062             * 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.
063             */
064            public static final String TABLE_NAME = "Team";
065            public static final Object[][] TABLE_COLUMNS = {
066                            { "teamId", Types.BIGINT },
067                            { "companyId", Types.BIGINT },
068                            { "userId", Types.BIGINT },
069                            { "userName", Types.VARCHAR },
070                            { "createDate", Types.TIMESTAMP },
071                            { "modifiedDate", Types.TIMESTAMP },
072                            { "groupId", Types.BIGINT },
073                            { "name", Types.VARCHAR },
074                            { "description", Types.VARCHAR }
075                    };
076            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)";
077            public static final String TABLE_SQL_DROP = "drop table Team";
078            public static final String ORDER_BY_JPQL = " ORDER BY team.name ASC";
079            public static final String ORDER_BY_SQL = " ORDER BY Team.name ASC";
080            public static final String DATA_SOURCE = "liferayDataSource";
081            public static final String SESSION_FACTORY = "liferaySessionFactory";
082            public static final String TX_MANAGER = "liferayTransactionManager";
083            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Team"),
085                            true);
086            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Team"),
088                            true);
089            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.Team"),
091                            true);
092            public static long GROUPID_COLUMN_BITMASK = 1L;
093            public static long NAME_COLUMN_BITMASK = 2L;
094    
095            /**
096             * Converts the soap model instance into a normal model instance.
097             *
098             * @param soapModel the soap model instance to convert
099             * @return the normal model instance
100             */
101            public static Team toModel(TeamSoap soapModel) {
102                    if (soapModel == null) {
103                            return null;
104                    }
105    
106                    Team model = new TeamImpl();
107    
108                    model.setTeamId(soapModel.getTeamId());
109                    model.setCompanyId(soapModel.getCompanyId());
110                    model.setUserId(soapModel.getUserId());
111                    model.setUserName(soapModel.getUserName());
112                    model.setCreateDate(soapModel.getCreateDate());
113                    model.setModifiedDate(soapModel.getModifiedDate());
114                    model.setGroupId(soapModel.getGroupId());
115                    model.setName(soapModel.getName());
116                    model.setDescription(soapModel.getDescription());
117    
118                    return model;
119            }
120    
121            /**
122             * Converts the soap model instances into normal model instances.
123             *
124             * @param soapModels the soap model instances to convert
125             * @return the normal model instances
126             */
127            public static List<Team> toModels(TeamSoap[] soapModels) {
128                    if (soapModels == null) {
129                            return null;
130                    }
131    
132                    List<Team> models = new ArrayList<Team>(soapModels.length);
133    
134                    for (TeamSoap soapModel : soapModels) {
135                            models.add(toModel(soapModel));
136                    }
137    
138                    return models;
139            }
140    
141            public static final String MAPPING_TABLE_USERS_TEAMS_NAME = "Users_Teams";
142            public static final Object[][] MAPPING_TABLE_USERS_TEAMS_COLUMNS = {
143                            { "userId", Types.BIGINT },
144                            { "teamId", Types.BIGINT }
145                    };
146            public static final String MAPPING_TABLE_USERS_TEAMS_SQL_CREATE = "create table Users_Teams (teamId LONG not null,userId LONG not null,primary key (teamId, userId))";
147            public static final boolean FINDER_CACHE_ENABLED_USERS_TEAMS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
148                                    "value.object.finder.cache.enabled.Users_Teams"), true);
149            public static final String MAPPING_TABLE_USERGROUPS_TEAMS_NAME = "UserGroups_Teams";
150            public static final Object[][] MAPPING_TABLE_USERGROUPS_TEAMS_COLUMNS = {
151                            { "userGroupId", Types.BIGINT },
152                            { "teamId", Types.BIGINT }
153                    };
154            public static final String MAPPING_TABLE_USERGROUPS_TEAMS_SQL_CREATE = "create table UserGroups_Teams (teamId LONG not null,userGroupId LONG not null,primary key (teamId, userGroupId))";
155            public static final boolean FINDER_CACHE_ENABLED_USERGROUPS_TEAMS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
156                                    "value.object.finder.cache.enabled.UserGroups_Teams"), true);
157            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
158                                    "lock.expiration.time.com.liferay.portal.model.Team"));
159    
160            public TeamModelImpl() {
161            }
162    
163            @Override
164            public long getPrimaryKey() {
165                    return _teamId;
166            }
167    
168            @Override
169            public void setPrimaryKey(long primaryKey) {
170                    setTeamId(primaryKey);
171            }
172    
173            @Override
174            public Serializable getPrimaryKeyObj() {
175                    return _teamId;
176            }
177    
178            @Override
179            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
180                    setPrimaryKey(((Long)primaryKeyObj).longValue());
181            }
182    
183            @Override
184            public Class<?> getModelClass() {
185                    return Team.class;
186            }
187    
188            @Override
189            public String getModelClassName() {
190                    return Team.class.getName();
191            }
192    
193            @Override
194            public Map<String, Object> getModelAttributes() {
195                    Map<String, Object> attributes = new HashMap<String, Object>();
196    
197                    attributes.put("teamId", getTeamId());
198                    attributes.put("companyId", getCompanyId());
199                    attributes.put("userId", getUserId());
200                    attributes.put("userName", getUserName());
201                    attributes.put("createDate", getCreateDate());
202                    attributes.put("modifiedDate", getModifiedDate());
203                    attributes.put("groupId", getGroupId());
204                    attributes.put("name", getName());
205                    attributes.put("description", getDescription());
206    
207                    return attributes;
208            }
209    
210            @Override
211            public void setModelAttributes(Map<String, Object> attributes) {
212                    Long teamId = (Long)attributes.get("teamId");
213    
214                    if (teamId != null) {
215                            setTeamId(teamId);
216                    }
217    
218                    Long companyId = (Long)attributes.get("companyId");
219    
220                    if (companyId != null) {
221                            setCompanyId(companyId);
222                    }
223    
224                    Long userId = (Long)attributes.get("userId");
225    
226                    if (userId != null) {
227                            setUserId(userId);
228                    }
229    
230                    String userName = (String)attributes.get("userName");
231    
232                    if (userName != null) {
233                            setUserName(userName);
234                    }
235    
236                    Date createDate = (Date)attributes.get("createDate");
237    
238                    if (createDate != null) {
239                            setCreateDate(createDate);
240                    }
241    
242                    Date modifiedDate = (Date)attributes.get("modifiedDate");
243    
244                    if (modifiedDate != null) {
245                            setModifiedDate(modifiedDate);
246                    }
247    
248                    Long groupId = (Long)attributes.get("groupId");
249    
250                    if (groupId != null) {
251                            setGroupId(groupId);
252                    }
253    
254                    String name = (String)attributes.get("name");
255    
256                    if (name != null) {
257                            setName(name);
258                    }
259    
260                    String description = (String)attributes.get("description");
261    
262                    if (description != null) {
263                            setDescription(description);
264                    }
265            }
266    
267            @JSON
268            @Override
269            public long getTeamId() {
270                    return _teamId;
271            }
272    
273            @Override
274            public void setTeamId(long teamId) {
275                    _teamId = teamId;
276            }
277    
278            @JSON
279            @Override
280            public long getCompanyId() {
281                    return _companyId;
282            }
283    
284            @Override
285            public void setCompanyId(long companyId) {
286                    _companyId = companyId;
287            }
288    
289            @JSON
290            @Override
291            public long getUserId() {
292                    return _userId;
293            }
294    
295            @Override
296            public void setUserId(long userId) {
297                    _userId = userId;
298            }
299    
300            @Override
301            public String getUserUuid() throws SystemException {
302                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
303            }
304    
305            @Override
306            public void setUserUuid(String userUuid) {
307                    _userUuid = userUuid;
308            }
309    
310            @JSON
311            @Override
312            public String getUserName() {
313                    if (_userName == null) {
314                            return StringPool.BLANK;
315                    }
316                    else {
317                            return _userName;
318                    }
319            }
320    
321            @Override
322            public void setUserName(String userName) {
323                    _userName = userName;
324            }
325    
326            @JSON
327            @Override
328            public Date getCreateDate() {
329                    return _createDate;
330            }
331    
332            @Override
333            public void setCreateDate(Date createDate) {
334                    _createDate = createDate;
335            }
336    
337            @JSON
338            @Override
339            public Date getModifiedDate() {
340                    return _modifiedDate;
341            }
342    
343            @Override
344            public void setModifiedDate(Date modifiedDate) {
345                    _modifiedDate = modifiedDate;
346            }
347    
348            @JSON
349            @Override
350            public long getGroupId() {
351                    return _groupId;
352            }
353    
354            @Override
355            public void setGroupId(long groupId) {
356                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
357    
358                    if (!_setOriginalGroupId) {
359                            _setOriginalGroupId = true;
360    
361                            _originalGroupId = _groupId;
362                    }
363    
364                    _groupId = groupId;
365            }
366    
367            public long getOriginalGroupId() {
368                    return _originalGroupId;
369            }
370    
371            @JSON
372            @Override
373            public String getName() {
374                    if (_name == null) {
375                            return StringPool.BLANK;
376                    }
377                    else {
378                            return _name;
379                    }
380            }
381    
382            @Override
383            public void setName(String name) {
384                    _columnBitmask = -1L;
385    
386                    if (_originalName == null) {
387                            _originalName = _name;
388                    }
389    
390                    _name = name;
391            }
392    
393            public String getOriginalName() {
394                    return GetterUtil.getString(_originalName);
395            }
396    
397            @JSON
398            @Override
399            public String getDescription() {
400                    if (_description == null) {
401                            return StringPool.BLANK;
402                    }
403                    else {
404                            return _description;
405                    }
406            }
407    
408            @Override
409            public void setDescription(String description) {
410                    _description = description;
411            }
412    
413            public long getColumnBitmask() {
414                    return _columnBitmask;
415            }
416    
417            @Override
418            public ExpandoBridge getExpandoBridge() {
419                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
420                            Team.class.getName(), getPrimaryKey());
421            }
422    
423            @Override
424            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
425                    ExpandoBridge expandoBridge = getExpandoBridge();
426    
427                    expandoBridge.setAttributes(serviceContext);
428            }
429    
430            @Override
431            public Team toEscapedModel() {
432                    if (_escapedModel == null) {
433                            _escapedModel = (Team)ProxyUtil.newProxyInstance(_classLoader,
434                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
435                    }
436    
437                    return _escapedModel;
438            }
439    
440            @Override
441            public Object clone() {
442                    TeamImpl teamImpl = new TeamImpl();
443    
444                    teamImpl.setTeamId(getTeamId());
445                    teamImpl.setCompanyId(getCompanyId());
446                    teamImpl.setUserId(getUserId());
447                    teamImpl.setUserName(getUserName());
448                    teamImpl.setCreateDate(getCreateDate());
449                    teamImpl.setModifiedDate(getModifiedDate());
450                    teamImpl.setGroupId(getGroupId());
451                    teamImpl.setName(getName());
452                    teamImpl.setDescription(getDescription());
453    
454                    teamImpl.resetOriginalValues();
455    
456                    return teamImpl;
457            }
458    
459            @Override
460            public int compareTo(Team team) {
461                    int value = 0;
462    
463                    value = getName().compareTo(team.getName());
464    
465                    if (value != 0) {
466                            return value;
467                    }
468    
469                    return 0;
470            }
471    
472            @Override
473            public boolean equals(Object obj) {
474                    if (this == obj) {
475                            return true;
476                    }
477    
478                    if (!(obj instanceof Team)) {
479                            return false;
480                    }
481    
482                    Team team = (Team)obj;
483    
484                    long primaryKey = team.getPrimaryKey();
485    
486                    if (getPrimaryKey() == primaryKey) {
487                            return true;
488                    }
489                    else {
490                            return false;
491                    }
492            }
493    
494            @Override
495            public int hashCode() {
496                    return (int)getPrimaryKey();
497            }
498    
499            @Override
500            public void resetOriginalValues() {
501                    TeamModelImpl teamModelImpl = this;
502    
503                    teamModelImpl._originalGroupId = teamModelImpl._groupId;
504    
505                    teamModelImpl._setOriginalGroupId = false;
506    
507                    teamModelImpl._originalName = teamModelImpl._name;
508    
509                    teamModelImpl._columnBitmask = 0;
510            }
511    
512            @Override
513            public CacheModel<Team> toCacheModel() {
514                    TeamCacheModel teamCacheModel = new TeamCacheModel();
515    
516                    teamCacheModel.teamId = getTeamId();
517    
518                    teamCacheModel.companyId = getCompanyId();
519    
520                    teamCacheModel.userId = getUserId();
521    
522                    teamCacheModel.userName = getUserName();
523    
524                    String userName = teamCacheModel.userName;
525    
526                    if ((userName != null) && (userName.length() == 0)) {
527                            teamCacheModel.userName = null;
528                    }
529    
530                    Date createDate = getCreateDate();
531    
532                    if (createDate != null) {
533                            teamCacheModel.createDate = createDate.getTime();
534                    }
535                    else {
536                            teamCacheModel.createDate = Long.MIN_VALUE;
537                    }
538    
539                    Date modifiedDate = getModifiedDate();
540    
541                    if (modifiedDate != null) {
542                            teamCacheModel.modifiedDate = modifiedDate.getTime();
543                    }
544                    else {
545                            teamCacheModel.modifiedDate = Long.MIN_VALUE;
546                    }
547    
548                    teamCacheModel.groupId = getGroupId();
549    
550                    teamCacheModel.name = getName();
551    
552                    String name = teamCacheModel.name;
553    
554                    if ((name != null) && (name.length() == 0)) {
555                            teamCacheModel.name = null;
556                    }
557    
558                    teamCacheModel.description = getDescription();
559    
560                    String description = teamCacheModel.description;
561    
562                    if ((description != null) && (description.length() == 0)) {
563                            teamCacheModel.description = null;
564                    }
565    
566                    return teamCacheModel;
567            }
568    
569            @Override
570            public String toString() {
571                    StringBundler sb = new StringBundler(19);
572    
573                    sb.append("{teamId=");
574                    sb.append(getTeamId());
575                    sb.append(", companyId=");
576                    sb.append(getCompanyId());
577                    sb.append(", userId=");
578                    sb.append(getUserId());
579                    sb.append(", userName=");
580                    sb.append(getUserName());
581                    sb.append(", createDate=");
582                    sb.append(getCreateDate());
583                    sb.append(", modifiedDate=");
584                    sb.append(getModifiedDate());
585                    sb.append(", groupId=");
586                    sb.append(getGroupId());
587                    sb.append(", name=");
588                    sb.append(getName());
589                    sb.append(", description=");
590                    sb.append(getDescription());
591                    sb.append("}");
592    
593                    return sb.toString();
594            }
595    
596            @Override
597            public String toXmlString() {
598                    StringBundler sb = new StringBundler(31);
599    
600                    sb.append("<model><model-name>");
601                    sb.append("com.liferay.portal.model.Team");
602                    sb.append("</model-name>");
603    
604                    sb.append(
605                            "<column><column-name>teamId</column-name><column-value><![CDATA[");
606                    sb.append(getTeamId());
607                    sb.append("]]></column-value></column>");
608                    sb.append(
609                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
610                    sb.append(getCompanyId());
611                    sb.append("]]></column-value></column>");
612                    sb.append(
613                            "<column><column-name>userId</column-name><column-value><![CDATA[");
614                    sb.append(getUserId());
615                    sb.append("]]></column-value></column>");
616                    sb.append(
617                            "<column><column-name>userName</column-name><column-value><![CDATA[");
618                    sb.append(getUserName());
619                    sb.append("]]></column-value></column>");
620                    sb.append(
621                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
622                    sb.append(getCreateDate());
623                    sb.append("]]></column-value></column>");
624                    sb.append(
625                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
626                    sb.append(getModifiedDate());
627                    sb.append("]]></column-value></column>");
628                    sb.append(
629                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
630                    sb.append(getGroupId());
631                    sb.append("]]></column-value></column>");
632                    sb.append(
633                            "<column><column-name>name</column-name><column-value><![CDATA[");
634                    sb.append(getName());
635                    sb.append("]]></column-value></column>");
636                    sb.append(
637                            "<column><column-name>description</column-name><column-value><![CDATA[");
638                    sb.append(getDescription());
639                    sb.append("]]></column-value></column>");
640    
641                    sb.append("</model>");
642    
643                    return sb.toString();
644            }
645    
646            private static ClassLoader _classLoader = Team.class.getClassLoader();
647            private static Class<?>[] _escapedModelInterfaces = new Class[] { Team.class };
648            private long _teamId;
649            private long _companyId;
650            private long _userId;
651            private String _userUuid;
652            private String _userName;
653            private Date _createDate;
654            private Date _modifiedDate;
655            private long _groupId;
656            private long _originalGroupId;
657            private boolean _setOriginalGroupId;
658            private String _name;
659            private String _originalName;
660            private String _description;
661            private long _columnBitmask;
662            private Team _escapedModel;
663    }