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