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