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