001
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
057 @JSON(strict = true)
058 public class TeamModelImpl extends BaseModelImpl<Team> implements TeamModel {
059
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
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
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 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 new Long(_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 public Team toUnescapedModel() {
415 return (Team)this;
416 }
417
418 @Override
419 public Object clone() {
420 TeamImpl teamImpl = new TeamImpl();
421
422 teamImpl.setTeamId(getTeamId());
423 teamImpl.setCompanyId(getCompanyId());
424 teamImpl.setUserId(getUserId());
425 teamImpl.setUserName(getUserName());
426 teamImpl.setCreateDate(getCreateDate());
427 teamImpl.setModifiedDate(getModifiedDate());
428 teamImpl.setGroupId(getGroupId());
429 teamImpl.setName(getName());
430 teamImpl.setDescription(getDescription());
431
432 teamImpl.resetOriginalValues();
433
434 return teamImpl;
435 }
436
437 public int compareTo(Team team) {
438 int value = 0;
439
440 value = getName().compareTo(team.getName());
441
442 if (value != 0) {
443 return value;
444 }
445
446 return 0;
447 }
448
449 @Override
450 public boolean equals(Object obj) {
451 if (this == obj) {
452 return true;
453 }
454
455 if (!(obj instanceof Team)) {
456 return false;
457 }
458
459 Team team = (Team)obj;
460
461 long primaryKey = team.getPrimaryKey();
462
463 if (getPrimaryKey() == primaryKey) {
464 return true;
465 }
466 else {
467 return false;
468 }
469 }
470
471 @Override
472 public int hashCode() {
473 return (int)getPrimaryKey();
474 }
475
476 @Override
477 public void resetOriginalValues() {
478 TeamModelImpl teamModelImpl = this;
479
480 teamModelImpl._originalGroupId = teamModelImpl._groupId;
481
482 teamModelImpl._setOriginalGroupId = false;
483
484 teamModelImpl._originalName = teamModelImpl._name;
485
486 teamModelImpl._columnBitmask = 0;
487 }
488
489 @Override
490 public CacheModel<Team> toCacheModel() {
491 TeamCacheModel teamCacheModel = new TeamCacheModel();
492
493 teamCacheModel.teamId = getTeamId();
494
495 teamCacheModel.companyId = getCompanyId();
496
497 teamCacheModel.userId = getUserId();
498
499 teamCacheModel.userName = getUserName();
500
501 String userName = teamCacheModel.userName;
502
503 if ((userName != null) && (userName.length() == 0)) {
504 teamCacheModel.userName = null;
505 }
506
507 Date createDate = getCreateDate();
508
509 if (createDate != null) {
510 teamCacheModel.createDate = createDate.getTime();
511 }
512 else {
513 teamCacheModel.createDate = Long.MIN_VALUE;
514 }
515
516 Date modifiedDate = getModifiedDate();
517
518 if (modifiedDate != null) {
519 teamCacheModel.modifiedDate = modifiedDate.getTime();
520 }
521 else {
522 teamCacheModel.modifiedDate = Long.MIN_VALUE;
523 }
524
525 teamCacheModel.groupId = getGroupId();
526
527 teamCacheModel.name = getName();
528
529 String name = teamCacheModel.name;
530
531 if ((name != null) && (name.length() == 0)) {
532 teamCacheModel.name = null;
533 }
534
535 teamCacheModel.description = getDescription();
536
537 String description = teamCacheModel.description;
538
539 if ((description != null) && (description.length() == 0)) {
540 teamCacheModel.description = null;
541 }
542
543 return teamCacheModel;
544 }
545
546 @Override
547 public String toString() {
548 StringBundler sb = new StringBundler(19);
549
550 sb.append("{teamId=");
551 sb.append(getTeamId());
552 sb.append(", companyId=");
553 sb.append(getCompanyId());
554 sb.append(", userId=");
555 sb.append(getUserId());
556 sb.append(", userName=");
557 sb.append(getUserName());
558 sb.append(", createDate=");
559 sb.append(getCreateDate());
560 sb.append(", modifiedDate=");
561 sb.append(getModifiedDate());
562 sb.append(", groupId=");
563 sb.append(getGroupId());
564 sb.append(", name=");
565 sb.append(getName());
566 sb.append(", description=");
567 sb.append(getDescription());
568 sb.append("}");
569
570 return sb.toString();
571 }
572
573 public String toXmlString() {
574 StringBundler sb = new StringBundler(31);
575
576 sb.append("<model><model-name>");
577 sb.append("com.liferay.portal.model.Team");
578 sb.append("</model-name>");
579
580 sb.append(
581 "<column><column-name>teamId</column-name><column-value><![CDATA[");
582 sb.append(getTeamId());
583 sb.append("]]></column-value></column>");
584 sb.append(
585 "<column><column-name>companyId</column-name><column-value><![CDATA[");
586 sb.append(getCompanyId());
587 sb.append("]]></column-value></column>");
588 sb.append(
589 "<column><column-name>userId</column-name><column-value><![CDATA[");
590 sb.append(getUserId());
591 sb.append("]]></column-value></column>");
592 sb.append(
593 "<column><column-name>userName</column-name><column-value><![CDATA[");
594 sb.append(getUserName());
595 sb.append("]]></column-value></column>");
596 sb.append(
597 "<column><column-name>createDate</column-name><column-value><![CDATA[");
598 sb.append(getCreateDate());
599 sb.append("]]></column-value></column>");
600 sb.append(
601 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
602 sb.append(getModifiedDate());
603 sb.append("]]></column-value></column>");
604 sb.append(
605 "<column><column-name>groupId</column-name><column-value><![CDATA[");
606 sb.append(getGroupId());
607 sb.append("]]></column-value></column>");
608 sb.append(
609 "<column><column-name>name</column-name><column-value><![CDATA[");
610 sb.append(getName());
611 sb.append("]]></column-value></column>");
612 sb.append(
613 "<column><column-name>description</column-name><column-value><![CDATA[");
614 sb.append(getDescription());
615 sb.append("]]></column-value></column>");
616
617 sb.append("</model>");
618
619 return sb.toString();
620 }
621
622 private static ClassLoader _classLoader = Team.class.getClassLoader();
623 private static Class<?>[] _escapedModelInterfaces = new Class[] { Team.class };
624 private long _teamId;
625 private long _companyId;
626 private long _userId;
627 private String _userUuid;
628 private String _userName;
629 private Date _createDate;
630 private Date _modifiedDate;
631 private long _groupId;
632 private long _originalGroupId;
633 private boolean _setOriginalGroupId;
634 private String _name;
635 private String _originalName;
636 private String _description;
637 private long _columnBitmask;
638 private Team _escapedModel;
639 }