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 (userId LONG not null,teamId LONG not null,primary key (userId, teamId))";
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 (userGroupId LONG not null,teamId LONG not null,primary key (userGroupId, teamId))";
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            public long getPrimaryKey() {
164                    return _teamId;
165            }
166    
167            public void setPrimaryKey(long primaryKey) {
168                    setTeamId(primaryKey);
169            }
170    
171            public Serializable getPrimaryKeyObj() {
172                    return _teamId;
173            }
174    
175            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
176                    setPrimaryKey(((Long)primaryKeyObj).longValue());
177            }
178    
179            public Class<?> getModelClass() {
180                    return Team.class;
181            }
182    
183            public String getModelClassName() {
184                    return Team.class.getName();
185            }
186    
187            @Override
188            public Map<String, Object> getModelAttributes() {
189                    Map<String, Object> attributes = new HashMap<String, Object>();
190    
191                    attributes.put("teamId", getTeamId());
192                    attributes.put("companyId", getCompanyId());
193                    attributes.put("userId", getUserId());
194                    attributes.put("userName", getUserName());
195                    attributes.put("createDate", getCreateDate());
196                    attributes.put("modifiedDate", getModifiedDate());
197                    attributes.put("groupId", getGroupId());
198                    attributes.put("name", getName());
199                    attributes.put("description", getDescription());
200    
201                    return attributes;
202            }
203    
204            @Override
205            public void setModelAttributes(Map<String, Object> attributes) {
206                    Long teamId = (Long)attributes.get("teamId");
207    
208                    if (teamId != null) {
209                            setTeamId(teamId);
210                    }
211    
212                    Long companyId = (Long)attributes.get("companyId");
213    
214                    if (companyId != null) {
215                            setCompanyId(companyId);
216                    }
217    
218                    Long userId = (Long)attributes.get("userId");
219    
220                    if (userId != null) {
221                            setUserId(userId);
222                    }
223    
224                    String userName = (String)attributes.get("userName");
225    
226                    if (userName != null) {
227                            setUserName(userName);
228                    }
229    
230                    Date createDate = (Date)attributes.get("createDate");
231    
232                    if (createDate != null) {
233                            setCreateDate(createDate);
234                    }
235    
236                    Date modifiedDate = (Date)attributes.get("modifiedDate");
237    
238                    if (modifiedDate != null) {
239                            setModifiedDate(modifiedDate);
240                    }
241    
242                    Long groupId = (Long)attributes.get("groupId");
243    
244                    if (groupId != null) {
245                            setGroupId(groupId);
246                    }
247    
248                    String name = (String)attributes.get("name");
249    
250                    if (name != null) {
251                            setName(name);
252                    }
253    
254                    String description = (String)attributes.get("description");
255    
256                    if (description != null) {
257                            setDescription(description);
258                    }
259            }
260    
261            @JSON
262            public long getTeamId() {
263                    return _teamId;
264            }
265    
266            public void setTeamId(long teamId) {
267                    _teamId = teamId;
268            }
269    
270            @JSON
271            public long getCompanyId() {
272                    return _companyId;
273            }
274    
275            public void setCompanyId(long companyId) {
276                    _companyId = companyId;
277            }
278    
279            @JSON
280            public long getUserId() {
281                    return _userId;
282            }
283    
284            public void setUserId(long userId) {
285                    _userId = userId;
286            }
287    
288            public String getUserUuid() throws SystemException {
289                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
290            }
291    
292            public void setUserUuid(String userUuid) {
293                    _userUuid = userUuid;
294            }
295    
296            @JSON
297            public String getUserName() {
298                    if (_userName == null) {
299                            return StringPool.BLANK;
300                    }
301                    else {
302                            return _userName;
303                    }
304            }
305    
306            public void setUserName(String userName) {
307                    _userName = userName;
308            }
309    
310            @JSON
311            public Date getCreateDate() {
312                    return _createDate;
313            }
314    
315            public void setCreateDate(Date createDate) {
316                    _createDate = createDate;
317            }
318    
319            @JSON
320            public Date getModifiedDate() {
321                    return _modifiedDate;
322            }
323    
324            public void setModifiedDate(Date modifiedDate) {
325                    _modifiedDate = modifiedDate;
326            }
327    
328            @JSON
329            public long getGroupId() {
330                    return _groupId;
331            }
332    
333            public void setGroupId(long groupId) {
334                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
335    
336                    if (!_setOriginalGroupId) {
337                            _setOriginalGroupId = true;
338    
339                            _originalGroupId = _groupId;
340                    }
341    
342                    _groupId = groupId;
343            }
344    
345            public long getOriginalGroupId() {
346                    return _originalGroupId;
347            }
348    
349            @JSON
350            public String getName() {
351                    if (_name == null) {
352                            return StringPool.BLANK;
353                    }
354                    else {
355                            return _name;
356                    }
357            }
358    
359            public void setName(String name) {
360                    _columnBitmask = -1L;
361    
362                    if (_originalName == null) {
363                            _originalName = _name;
364                    }
365    
366                    _name = name;
367            }
368    
369            public String getOriginalName() {
370                    return GetterUtil.getString(_originalName);
371            }
372    
373            @JSON
374            public String getDescription() {
375                    if (_description == null) {
376                            return StringPool.BLANK;
377                    }
378                    else {
379                            return _description;
380                    }
381            }
382    
383            public void setDescription(String description) {
384                    _description = description;
385            }
386    
387            public long getColumnBitmask() {
388                    return _columnBitmask;
389            }
390    
391            @Override
392            public ExpandoBridge getExpandoBridge() {
393                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
394                            Team.class.getName(), getPrimaryKey());
395            }
396    
397            @Override
398            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
399                    ExpandoBridge expandoBridge = getExpandoBridge();
400    
401                    expandoBridge.setAttributes(serviceContext);
402            }
403    
404            @Override
405            public Team toEscapedModel() {
406                    if (_escapedModel == null) {
407                            _escapedModel = (Team)ProxyUtil.newProxyInstance(_classLoader,
408                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
409                    }
410    
411                    return _escapedModel;
412            }
413    
414            @Override
415            public Object clone() {
416                    TeamImpl teamImpl = new TeamImpl();
417    
418                    teamImpl.setTeamId(getTeamId());
419                    teamImpl.setCompanyId(getCompanyId());
420                    teamImpl.setUserId(getUserId());
421                    teamImpl.setUserName(getUserName());
422                    teamImpl.setCreateDate(getCreateDate());
423                    teamImpl.setModifiedDate(getModifiedDate());
424                    teamImpl.setGroupId(getGroupId());
425                    teamImpl.setName(getName());
426                    teamImpl.setDescription(getDescription());
427    
428                    teamImpl.resetOriginalValues();
429    
430                    return teamImpl;
431            }
432    
433            public int compareTo(Team team) {
434                    int value = 0;
435    
436                    value = getName().compareTo(team.getName());
437    
438                    if (value != 0) {
439                            return value;
440                    }
441    
442                    return 0;
443            }
444    
445            @Override
446            public boolean equals(Object obj) {
447                    if (obj == null) {
448                            return false;
449                    }
450    
451                    Team team = null;
452    
453                    try {
454                            team = (Team)obj;
455                    }
456                    catch (ClassCastException cce) {
457                            return false;
458                    }
459    
460                    long primaryKey = team.getPrimaryKey();
461    
462                    if (getPrimaryKey() == primaryKey) {
463                            return true;
464                    }
465                    else {
466                            return false;
467                    }
468            }
469    
470            @Override
471            public int hashCode() {
472                    return (int)getPrimaryKey();
473            }
474    
475            @Override
476            public void resetOriginalValues() {
477                    TeamModelImpl teamModelImpl = this;
478    
479                    teamModelImpl._originalGroupId = teamModelImpl._groupId;
480    
481                    teamModelImpl._setOriginalGroupId = false;
482    
483                    teamModelImpl._originalName = teamModelImpl._name;
484    
485                    teamModelImpl._columnBitmask = 0;
486            }
487    
488            @Override
489            public CacheModel<Team> toCacheModel() {
490                    TeamCacheModel teamCacheModel = new TeamCacheModel();
491    
492                    teamCacheModel.teamId = getTeamId();
493    
494                    teamCacheModel.companyId = getCompanyId();
495    
496                    teamCacheModel.userId = getUserId();
497    
498                    teamCacheModel.userName = getUserName();
499    
500                    String userName = teamCacheModel.userName;
501    
502                    if ((userName != null) && (userName.length() == 0)) {
503                            teamCacheModel.userName = null;
504                    }
505    
506                    Date createDate = getCreateDate();
507    
508                    if (createDate != null) {
509                            teamCacheModel.createDate = createDate.getTime();
510                    }
511                    else {
512                            teamCacheModel.createDate = Long.MIN_VALUE;
513                    }
514    
515                    Date modifiedDate = getModifiedDate();
516    
517                    if (modifiedDate != null) {
518                            teamCacheModel.modifiedDate = modifiedDate.getTime();
519                    }
520                    else {
521                            teamCacheModel.modifiedDate = Long.MIN_VALUE;
522                    }
523    
524                    teamCacheModel.groupId = getGroupId();
525    
526                    teamCacheModel.name = getName();
527    
528                    String name = teamCacheModel.name;
529    
530                    if ((name != null) && (name.length() == 0)) {
531                            teamCacheModel.name = null;
532                    }
533    
534                    teamCacheModel.description = getDescription();
535    
536                    String description = teamCacheModel.description;
537    
538                    if ((description != null) && (description.length() == 0)) {
539                            teamCacheModel.description = null;
540                    }
541    
542                    return teamCacheModel;
543            }
544    
545            @Override
546            public String toString() {
547                    StringBundler sb = new StringBundler(19);
548    
549                    sb.append("{teamId=");
550                    sb.append(getTeamId());
551                    sb.append(", companyId=");
552                    sb.append(getCompanyId());
553                    sb.append(", userId=");
554                    sb.append(getUserId());
555                    sb.append(", userName=");
556                    sb.append(getUserName());
557                    sb.append(", createDate=");
558                    sb.append(getCreateDate());
559                    sb.append(", modifiedDate=");
560                    sb.append(getModifiedDate());
561                    sb.append(", groupId=");
562                    sb.append(getGroupId());
563                    sb.append(", name=");
564                    sb.append(getName());
565                    sb.append(", description=");
566                    sb.append(getDescription());
567                    sb.append("}");
568    
569                    return sb.toString();
570            }
571    
572            public String toXmlString() {
573                    StringBundler sb = new StringBundler(31);
574    
575                    sb.append("<model><model-name>");
576                    sb.append("com.liferay.portal.model.Team");
577                    sb.append("</model-name>");
578    
579                    sb.append(
580                            "<column><column-name>teamId</column-name><column-value><![CDATA[");
581                    sb.append(getTeamId());
582                    sb.append("]]></column-value></column>");
583                    sb.append(
584                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
585                    sb.append(getCompanyId());
586                    sb.append("]]></column-value></column>");
587                    sb.append(
588                            "<column><column-name>userId</column-name><column-value><![CDATA[");
589                    sb.append(getUserId());
590                    sb.append("]]></column-value></column>");
591                    sb.append(
592                            "<column><column-name>userName</column-name><column-value><![CDATA[");
593                    sb.append(getUserName());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
597                    sb.append(getCreateDate());
598                    sb.append("]]></column-value></column>");
599                    sb.append(
600                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
601                    sb.append(getModifiedDate());
602                    sb.append("]]></column-value></column>");
603                    sb.append(
604                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
605                    sb.append(getGroupId());
606                    sb.append("]]></column-value></column>");
607                    sb.append(
608                            "<column><column-name>name</column-name><column-value><![CDATA[");
609                    sb.append(getName());
610                    sb.append("]]></column-value></column>");
611                    sb.append(
612                            "<column><column-name>description</column-name><column-value><![CDATA[");
613                    sb.append(getDescription());
614                    sb.append("]]></column-value></column>");
615    
616                    sb.append("</model>");
617    
618                    return sb.toString();
619            }
620    
621            private static ClassLoader _classLoader = Team.class.getClassLoader();
622            private static Class<?>[] _escapedModelInterfaces = new Class[] { Team.class };
623            private long _teamId;
624            private long _companyId;
625            private long _userId;
626            private String _userUuid;
627            private String _userName;
628            private Date _createDate;
629            private Date _modifiedDate;
630            private long _groupId;
631            private long _originalGroupId;
632            private boolean _setOriginalGroupId;
633            private String _name;
634            private String _originalName;
635            private String _description;
636            private long _columnBitmask;
637            private Team _escapedModel;
638    }