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