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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.ResourceTypePermission;
024    import com.liferay.portal.model.ResourceTypePermissionModel;
025    import com.liferay.portal.service.ServiceContext;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.sql.Types;
033    
034    import java.util.HashMap;
035    import java.util.Map;
036    
037    /**
038     * The base model implementation for the ResourceTypePermission service. Represents a row in the "ResourceTypePermission" database table, with each column mapped to a property of this class.
039     *
040     * <p>
041     * This implementation and its corresponding interface {@link com.liferay.portal.model.ResourceTypePermissionModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ResourceTypePermissionImpl}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see ResourceTypePermissionImpl
046     * @see com.liferay.portal.model.ResourceTypePermission
047     * @see com.liferay.portal.model.ResourceTypePermissionModel
048     * @generated
049     */
050    public class ResourceTypePermissionModelImpl extends BaseModelImpl<ResourceTypePermission>
051            implements ResourceTypePermissionModel {
052            /*
053             * NOTE FOR DEVELOPERS:
054             *
055             * Never modify or reference this class directly. All methods that expect a resource type permission model instance should use the {@link com.liferay.portal.model.ResourceTypePermission} interface instead.
056             */
057            public static final String TABLE_NAME = "ResourceTypePermission";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "resourceTypePermissionId", Types.BIGINT },
060                            { "companyId", Types.BIGINT },
061                            { "groupId", Types.BIGINT },
062                            { "name", Types.VARCHAR },
063                            { "roleId", Types.BIGINT },
064                            { "actionIds", Types.BIGINT }
065                    };
066            public static final String TABLE_SQL_CREATE = "create table ResourceTypePermission (resourceTypePermissionId LONG not null primary key,companyId LONG,groupId LONG,name VARCHAR(75) null,roleId LONG,actionIds LONG)";
067            public static final String TABLE_SQL_DROP = "drop table ResourceTypePermission";
068            public static final String ORDER_BY_JPQL = " ORDER BY resourceTypePermission.resourceTypePermissionId ASC";
069            public static final String ORDER_BY_SQL = " ORDER BY ResourceTypePermission.resourceTypePermissionId ASC";
070            public static final String DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceTypePermission"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceTypePermission"),
078                            true);
079            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.ResourceTypePermission"),
081                            true);
082            public static long COMPANYID_COLUMN_BITMASK = 1L;
083            public static long GROUPID_COLUMN_BITMASK = 2L;
084            public static long NAME_COLUMN_BITMASK = 4L;
085            public static long ROLEID_COLUMN_BITMASK = 8L;
086            public static long RESOURCETYPEPERMISSIONID_COLUMN_BITMASK = 16L;
087            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
088                                    "lock.expiration.time.com.liferay.portal.model.ResourceTypePermission"));
089    
090            public ResourceTypePermissionModelImpl() {
091            }
092    
093            @Override
094            public long getPrimaryKey() {
095                    return _resourceTypePermissionId;
096            }
097    
098            @Override
099            public void setPrimaryKey(long primaryKey) {
100                    setResourceTypePermissionId(primaryKey);
101            }
102    
103            @Override
104            public Serializable getPrimaryKeyObj() {
105                    return _resourceTypePermissionId;
106            }
107    
108            @Override
109            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
110                    setPrimaryKey(((Long)primaryKeyObj).longValue());
111            }
112    
113            @Override
114            public Class<?> getModelClass() {
115                    return ResourceTypePermission.class;
116            }
117    
118            @Override
119            public String getModelClassName() {
120                    return ResourceTypePermission.class.getName();
121            }
122    
123            @Override
124            public Map<String, Object> getModelAttributes() {
125                    Map<String, Object> attributes = new HashMap<String, Object>();
126    
127                    attributes.put("resourceTypePermissionId", getResourceTypePermissionId());
128                    attributes.put("companyId", getCompanyId());
129                    attributes.put("groupId", getGroupId());
130                    attributes.put("name", getName());
131                    attributes.put("roleId", getRoleId());
132                    attributes.put("actionIds", getActionIds());
133    
134                    return attributes;
135            }
136    
137            @Override
138            public void setModelAttributes(Map<String, Object> attributes) {
139                    Long resourceTypePermissionId = (Long)attributes.get(
140                                    "resourceTypePermissionId");
141    
142                    if (resourceTypePermissionId != null) {
143                            setResourceTypePermissionId(resourceTypePermissionId);
144                    }
145    
146                    Long companyId = (Long)attributes.get("companyId");
147    
148                    if (companyId != null) {
149                            setCompanyId(companyId);
150                    }
151    
152                    Long groupId = (Long)attributes.get("groupId");
153    
154                    if (groupId != null) {
155                            setGroupId(groupId);
156                    }
157    
158                    String name = (String)attributes.get("name");
159    
160                    if (name != null) {
161                            setName(name);
162                    }
163    
164                    Long roleId = (Long)attributes.get("roleId");
165    
166                    if (roleId != null) {
167                            setRoleId(roleId);
168                    }
169    
170                    Long actionIds = (Long)attributes.get("actionIds");
171    
172                    if (actionIds != null) {
173                            setActionIds(actionIds);
174                    }
175            }
176    
177            @Override
178            public long getResourceTypePermissionId() {
179                    return _resourceTypePermissionId;
180            }
181    
182            @Override
183            public void setResourceTypePermissionId(long resourceTypePermissionId) {
184                    _resourceTypePermissionId = resourceTypePermissionId;
185            }
186    
187            @Override
188            public long getCompanyId() {
189                    return _companyId;
190            }
191    
192            @Override
193            public void setCompanyId(long companyId) {
194                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
195    
196                    if (!_setOriginalCompanyId) {
197                            _setOriginalCompanyId = true;
198    
199                            _originalCompanyId = _companyId;
200                    }
201    
202                    _companyId = companyId;
203            }
204    
205            public long getOriginalCompanyId() {
206                    return _originalCompanyId;
207            }
208    
209            @Override
210            public long getGroupId() {
211                    return _groupId;
212            }
213    
214            @Override
215            public void setGroupId(long groupId) {
216                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
217    
218                    if (!_setOriginalGroupId) {
219                            _setOriginalGroupId = true;
220    
221                            _originalGroupId = _groupId;
222                    }
223    
224                    _groupId = groupId;
225            }
226    
227            public long getOriginalGroupId() {
228                    return _originalGroupId;
229            }
230    
231            @Override
232            public String getName() {
233                    if (_name == null) {
234                            return StringPool.BLANK;
235                    }
236                    else {
237                            return _name;
238                    }
239            }
240    
241            @Override
242            public void setName(String name) {
243                    _columnBitmask |= NAME_COLUMN_BITMASK;
244    
245                    if (_originalName == null) {
246                            _originalName = _name;
247                    }
248    
249                    _name = name;
250            }
251    
252            public String getOriginalName() {
253                    return GetterUtil.getString(_originalName);
254            }
255    
256            @Override
257            public long getRoleId() {
258                    return _roleId;
259            }
260    
261            @Override
262            public void setRoleId(long roleId) {
263                    _columnBitmask |= ROLEID_COLUMN_BITMASK;
264    
265                    if (!_setOriginalRoleId) {
266                            _setOriginalRoleId = true;
267    
268                            _originalRoleId = _roleId;
269                    }
270    
271                    _roleId = roleId;
272            }
273    
274            public long getOriginalRoleId() {
275                    return _originalRoleId;
276            }
277    
278            @Override
279            public long getActionIds() {
280                    return _actionIds;
281            }
282    
283            @Override
284            public void setActionIds(long actionIds) {
285                    _actionIds = actionIds;
286            }
287    
288            public long getColumnBitmask() {
289                    return _columnBitmask;
290            }
291    
292            @Override
293            public ExpandoBridge getExpandoBridge() {
294                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
295                            ResourceTypePermission.class.getName(), getPrimaryKey());
296            }
297    
298            @Override
299            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
300                    ExpandoBridge expandoBridge = getExpandoBridge();
301    
302                    expandoBridge.setAttributes(serviceContext);
303            }
304    
305            @Override
306            public ResourceTypePermission toEscapedModel() {
307                    if (_escapedModel == null) {
308                            _escapedModel = (ResourceTypePermission)ProxyUtil.newProxyInstance(_classLoader,
309                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
310                    }
311    
312                    return _escapedModel;
313            }
314    
315            @Override
316            public Object clone() {
317                    ResourceTypePermissionImpl resourceTypePermissionImpl = new ResourceTypePermissionImpl();
318    
319                    resourceTypePermissionImpl.setResourceTypePermissionId(getResourceTypePermissionId());
320                    resourceTypePermissionImpl.setCompanyId(getCompanyId());
321                    resourceTypePermissionImpl.setGroupId(getGroupId());
322                    resourceTypePermissionImpl.setName(getName());
323                    resourceTypePermissionImpl.setRoleId(getRoleId());
324                    resourceTypePermissionImpl.setActionIds(getActionIds());
325    
326                    resourceTypePermissionImpl.resetOriginalValues();
327    
328                    return resourceTypePermissionImpl;
329            }
330    
331            @Override
332            public int compareTo(ResourceTypePermission resourceTypePermission) {
333                    long primaryKey = resourceTypePermission.getPrimaryKey();
334    
335                    if (getPrimaryKey() < primaryKey) {
336                            return -1;
337                    }
338                    else if (getPrimaryKey() > primaryKey) {
339                            return 1;
340                    }
341                    else {
342                            return 0;
343                    }
344            }
345    
346            @Override
347            public boolean equals(Object obj) {
348                    if (this == obj) {
349                            return true;
350                    }
351    
352                    if (!(obj instanceof ResourceTypePermission)) {
353                            return false;
354                    }
355    
356                    ResourceTypePermission resourceTypePermission = (ResourceTypePermission)obj;
357    
358                    long primaryKey = resourceTypePermission.getPrimaryKey();
359    
360                    if (getPrimaryKey() == primaryKey) {
361                            return true;
362                    }
363                    else {
364                            return false;
365                    }
366            }
367    
368            @Override
369            public int hashCode() {
370                    return (int)getPrimaryKey();
371            }
372    
373            @Override
374            public void resetOriginalValues() {
375                    ResourceTypePermissionModelImpl resourceTypePermissionModelImpl = this;
376    
377                    resourceTypePermissionModelImpl._originalCompanyId = resourceTypePermissionModelImpl._companyId;
378    
379                    resourceTypePermissionModelImpl._setOriginalCompanyId = false;
380    
381                    resourceTypePermissionModelImpl._originalGroupId = resourceTypePermissionModelImpl._groupId;
382    
383                    resourceTypePermissionModelImpl._setOriginalGroupId = false;
384    
385                    resourceTypePermissionModelImpl._originalName = resourceTypePermissionModelImpl._name;
386    
387                    resourceTypePermissionModelImpl._originalRoleId = resourceTypePermissionModelImpl._roleId;
388    
389                    resourceTypePermissionModelImpl._setOriginalRoleId = false;
390    
391                    resourceTypePermissionModelImpl._columnBitmask = 0;
392            }
393    
394            @Override
395            public CacheModel<ResourceTypePermission> toCacheModel() {
396                    ResourceTypePermissionCacheModel resourceTypePermissionCacheModel = new ResourceTypePermissionCacheModel();
397    
398                    resourceTypePermissionCacheModel.resourceTypePermissionId = getResourceTypePermissionId();
399    
400                    resourceTypePermissionCacheModel.companyId = getCompanyId();
401    
402                    resourceTypePermissionCacheModel.groupId = getGroupId();
403    
404                    resourceTypePermissionCacheModel.name = getName();
405    
406                    String name = resourceTypePermissionCacheModel.name;
407    
408                    if ((name != null) && (name.length() == 0)) {
409                            resourceTypePermissionCacheModel.name = null;
410                    }
411    
412                    resourceTypePermissionCacheModel.roleId = getRoleId();
413    
414                    resourceTypePermissionCacheModel.actionIds = getActionIds();
415    
416                    return resourceTypePermissionCacheModel;
417            }
418    
419            @Override
420            public String toString() {
421                    StringBundler sb = new StringBundler(13);
422    
423                    sb.append("{resourceTypePermissionId=");
424                    sb.append(getResourceTypePermissionId());
425                    sb.append(", companyId=");
426                    sb.append(getCompanyId());
427                    sb.append(", groupId=");
428                    sb.append(getGroupId());
429                    sb.append(", name=");
430                    sb.append(getName());
431                    sb.append(", roleId=");
432                    sb.append(getRoleId());
433                    sb.append(", actionIds=");
434                    sb.append(getActionIds());
435                    sb.append("}");
436    
437                    return sb.toString();
438            }
439    
440            @Override
441            public String toXmlString() {
442                    StringBundler sb = new StringBundler(22);
443    
444                    sb.append("<model><model-name>");
445                    sb.append("com.liferay.portal.model.ResourceTypePermission");
446                    sb.append("</model-name>");
447    
448                    sb.append(
449                            "<column><column-name>resourceTypePermissionId</column-name><column-value><![CDATA[");
450                    sb.append(getResourceTypePermissionId());
451                    sb.append("]]></column-value></column>");
452                    sb.append(
453                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
454                    sb.append(getCompanyId());
455                    sb.append("]]></column-value></column>");
456                    sb.append(
457                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
458                    sb.append(getGroupId());
459                    sb.append("]]></column-value></column>");
460                    sb.append(
461                            "<column><column-name>name</column-name><column-value><![CDATA[");
462                    sb.append(getName());
463                    sb.append("]]></column-value></column>");
464                    sb.append(
465                            "<column><column-name>roleId</column-name><column-value><![CDATA[");
466                    sb.append(getRoleId());
467                    sb.append("]]></column-value></column>");
468                    sb.append(
469                            "<column><column-name>actionIds</column-name><column-value><![CDATA[");
470                    sb.append(getActionIds());
471                    sb.append("]]></column-value></column>");
472    
473                    sb.append("</model>");
474    
475                    return sb.toString();
476            }
477    
478            private static ClassLoader _classLoader = ResourceTypePermission.class.getClassLoader();
479            private static Class<?>[] _escapedModelInterfaces = new Class[] {
480                            ResourceTypePermission.class
481                    };
482            private long _resourceTypePermissionId;
483            private long _companyId;
484            private long _originalCompanyId;
485            private boolean _setOriginalCompanyId;
486            private long _groupId;
487            private long _originalGroupId;
488            private boolean _setOriginalGroupId;
489            private String _name;
490            private String _originalName;
491            private long _roleId;
492            private long _originalRoleId;
493            private boolean _setOriginalRoleId;
494            private long _actionIds;
495            private long _columnBitmask;
496            private ResourceTypePermission _escapedModel;
497    }