001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.json.JSON;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.ProxyUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.ResourcePermission;
025 import com.liferay.portal.model.ResourcePermissionModel;
026 import com.liferay.portal.model.ResourcePermissionSoap;
027 import com.liferay.portal.service.ServiceContext;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031
032 import java.io.Serializable;
033
034 import java.sql.Types;
035
036 import java.util.ArrayList;
037 import java.util.HashMap;
038 import java.util.List;
039 import java.util.Map;
040
041
054 @JSON(strict = true)
055 public class ResourcePermissionModelImpl extends BaseModelImpl<ResourcePermission>
056 implements ResourcePermissionModel {
057
062 public static final String TABLE_NAME = "ResourcePermission";
063 public static final Object[][] TABLE_COLUMNS = {
064 { "resourcePermissionId", Types.BIGINT },
065 { "companyId", Types.BIGINT },
066 { "name", Types.VARCHAR },
067 { "scope", Types.INTEGER },
068 { "primKey", Types.VARCHAR },
069 { "roleId", Types.BIGINT },
070 { "ownerId", Types.BIGINT },
071 { "actionIds", Types.BIGINT }
072 };
073 public static final String TABLE_SQL_CREATE = "create table ResourcePermission (resourcePermissionId LONG not null primary key,companyId LONG,name VARCHAR(255) null,scope INTEGER,primKey VARCHAR(255) null,roleId LONG,ownerId LONG,actionIds LONG)";
074 public static final String TABLE_SQL_DROP = "drop table ResourcePermission";
075 public static final String DATA_SOURCE = "liferayDataSource";
076 public static final String SESSION_FACTORY = "liferaySessionFactory";
077 public static final String TX_MANAGER = "liferayTransactionManager";
078 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079 "value.object.entity.cache.enabled.com.liferay.portal.model.ResourcePermission"),
080 true);
081 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082 "value.object.finder.cache.enabled.com.liferay.portal.model.ResourcePermission"),
083 true);
084 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085 "value.object.column.bitmask.enabled.com.liferay.portal.model.ResourcePermission"),
086 true);
087 public static long ACTIONIDS_COLUMN_BITMASK = 1L;
088 public static long COMPANYID_COLUMN_BITMASK = 2L;
089 public static long NAME_COLUMN_BITMASK = 4L;
090 public static long OWNERID_COLUMN_BITMASK = 8L;
091 public static long PRIMKEY_COLUMN_BITMASK = 16L;
092 public static long ROLEID_COLUMN_BITMASK = 32L;
093 public static long SCOPE_COLUMN_BITMASK = 64L;
094
095
101 public static ResourcePermission toModel(ResourcePermissionSoap soapModel) {
102 if (soapModel == null) {
103 return null;
104 }
105
106 ResourcePermission model = new ResourcePermissionImpl();
107
108 model.setResourcePermissionId(soapModel.getResourcePermissionId());
109 model.setCompanyId(soapModel.getCompanyId());
110 model.setName(soapModel.getName());
111 model.setScope(soapModel.getScope());
112 model.setPrimKey(soapModel.getPrimKey());
113 model.setRoleId(soapModel.getRoleId());
114 model.setOwnerId(soapModel.getOwnerId());
115 model.setActionIds(soapModel.getActionIds());
116
117 return model;
118 }
119
120
126 public static List<ResourcePermission> toModels(
127 ResourcePermissionSoap[] soapModels) {
128 if (soapModels == null) {
129 return null;
130 }
131
132 List<ResourcePermission> models = new ArrayList<ResourcePermission>(soapModels.length);
133
134 for (ResourcePermissionSoap soapModel : soapModels) {
135 models.add(toModel(soapModel));
136 }
137
138 return models;
139 }
140
141 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
142 "lock.expiration.time.com.liferay.portal.model.ResourcePermission"));
143
144 public ResourcePermissionModelImpl() {
145 }
146
147 public long getPrimaryKey() {
148 return _resourcePermissionId;
149 }
150
151 public void setPrimaryKey(long primaryKey) {
152 setResourcePermissionId(primaryKey);
153 }
154
155 public Serializable getPrimaryKeyObj() {
156 return new Long(_resourcePermissionId);
157 }
158
159 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
160 setPrimaryKey(((Long)primaryKeyObj).longValue());
161 }
162
163 public Class<?> getModelClass() {
164 return ResourcePermission.class;
165 }
166
167 public String getModelClassName() {
168 return ResourcePermission.class.getName();
169 }
170
171 @Override
172 public Map<String, Object> getModelAttributes() {
173 Map<String, Object> attributes = new HashMap<String, Object>();
174
175 attributes.put("resourcePermissionId", getResourcePermissionId());
176 attributes.put("companyId", getCompanyId());
177 attributes.put("name", getName());
178 attributes.put("scope", getScope());
179 attributes.put("primKey", getPrimKey());
180 attributes.put("roleId", getRoleId());
181 attributes.put("ownerId", getOwnerId());
182 attributes.put("actionIds", getActionIds());
183
184 return attributes;
185 }
186
187 @Override
188 public void setModelAttributes(Map<String, Object> attributes) {
189 Long resourcePermissionId = (Long)attributes.get("resourcePermissionId");
190
191 if (resourcePermissionId != null) {
192 setResourcePermissionId(resourcePermissionId);
193 }
194
195 Long companyId = (Long)attributes.get("companyId");
196
197 if (companyId != null) {
198 setCompanyId(companyId);
199 }
200
201 String name = (String)attributes.get("name");
202
203 if (name != null) {
204 setName(name);
205 }
206
207 Integer scope = (Integer)attributes.get("scope");
208
209 if (scope != null) {
210 setScope(scope);
211 }
212
213 String primKey = (String)attributes.get("primKey");
214
215 if (primKey != null) {
216 setPrimKey(primKey);
217 }
218
219 Long roleId = (Long)attributes.get("roleId");
220
221 if (roleId != null) {
222 setRoleId(roleId);
223 }
224
225 Long ownerId = (Long)attributes.get("ownerId");
226
227 if (ownerId != null) {
228 setOwnerId(ownerId);
229 }
230
231 Long actionIds = (Long)attributes.get("actionIds");
232
233 if (actionIds != null) {
234 setActionIds(actionIds);
235 }
236 }
237
238 @JSON
239 public long getResourcePermissionId() {
240 return _resourcePermissionId;
241 }
242
243 public void setResourcePermissionId(long resourcePermissionId) {
244 _resourcePermissionId = resourcePermissionId;
245 }
246
247 @JSON
248 public long getCompanyId() {
249 return _companyId;
250 }
251
252 public void setCompanyId(long companyId) {
253 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
254
255 if (!_setOriginalCompanyId) {
256 _setOriginalCompanyId = true;
257
258 _originalCompanyId = _companyId;
259 }
260
261 _companyId = companyId;
262 }
263
264 public long getOriginalCompanyId() {
265 return _originalCompanyId;
266 }
267
268 @JSON
269 public String getName() {
270 if (_name == null) {
271 return StringPool.BLANK;
272 }
273 else {
274 return _name;
275 }
276 }
277
278 public void setName(String name) {
279 _columnBitmask |= NAME_COLUMN_BITMASK;
280
281 if (_originalName == null) {
282 _originalName = _name;
283 }
284
285 _name = name;
286 }
287
288 public String getOriginalName() {
289 return GetterUtil.getString(_originalName);
290 }
291
292 @JSON
293 public int getScope() {
294 return _scope;
295 }
296
297 public void setScope(int scope) {
298 _columnBitmask |= SCOPE_COLUMN_BITMASK;
299
300 if (!_setOriginalScope) {
301 _setOriginalScope = true;
302
303 _originalScope = _scope;
304 }
305
306 _scope = scope;
307 }
308
309 public int getOriginalScope() {
310 return _originalScope;
311 }
312
313 @JSON
314 public String getPrimKey() {
315 if (_primKey == null) {
316 return StringPool.BLANK;
317 }
318 else {
319 return _primKey;
320 }
321 }
322
323 public void setPrimKey(String primKey) {
324 _columnBitmask |= PRIMKEY_COLUMN_BITMASK;
325
326 if (_originalPrimKey == null) {
327 _originalPrimKey = _primKey;
328 }
329
330 _primKey = primKey;
331 }
332
333 public String getOriginalPrimKey() {
334 return GetterUtil.getString(_originalPrimKey);
335 }
336
337 @JSON
338 public long getRoleId() {
339 return _roleId;
340 }
341
342 public void setRoleId(long roleId) {
343 _columnBitmask |= ROLEID_COLUMN_BITMASK;
344
345 if (!_setOriginalRoleId) {
346 _setOriginalRoleId = true;
347
348 _originalRoleId = _roleId;
349 }
350
351 _roleId = roleId;
352 }
353
354 public long getOriginalRoleId() {
355 return _originalRoleId;
356 }
357
358 @JSON
359 public long getOwnerId() {
360 return _ownerId;
361 }
362
363 public void setOwnerId(long ownerId) {
364 _columnBitmask |= OWNERID_COLUMN_BITMASK;
365
366 if (!_setOriginalOwnerId) {
367 _setOriginalOwnerId = true;
368
369 _originalOwnerId = _ownerId;
370 }
371
372 _ownerId = ownerId;
373 }
374
375 public long getOriginalOwnerId() {
376 return _originalOwnerId;
377 }
378
379 @JSON
380 public long getActionIds() {
381 return _actionIds;
382 }
383
384 public void setActionIds(long actionIds) {
385 _columnBitmask |= ACTIONIDS_COLUMN_BITMASK;
386
387 if (!_setOriginalActionIds) {
388 _setOriginalActionIds = true;
389
390 _originalActionIds = _actionIds;
391 }
392
393 _actionIds = actionIds;
394 }
395
396 public long getOriginalActionIds() {
397 return _originalActionIds;
398 }
399
400 public long getColumnBitmask() {
401 return _columnBitmask;
402 }
403
404 @Override
405 public ExpandoBridge getExpandoBridge() {
406 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
407 ResourcePermission.class.getName(), getPrimaryKey());
408 }
409
410 @Override
411 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
412 ExpandoBridge expandoBridge = getExpandoBridge();
413
414 expandoBridge.setAttributes(serviceContext);
415 }
416
417 @Override
418 public ResourcePermission toEscapedModel() {
419 if (_escapedModel == null) {
420 _escapedModel = (ResourcePermission)ProxyUtil.newProxyInstance(_classLoader,
421 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
422 }
423
424 return _escapedModel;
425 }
426
427 public ResourcePermission toUnescapedModel() {
428 return (ResourcePermission)this;
429 }
430
431 @Override
432 public Object clone() {
433 ResourcePermissionImpl resourcePermissionImpl = new ResourcePermissionImpl();
434
435 resourcePermissionImpl.setResourcePermissionId(getResourcePermissionId());
436 resourcePermissionImpl.setCompanyId(getCompanyId());
437 resourcePermissionImpl.setName(getName());
438 resourcePermissionImpl.setScope(getScope());
439 resourcePermissionImpl.setPrimKey(getPrimKey());
440 resourcePermissionImpl.setRoleId(getRoleId());
441 resourcePermissionImpl.setOwnerId(getOwnerId());
442 resourcePermissionImpl.setActionIds(getActionIds());
443
444 resourcePermissionImpl.resetOriginalValues();
445
446 return resourcePermissionImpl;
447 }
448
449 public int compareTo(ResourcePermission resourcePermission) {
450 long primaryKey = resourcePermission.getPrimaryKey();
451
452 if (getPrimaryKey() < primaryKey) {
453 return -1;
454 }
455 else if (getPrimaryKey() > primaryKey) {
456 return 1;
457 }
458 else {
459 return 0;
460 }
461 }
462
463 @Override
464 public boolean equals(Object obj) {
465 if (this == obj) {
466 return true;
467 }
468
469 if (!(obj instanceof ResourcePermission)) {
470 return false;
471 }
472
473 ResourcePermission resourcePermission = (ResourcePermission)obj;
474
475 long primaryKey = resourcePermission.getPrimaryKey();
476
477 if (getPrimaryKey() == primaryKey) {
478 return true;
479 }
480 else {
481 return false;
482 }
483 }
484
485 @Override
486 public int hashCode() {
487 return (int)getPrimaryKey();
488 }
489
490 @Override
491 public void resetOriginalValues() {
492 ResourcePermissionModelImpl resourcePermissionModelImpl = this;
493
494 resourcePermissionModelImpl._originalCompanyId = resourcePermissionModelImpl._companyId;
495
496 resourcePermissionModelImpl._setOriginalCompanyId = false;
497
498 resourcePermissionModelImpl._originalName = resourcePermissionModelImpl._name;
499
500 resourcePermissionModelImpl._originalScope = resourcePermissionModelImpl._scope;
501
502 resourcePermissionModelImpl._setOriginalScope = false;
503
504 resourcePermissionModelImpl._originalPrimKey = resourcePermissionModelImpl._primKey;
505
506 resourcePermissionModelImpl._originalRoleId = resourcePermissionModelImpl._roleId;
507
508 resourcePermissionModelImpl._setOriginalRoleId = false;
509
510 resourcePermissionModelImpl._originalOwnerId = resourcePermissionModelImpl._ownerId;
511
512 resourcePermissionModelImpl._setOriginalOwnerId = false;
513
514 resourcePermissionModelImpl._originalActionIds = resourcePermissionModelImpl._actionIds;
515
516 resourcePermissionModelImpl._setOriginalActionIds = false;
517
518 resourcePermissionModelImpl._columnBitmask = 0;
519 }
520
521 @Override
522 public CacheModel<ResourcePermission> toCacheModel() {
523 ResourcePermissionCacheModel resourcePermissionCacheModel = new ResourcePermissionCacheModel();
524
525 resourcePermissionCacheModel.resourcePermissionId = getResourcePermissionId();
526
527 resourcePermissionCacheModel.companyId = getCompanyId();
528
529 resourcePermissionCacheModel.name = getName();
530
531 String name = resourcePermissionCacheModel.name;
532
533 if ((name != null) && (name.length() == 0)) {
534 resourcePermissionCacheModel.name = null;
535 }
536
537 resourcePermissionCacheModel.scope = getScope();
538
539 resourcePermissionCacheModel.primKey = getPrimKey();
540
541 String primKey = resourcePermissionCacheModel.primKey;
542
543 if ((primKey != null) && (primKey.length() == 0)) {
544 resourcePermissionCacheModel.primKey = null;
545 }
546
547 resourcePermissionCacheModel.roleId = getRoleId();
548
549 resourcePermissionCacheModel.ownerId = getOwnerId();
550
551 resourcePermissionCacheModel.actionIds = getActionIds();
552
553 return resourcePermissionCacheModel;
554 }
555
556 @Override
557 public String toString() {
558 StringBundler sb = new StringBundler(17);
559
560 sb.append("{resourcePermissionId=");
561 sb.append(getResourcePermissionId());
562 sb.append(", companyId=");
563 sb.append(getCompanyId());
564 sb.append(", name=");
565 sb.append(getName());
566 sb.append(", scope=");
567 sb.append(getScope());
568 sb.append(", primKey=");
569 sb.append(getPrimKey());
570 sb.append(", roleId=");
571 sb.append(getRoleId());
572 sb.append(", ownerId=");
573 sb.append(getOwnerId());
574 sb.append(", actionIds=");
575 sb.append(getActionIds());
576 sb.append("}");
577
578 return sb.toString();
579 }
580
581 public String toXmlString() {
582 StringBundler sb = new StringBundler(28);
583
584 sb.append("<model><model-name>");
585 sb.append("com.liferay.portal.model.ResourcePermission");
586 sb.append("</model-name>");
587
588 sb.append(
589 "<column><column-name>resourcePermissionId</column-name><column-value><![CDATA[");
590 sb.append(getResourcePermissionId());
591 sb.append("]]></column-value></column>");
592 sb.append(
593 "<column><column-name>companyId</column-name><column-value><![CDATA[");
594 sb.append(getCompanyId());
595 sb.append("]]></column-value></column>");
596 sb.append(
597 "<column><column-name>name</column-name><column-value><![CDATA[");
598 sb.append(getName());
599 sb.append("]]></column-value></column>");
600 sb.append(
601 "<column><column-name>scope</column-name><column-value><![CDATA[");
602 sb.append(getScope());
603 sb.append("]]></column-value></column>");
604 sb.append(
605 "<column><column-name>primKey</column-name><column-value><![CDATA[");
606 sb.append(getPrimKey());
607 sb.append("]]></column-value></column>");
608 sb.append(
609 "<column><column-name>roleId</column-name><column-value><![CDATA[");
610 sb.append(getRoleId());
611 sb.append("]]></column-value></column>");
612 sb.append(
613 "<column><column-name>ownerId</column-name><column-value><![CDATA[");
614 sb.append(getOwnerId());
615 sb.append("]]></column-value></column>");
616 sb.append(
617 "<column><column-name>actionIds</column-name><column-value><![CDATA[");
618 sb.append(getActionIds());
619 sb.append("]]></column-value></column>");
620
621 sb.append("</model>");
622
623 return sb.toString();
624 }
625
626 private static ClassLoader _classLoader = ResourcePermission.class.getClassLoader();
627 private static Class<?>[] _escapedModelInterfaces = new Class[] {
628 ResourcePermission.class
629 };
630 private long _resourcePermissionId;
631 private long _companyId;
632 private long _originalCompanyId;
633 private boolean _setOriginalCompanyId;
634 private String _name;
635 private String _originalName;
636 private int _scope;
637 private int _originalScope;
638 private boolean _setOriginalScope;
639 private String _primKey;
640 private String _originalPrimKey;
641 private long _roleId;
642 private long _originalRoleId;
643 private boolean _setOriginalRoleId;
644 private long _ownerId;
645 private long _originalOwnerId;
646 private boolean _setOriginalOwnerId;
647 private long _actionIds;
648 private long _originalActionIds;
649 private boolean _setOriginalActionIds;
650 private long _columnBitmask;
651 private ResourcePermission _escapedModel;
652 }