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.kernel.util.Validator;
025 import com.liferay.portal.model.CacheModel;
026 import com.liferay.portal.model.Repository;
027 import com.liferay.portal.model.RepositoryModel;
028 import com.liferay.portal.model.RepositorySoap;
029 import com.liferay.portal.service.ServiceContext;
030 import com.liferay.portal.util.PortalUtil;
031
032 import com.liferay.portlet.expando.model.ExpandoBridge;
033 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
034
035 import java.io.Serializable;
036
037 import java.sql.Types;
038
039 import java.util.ArrayList;
040 import java.util.Date;
041 import java.util.HashMap;
042 import java.util.List;
043 import java.util.Map;
044
045
058 @JSON(strict = true)
059 public class RepositoryModelImpl extends BaseModelImpl<Repository>
060 implements RepositoryModel {
061
066 public static final String TABLE_NAME = "Repository";
067 public static final Object[][] TABLE_COLUMNS = {
068 { "uuid_", Types.VARCHAR },
069 { "repositoryId", Types.BIGINT },
070 { "groupId", Types.BIGINT },
071 { "companyId", Types.BIGINT },
072 { "userId", Types.BIGINT },
073 { "userName", Types.VARCHAR },
074 { "createDate", Types.TIMESTAMP },
075 { "modifiedDate", Types.TIMESTAMP },
076 { "classNameId", Types.BIGINT },
077 { "name", Types.VARCHAR },
078 { "description", Types.VARCHAR },
079 { "portletId", Types.VARCHAR },
080 { "typeSettings", Types.CLOB },
081 { "dlFolderId", Types.BIGINT }
082 };
083 public static final String TABLE_SQL_CREATE = "create table Repository (uuid_ VARCHAR(75) null,repositoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,name VARCHAR(75) null,description STRING null,portletId VARCHAR(75) null,typeSettings TEXT null,dlFolderId LONG)";
084 public static final String TABLE_SQL_DROP = "drop table Repository";
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.Repository"),
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.Repository"),
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.Repository"),
096 true);
097 public static long GROUPID_COLUMN_BITMASK = 1L;
098 public static long UUID_COLUMN_BITMASK = 2L;
099
100
106 public static Repository toModel(RepositorySoap soapModel) {
107 if (soapModel == null) {
108 return null;
109 }
110
111 Repository model = new RepositoryImpl();
112
113 model.setUuid(soapModel.getUuid());
114 model.setRepositoryId(soapModel.getRepositoryId());
115 model.setGroupId(soapModel.getGroupId());
116 model.setCompanyId(soapModel.getCompanyId());
117 model.setUserId(soapModel.getUserId());
118 model.setUserName(soapModel.getUserName());
119 model.setCreateDate(soapModel.getCreateDate());
120 model.setModifiedDate(soapModel.getModifiedDate());
121 model.setClassNameId(soapModel.getClassNameId());
122 model.setName(soapModel.getName());
123 model.setDescription(soapModel.getDescription());
124 model.setPortletId(soapModel.getPortletId());
125 model.setTypeSettings(soapModel.getTypeSettings());
126 model.setDlFolderId(soapModel.getDlFolderId());
127
128 return model;
129 }
130
131
137 public static List<Repository> toModels(RepositorySoap[] soapModels) {
138 if (soapModels == null) {
139 return null;
140 }
141
142 List<Repository> models = new ArrayList<Repository>(soapModels.length);
143
144 for (RepositorySoap soapModel : soapModels) {
145 models.add(toModel(soapModel));
146 }
147
148 return models;
149 }
150
151 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
152 "lock.expiration.time.com.liferay.portal.model.Repository"));
153
154 public RepositoryModelImpl() {
155 }
156
157 public long getPrimaryKey() {
158 return _repositoryId;
159 }
160
161 public void setPrimaryKey(long primaryKey) {
162 setRepositoryId(primaryKey);
163 }
164
165 public Serializable getPrimaryKeyObj() {
166 return new Long(_repositoryId);
167 }
168
169 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
170 setPrimaryKey(((Long)primaryKeyObj).longValue());
171 }
172
173 public Class<?> getModelClass() {
174 return Repository.class;
175 }
176
177 public String getModelClassName() {
178 return Repository.class.getName();
179 }
180
181 @Override
182 public Map<String, Object> getModelAttributes() {
183 Map<String, Object> attributes = new HashMap<String, Object>();
184
185 attributes.put("uuid", getUuid());
186 attributes.put("repositoryId", getRepositoryId());
187 attributes.put("groupId", getGroupId());
188 attributes.put("companyId", getCompanyId());
189 attributes.put("userId", getUserId());
190 attributes.put("userName", getUserName());
191 attributes.put("createDate", getCreateDate());
192 attributes.put("modifiedDate", getModifiedDate());
193 attributes.put("classNameId", getClassNameId());
194 attributes.put("name", getName());
195 attributes.put("description", getDescription());
196 attributes.put("portletId", getPortletId());
197 attributes.put("typeSettings", getTypeSettings());
198 attributes.put("dlFolderId", getDlFolderId());
199
200 return attributes;
201 }
202
203 @Override
204 public void setModelAttributes(Map<String, Object> attributes) {
205 String uuid = (String)attributes.get("uuid");
206
207 if (uuid != null) {
208 setUuid(uuid);
209 }
210
211 Long repositoryId = (Long)attributes.get("repositoryId");
212
213 if (repositoryId != null) {
214 setRepositoryId(repositoryId);
215 }
216
217 Long groupId = (Long)attributes.get("groupId");
218
219 if (groupId != null) {
220 setGroupId(groupId);
221 }
222
223 Long companyId = (Long)attributes.get("companyId");
224
225 if (companyId != null) {
226 setCompanyId(companyId);
227 }
228
229 Long userId = (Long)attributes.get("userId");
230
231 if (userId != null) {
232 setUserId(userId);
233 }
234
235 String userName = (String)attributes.get("userName");
236
237 if (userName != null) {
238 setUserName(userName);
239 }
240
241 Date createDate = (Date)attributes.get("createDate");
242
243 if (createDate != null) {
244 setCreateDate(createDate);
245 }
246
247 Date modifiedDate = (Date)attributes.get("modifiedDate");
248
249 if (modifiedDate != null) {
250 setModifiedDate(modifiedDate);
251 }
252
253 Long classNameId = (Long)attributes.get("classNameId");
254
255 if (classNameId != null) {
256 setClassNameId(classNameId);
257 }
258
259 String name = (String)attributes.get("name");
260
261 if (name != null) {
262 setName(name);
263 }
264
265 String description = (String)attributes.get("description");
266
267 if (description != null) {
268 setDescription(description);
269 }
270
271 String portletId = (String)attributes.get("portletId");
272
273 if (portletId != null) {
274 setPortletId(portletId);
275 }
276
277 String typeSettings = (String)attributes.get("typeSettings");
278
279 if (typeSettings != null) {
280 setTypeSettings(typeSettings);
281 }
282
283 Long dlFolderId = (Long)attributes.get("dlFolderId");
284
285 if (dlFolderId != null) {
286 setDlFolderId(dlFolderId);
287 }
288 }
289
290 @JSON
291 public String getUuid() {
292 if (_uuid == null) {
293 return StringPool.BLANK;
294 }
295 else {
296 return _uuid;
297 }
298 }
299
300 public void setUuid(String uuid) {
301 if (_originalUuid == null) {
302 _originalUuid = _uuid;
303 }
304
305 _uuid = uuid;
306 }
307
308 public String getOriginalUuid() {
309 return GetterUtil.getString(_originalUuid);
310 }
311
312 @JSON
313 public long getRepositoryId() {
314 return _repositoryId;
315 }
316
317 public void setRepositoryId(long repositoryId) {
318 _repositoryId = repositoryId;
319 }
320
321 @JSON
322 public long getGroupId() {
323 return _groupId;
324 }
325
326 public void setGroupId(long groupId) {
327 _columnBitmask |= GROUPID_COLUMN_BITMASK;
328
329 if (!_setOriginalGroupId) {
330 _setOriginalGroupId = true;
331
332 _originalGroupId = _groupId;
333 }
334
335 _groupId = groupId;
336 }
337
338 public long getOriginalGroupId() {
339 return _originalGroupId;
340 }
341
342 @JSON
343 public long getCompanyId() {
344 return _companyId;
345 }
346
347 public void setCompanyId(long companyId) {
348 _companyId = companyId;
349 }
350
351 @JSON
352 public long getUserId() {
353 return _userId;
354 }
355
356 public void setUserId(long userId) {
357 _userId = userId;
358 }
359
360 public String getUserUuid() throws SystemException {
361 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
362 }
363
364 public void setUserUuid(String userUuid) {
365 _userUuid = userUuid;
366 }
367
368 @JSON
369 public String getUserName() {
370 if (_userName == null) {
371 return StringPool.BLANK;
372 }
373 else {
374 return _userName;
375 }
376 }
377
378 public void setUserName(String userName) {
379 _userName = userName;
380 }
381
382 @JSON
383 public Date getCreateDate() {
384 return _createDate;
385 }
386
387 public void setCreateDate(Date createDate) {
388 _createDate = createDate;
389 }
390
391 @JSON
392 public Date getModifiedDate() {
393 return _modifiedDate;
394 }
395
396 public void setModifiedDate(Date modifiedDate) {
397 _modifiedDate = modifiedDate;
398 }
399
400 public String getClassName() {
401 if (getClassNameId() <= 0) {
402 return StringPool.BLANK;
403 }
404
405 return PortalUtil.getClassName(getClassNameId());
406 }
407
408 public void setClassName(String className) {
409 long classNameId = 0;
410
411 if (Validator.isNotNull(className)) {
412 classNameId = PortalUtil.getClassNameId(className);
413 }
414
415 setClassNameId(classNameId);
416 }
417
418 @JSON
419 public long getClassNameId() {
420 return _classNameId;
421 }
422
423 public void setClassNameId(long classNameId) {
424 _classNameId = classNameId;
425 }
426
427 @JSON
428 public String getName() {
429 if (_name == null) {
430 return StringPool.BLANK;
431 }
432 else {
433 return _name;
434 }
435 }
436
437 public void setName(String name) {
438 _name = name;
439 }
440
441 @JSON
442 public String getDescription() {
443 if (_description == null) {
444 return StringPool.BLANK;
445 }
446 else {
447 return _description;
448 }
449 }
450
451 public void setDescription(String description) {
452 _description = description;
453 }
454
455 @JSON
456 public String getPortletId() {
457 if (_portletId == null) {
458 return StringPool.BLANK;
459 }
460 else {
461 return _portletId;
462 }
463 }
464
465 public void setPortletId(String portletId) {
466 _portletId = portletId;
467 }
468
469 @JSON
470 public String getTypeSettings() {
471 if (_typeSettings == null) {
472 return StringPool.BLANK;
473 }
474 else {
475 return _typeSettings;
476 }
477 }
478
479 public void setTypeSettings(String typeSettings) {
480 _typeSettings = typeSettings;
481 }
482
483 @JSON
484 public long getDlFolderId() {
485 return _dlFolderId;
486 }
487
488 public void setDlFolderId(long dlFolderId) {
489 _dlFolderId = dlFolderId;
490 }
491
492 public long getColumnBitmask() {
493 return _columnBitmask;
494 }
495
496 @Override
497 public ExpandoBridge getExpandoBridge() {
498 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
499 Repository.class.getName(), getPrimaryKey());
500 }
501
502 @Override
503 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
504 ExpandoBridge expandoBridge = getExpandoBridge();
505
506 expandoBridge.setAttributes(serviceContext);
507 }
508
509 @Override
510 public Repository toEscapedModel() {
511 if (_escapedModel == null) {
512 _escapedModel = (Repository)ProxyUtil.newProxyInstance(_classLoader,
513 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
514 }
515
516 return _escapedModel;
517 }
518
519 public Repository toUnescapedModel() {
520 return (Repository)this;
521 }
522
523 @Override
524 public Object clone() {
525 RepositoryImpl repositoryImpl = new RepositoryImpl();
526
527 repositoryImpl.setUuid(getUuid());
528 repositoryImpl.setRepositoryId(getRepositoryId());
529 repositoryImpl.setGroupId(getGroupId());
530 repositoryImpl.setCompanyId(getCompanyId());
531 repositoryImpl.setUserId(getUserId());
532 repositoryImpl.setUserName(getUserName());
533 repositoryImpl.setCreateDate(getCreateDate());
534 repositoryImpl.setModifiedDate(getModifiedDate());
535 repositoryImpl.setClassNameId(getClassNameId());
536 repositoryImpl.setName(getName());
537 repositoryImpl.setDescription(getDescription());
538 repositoryImpl.setPortletId(getPortletId());
539 repositoryImpl.setTypeSettings(getTypeSettings());
540 repositoryImpl.setDlFolderId(getDlFolderId());
541
542 repositoryImpl.resetOriginalValues();
543
544 return repositoryImpl;
545 }
546
547 public int compareTo(Repository repository) {
548 long primaryKey = repository.getPrimaryKey();
549
550 if (getPrimaryKey() < primaryKey) {
551 return -1;
552 }
553 else if (getPrimaryKey() > primaryKey) {
554 return 1;
555 }
556 else {
557 return 0;
558 }
559 }
560
561 @Override
562 public boolean equals(Object obj) {
563 if (this == obj) {
564 return true;
565 }
566
567 if (!(obj instanceof Repository)) {
568 return false;
569 }
570
571 Repository repository = (Repository)obj;
572
573 long primaryKey = repository.getPrimaryKey();
574
575 if (getPrimaryKey() == primaryKey) {
576 return true;
577 }
578 else {
579 return false;
580 }
581 }
582
583 @Override
584 public int hashCode() {
585 return (int)getPrimaryKey();
586 }
587
588 @Override
589 public void resetOriginalValues() {
590 RepositoryModelImpl repositoryModelImpl = this;
591
592 repositoryModelImpl._originalUuid = repositoryModelImpl._uuid;
593
594 repositoryModelImpl._originalGroupId = repositoryModelImpl._groupId;
595
596 repositoryModelImpl._setOriginalGroupId = false;
597
598 repositoryModelImpl._columnBitmask = 0;
599 }
600
601 @Override
602 public CacheModel<Repository> toCacheModel() {
603 RepositoryCacheModel repositoryCacheModel = new RepositoryCacheModel();
604
605 repositoryCacheModel.uuid = getUuid();
606
607 String uuid = repositoryCacheModel.uuid;
608
609 if ((uuid != null) && (uuid.length() == 0)) {
610 repositoryCacheModel.uuid = null;
611 }
612
613 repositoryCacheModel.repositoryId = getRepositoryId();
614
615 repositoryCacheModel.groupId = getGroupId();
616
617 repositoryCacheModel.companyId = getCompanyId();
618
619 repositoryCacheModel.userId = getUserId();
620
621 repositoryCacheModel.userName = getUserName();
622
623 String userName = repositoryCacheModel.userName;
624
625 if ((userName != null) && (userName.length() == 0)) {
626 repositoryCacheModel.userName = null;
627 }
628
629 Date createDate = getCreateDate();
630
631 if (createDate != null) {
632 repositoryCacheModel.createDate = createDate.getTime();
633 }
634 else {
635 repositoryCacheModel.createDate = Long.MIN_VALUE;
636 }
637
638 Date modifiedDate = getModifiedDate();
639
640 if (modifiedDate != null) {
641 repositoryCacheModel.modifiedDate = modifiedDate.getTime();
642 }
643 else {
644 repositoryCacheModel.modifiedDate = Long.MIN_VALUE;
645 }
646
647 repositoryCacheModel.classNameId = getClassNameId();
648
649 repositoryCacheModel.name = getName();
650
651 String name = repositoryCacheModel.name;
652
653 if ((name != null) && (name.length() == 0)) {
654 repositoryCacheModel.name = null;
655 }
656
657 repositoryCacheModel.description = getDescription();
658
659 String description = repositoryCacheModel.description;
660
661 if ((description != null) && (description.length() == 0)) {
662 repositoryCacheModel.description = null;
663 }
664
665 repositoryCacheModel.portletId = getPortletId();
666
667 String portletId = repositoryCacheModel.portletId;
668
669 if ((portletId != null) && (portletId.length() == 0)) {
670 repositoryCacheModel.portletId = null;
671 }
672
673 repositoryCacheModel.typeSettings = getTypeSettings();
674
675 String typeSettings = repositoryCacheModel.typeSettings;
676
677 if ((typeSettings != null) && (typeSettings.length() == 0)) {
678 repositoryCacheModel.typeSettings = null;
679 }
680
681 repositoryCacheModel.dlFolderId = getDlFolderId();
682
683 return repositoryCacheModel;
684 }
685
686 @Override
687 public String toString() {
688 StringBundler sb = new StringBundler(29);
689
690 sb.append("{uuid=");
691 sb.append(getUuid());
692 sb.append(", repositoryId=");
693 sb.append(getRepositoryId());
694 sb.append(", groupId=");
695 sb.append(getGroupId());
696 sb.append(", companyId=");
697 sb.append(getCompanyId());
698 sb.append(", userId=");
699 sb.append(getUserId());
700 sb.append(", userName=");
701 sb.append(getUserName());
702 sb.append(", createDate=");
703 sb.append(getCreateDate());
704 sb.append(", modifiedDate=");
705 sb.append(getModifiedDate());
706 sb.append(", classNameId=");
707 sb.append(getClassNameId());
708 sb.append(", name=");
709 sb.append(getName());
710 sb.append(", description=");
711 sb.append(getDescription());
712 sb.append(", portletId=");
713 sb.append(getPortletId());
714 sb.append(", typeSettings=");
715 sb.append(getTypeSettings());
716 sb.append(", dlFolderId=");
717 sb.append(getDlFolderId());
718 sb.append("}");
719
720 return sb.toString();
721 }
722
723 public String toXmlString() {
724 StringBundler sb = new StringBundler(46);
725
726 sb.append("<model><model-name>");
727 sb.append("com.liferay.portal.model.Repository");
728 sb.append("</model-name>");
729
730 sb.append(
731 "<column><column-name>uuid</column-name><column-value><![CDATA[");
732 sb.append(getUuid());
733 sb.append("]]></column-value></column>");
734 sb.append(
735 "<column><column-name>repositoryId</column-name><column-value><![CDATA[");
736 sb.append(getRepositoryId());
737 sb.append("]]></column-value></column>");
738 sb.append(
739 "<column><column-name>groupId</column-name><column-value><![CDATA[");
740 sb.append(getGroupId());
741 sb.append("]]></column-value></column>");
742 sb.append(
743 "<column><column-name>companyId</column-name><column-value><![CDATA[");
744 sb.append(getCompanyId());
745 sb.append("]]></column-value></column>");
746 sb.append(
747 "<column><column-name>userId</column-name><column-value><![CDATA[");
748 sb.append(getUserId());
749 sb.append("]]></column-value></column>");
750 sb.append(
751 "<column><column-name>userName</column-name><column-value><![CDATA[");
752 sb.append(getUserName());
753 sb.append("]]></column-value></column>");
754 sb.append(
755 "<column><column-name>createDate</column-name><column-value><![CDATA[");
756 sb.append(getCreateDate());
757 sb.append("]]></column-value></column>");
758 sb.append(
759 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
760 sb.append(getModifiedDate());
761 sb.append("]]></column-value></column>");
762 sb.append(
763 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
764 sb.append(getClassNameId());
765 sb.append("]]></column-value></column>");
766 sb.append(
767 "<column><column-name>name</column-name><column-value><![CDATA[");
768 sb.append(getName());
769 sb.append("]]></column-value></column>");
770 sb.append(
771 "<column><column-name>description</column-name><column-value><![CDATA[");
772 sb.append(getDescription());
773 sb.append("]]></column-value></column>");
774 sb.append(
775 "<column><column-name>portletId</column-name><column-value><![CDATA[");
776 sb.append(getPortletId());
777 sb.append("]]></column-value></column>");
778 sb.append(
779 "<column><column-name>typeSettings</column-name><column-value><![CDATA[");
780 sb.append(getTypeSettings());
781 sb.append("]]></column-value></column>");
782 sb.append(
783 "<column><column-name>dlFolderId</column-name><column-value><![CDATA[");
784 sb.append(getDlFolderId());
785 sb.append("]]></column-value></column>");
786
787 sb.append("</model>");
788
789 return sb.toString();
790 }
791
792 private static ClassLoader _classLoader = Repository.class.getClassLoader();
793 private static Class<?>[] _escapedModelInterfaces = new Class[] {
794 Repository.class
795 };
796 private String _uuid;
797 private String _originalUuid;
798 private long _repositoryId;
799 private long _groupId;
800 private long _originalGroupId;
801 private boolean _setOriginalGroupId;
802 private long _companyId;
803 private long _userId;
804 private String _userUuid;
805 private String _userName;
806 private Date _createDate;
807 private Date _modifiedDate;
808 private long _classNameId;
809 private String _name;
810 private String _description;
811 private String _portletId;
812 private String _typeSettings;
813 private long _dlFolderId;
814 private long _columnBitmask;
815 private Repository _escapedModel;
816 }