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 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 Team
057     * @see 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 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            public boolean hasSetModifiedDate() {
377                    return _setModifiedDate;
378            }
379    
380            @Override
381            public void setModifiedDate(Date modifiedDate) {
382                    _setModifiedDate = true;
383    
384                    _modifiedDate = modifiedDate;
385            }
386    
387            @JSON
388            @Override
389            public long getGroupId() {
390                    return _groupId;
391            }
392    
393            @Override
394            public void setGroupId(long groupId) {
395                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
396    
397                    if (!_setOriginalGroupId) {
398                            _setOriginalGroupId = true;
399    
400                            _originalGroupId = _groupId;
401                    }
402    
403                    _groupId = groupId;
404            }
405    
406            public long getOriginalGroupId() {
407                    return _originalGroupId;
408            }
409    
410            @JSON
411            @Override
412            public String getName() {
413                    if (_name == null) {
414                            return StringPool.BLANK;
415                    }
416                    else {
417                            return _name;
418                    }
419            }
420    
421            @Override
422            public void setName(String name) {
423                    _columnBitmask = -1L;
424    
425                    if (_originalName == null) {
426                            _originalName = _name;
427                    }
428    
429                    _name = name;
430            }
431    
432            public String getOriginalName() {
433                    return GetterUtil.getString(_originalName);
434            }
435    
436            @JSON
437            @Override
438            public String getDescription() {
439                    if (_description == null) {
440                            return StringPool.BLANK;
441                    }
442                    else {
443                            return _description;
444                    }
445            }
446    
447            @Override
448            public void setDescription(String description) {
449                    _description = description;
450            }
451    
452            public long getColumnBitmask() {
453                    return _columnBitmask;
454            }
455    
456            @Override
457            public ExpandoBridge getExpandoBridge() {
458                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
459                            Team.class.getName(), getPrimaryKey());
460            }
461    
462            @Override
463            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
464                    ExpandoBridge expandoBridge = getExpandoBridge();
465    
466                    expandoBridge.setAttributes(serviceContext);
467            }
468    
469            @Override
470            public Team toEscapedModel() {
471                    if (_escapedModel == null) {
472                            _escapedModel = (Team)ProxyUtil.newProxyInstance(_classLoader,
473                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
474                    }
475    
476                    return _escapedModel;
477            }
478    
479            @Override
480            public Object clone() {
481                    TeamImpl teamImpl = new TeamImpl();
482    
483                    teamImpl.setMvccVersion(getMvccVersion());
484                    teamImpl.setTeamId(getTeamId());
485                    teamImpl.setCompanyId(getCompanyId());
486                    teamImpl.setUserId(getUserId());
487                    teamImpl.setUserName(getUserName());
488                    teamImpl.setCreateDate(getCreateDate());
489                    teamImpl.setModifiedDate(getModifiedDate());
490                    teamImpl.setGroupId(getGroupId());
491                    teamImpl.setName(getName());
492                    teamImpl.setDescription(getDescription());
493    
494                    teamImpl.resetOriginalValues();
495    
496                    return teamImpl;
497            }
498    
499            @Override
500            public int compareTo(Team team) {
501                    int value = 0;
502    
503                    value = getName().compareTo(team.getName());
504    
505                    if (value != 0) {
506                            return value;
507                    }
508    
509                    return 0;
510            }
511    
512            @Override
513            public boolean equals(Object obj) {
514                    if (this == obj) {
515                            return true;
516                    }
517    
518                    if (!(obj instanceof Team)) {
519                            return false;
520                    }
521    
522                    Team team = (Team)obj;
523    
524                    long primaryKey = team.getPrimaryKey();
525    
526                    if (getPrimaryKey() == primaryKey) {
527                            return true;
528                    }
529                    else {
530                            return false;
531                    }
532            }
533    
534            @Override
535            public int hashCode() {
536                    return (int)getPrimaryKey();
537            }
538    
539            @Override
540            public boolean isEntityCacheEnabled() {
541                    return ENTITY_CACHE_ENABLED;
542            }
543    
544            @Override
545            public boolean isFinderCacheEnabled() {
546                    return FINDER_CACHE_ENABLED;
547            }
548    
549            @Override
550            public void resetOriginalValues() {
551                    TeamModelImpl teamModelImpl = this;
552    
553                    teamModelImpl._setModifiedDate = false;
554    
555                    teamModelImpl._originalGroupId = teamModelImpl._groupId;
556    
557                    teamModelImpl._setOriginalGroupId = false;
558    
559                    teamModelImpl._originalName = teamModelImpl._name;
560    
561                    teamModelImpl._columnBitmask = 0;
562            }
563    
564            @Override
565            public CacheModel<Team> toCacheModel() {
566                    TeamCacheModel teamCacheModel = new TeamCacheModel();
567    
568                    teamCacheModel.mvccVersion = getMvccVersion();
569    
570                    teamCacheModel.teamId = getTeamId();
571    
572                    teamCacheModel.companyId = getCompanyId();
573    
574                    teamCacheModel.userId = getUserId();
575    
576                    teamCacheModel.userName = getUserName();
577    
578                    String userName = teamCacheModel.userName;
579    
580                    if ((userName != null) && (userName.length() == 0)) {
581                            teamCacheModel.userName = null;
582                    }
583    
584                    Date createDate = getCreateDate();
585    
586                    if (createDate != null) {
587                            teamCacheModel.createDate = createDate.getTime();
588                    }
589                    else {
590                            teamCacheModel.createDate = Long.MIN_VALUE;
591                    }
592    
593                    Date modifiedDate = getModifiedDate();
594    
595                    if (modifiedDate != null) {
596                            teamCacheModel.modifiedDate = modifiedDate.getTime();
597                    }
598                    else {
599                            teamCacheModel.modifiedDate = Long.MIN_VALUE;
600                    }
601    
602                    teamCacheModel.groupId = getGroupId();
603    
604                    teamCacheModel.name = getName();
605    
606                    String name = teamCacheModel.name;
607    
608                    if ((name != null) && (name.length() == 0)) {
609                            teamCacheModel.name = null;
610                    }
611    
612                    teamCacheModel.description = getDescription();
613    
614                    String description = teamCacheModel.description;
615    
616                    if ((description != null) && (description.length() == 0)) {
617                            teamCacheModel.description = null;
618                    }
619    
620                    return teamCacheModel;
621            }
622    
623            @Override
624            public String toString() {
625                    StringBundler sb = new StringBundler(21);
626    
627                    sb.append("{mvccVersion=");
628                    sb.append(getMvccVersion());
629                    sb.append(", teamId=");
630                    sb.append(getTeamId());
631                    sb.append(", companyId=");
632                    sb.append(getCompanyId());
633                    sb.append(", userId=");
634                    sb.append(getUserId());
635                    sb.append(", userName=");
636                    sb.append(getUserName());
637                    sb.append(", createDate=");
638                    sb.append(getCreateDate());
639                    sb.append(", modifiedDate=");
640                    sb.append(getModifiedDate());
641                    sb.append(", groupId=");
642                    sb.append(getGroupId());
643                    sb.append(", name=");
644                    sb.append(getName());
645                    sb.append(", description=");
646                    sb.append(getDescription());
647                    sb.append("}");
648    
649                    return sb.toString();
650            }
651    
652            @Override
653            public String toXmlString() {
654                    StringBundler sb = new StringBundler(34);
655    
656                    sb.append("<model><model-name>");
657                    sb.append("com.liferay.portal.model.Team");
658                    sb.append("</model-name>");
659    
660                    sb.append(
661                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
662                    sb.append(getMvccVersion());
663                    sb.append("]]></column-value></column>");
664                    sb.append(
665                            "<column><column-name>teamId</column-name><column-value><![CDATA[");
666                    sb.append(getTeamId());
667                    sb.append("]]></column-value></column>");
668                    sb.append(
669                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
670                    sb.append(getCompanyId());
671                    sb.append("]]></column-value></column>");
672                    sb.append(
673                            "<column><column-name>userId</column-name><column-value><![CDATA[");
674                    sb.append(getUserId());
675                    sb.append("]]></column-value></column>");
676                    sb.append(
677                            "<column><column-name>userName</column-name><column-value><![CDATA[");
678                    sb.append(getUserName());
679                    sb.append("]]></column-value></column>");
680                    sb.append(
681                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
682                    sb.append(getCreateDate());
683                    sb.append("]]></column-value></column>");
684                    sb.append(
685                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
686                    sb.append(getModifiedDate());
687                    sb.append("]]></column-value></column>");
688                    sb.append(
689                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
690                    sb.append(getGroupId());
691                    sb.append("]]></column-value></column>");
692                    sb.append(
693                            "<column><column-name>name</column-name><column-value><![CDATA[");
694                    sb.append(getName());
695                    sb.append("]]></column-value></column>");
696                    sb.append(
697                            "<column><column-name>description</column-name><column-value><![CDATA[");
698                    sb.append(getDescription());
699                    sb.append("]]></column-value></column>");
700    
701                    sb.append("</model>");
702    
703                    return sb.toString();
704            }
705    
706            private static final ClassLoader _classLoader = Team.class.getClassLoader();
707            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
708                            Team.class
709                    };
710            private long _mvccVersion;
711            private long _teamId;
712            private long _companyId;
713            private long _userId;
714            private String _userName;
715            private Date _createDate;
716            private Date _modifiedDate;
717            private boolean _setModifiedDate;
718            private long _groupId;
719            private long _originalGroupId;
720            private boolean _setOriginalGroupId;
721            private String _name;
722            private String _originalName;
723            private String _description;
724            private long _columnBitmask;
725            private Team _escapedModel;
726    }