001    /**
002     * Copyright (c) 2000-2012 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.ResourceAction;
024    import com.liferay.portal.model.ResourceActionModel;
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    /**
035     * 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.
036     *
037     * <p>
038     * This implementation and its corresponding interface {@link com.liferay.portal.model.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}.
039     * </p>
040     *
041     * @author Brian Wing Shun Chan
042     * @see ResourceActionImpl
043     * @see com.liferay.portal.model.ResourceAction
044     * @see com.liferay.portal.model.ResourceActionModel
045     * @generated
046     */
047    public class ResourceActionModelImpl extends BaseModelImpl<ResourceAction>
048            implements ResourceActionModel {
049            /*
050             * NOTE FOR DEVELOPERS:
051             *
052             * Never modify or reference this class directly. All methods that expect a resource action model instance should use the {@link com.liferay.portal.model.ResourceAction} interface instead.
053             */
054            public static final String TABLE_NAME = "ResourceAction";
055            public static final Object[][] TABLE_COLUMNS = {
056                            { "resourceActionId", Types.BIGINT },
057                            { "name", Types.VARCHAR },
058                            { "actionId", Types.VARCHAR },
059                            { "bitwiseValue", Types.BIGINT }
060                    };
061            public static final String TABLE_SQL_CREATE = "create table ResourceAction (resourceActionId LONG not null primary key,name VARCHAR(255) null,actionId VARCHAR(75) null,bitwiseValue LONG)";
062            public static final String TABLE_SQL_DROP = "drop table ResourceAction";
063            public static final String ORDER_BY_JPQL = " ORDER BY resourceAction.name ASC, resourceAction.bitwiseValue ASC";
064            public static final String ORDER_BY_SQL = " ORDER BY ResourceAction.name ASC, ResourceAction.bitwiseValue ASC";
065            public static final String DATA_SOURCE = "liferayDataSource";
066            public static final String SESSION_FACTORY = "liferaySessionFactory";
067            public static final String TX_MANAGER = "liferayTransactionManager";
068            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceAction"),
070                            true);
071            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceAction"),
073                            true);
074            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.ResourceAction"),
076                            true);
077            public static long ACTIONID_COLUMN_BITMASK = 1L;
078            public static long NAME_COLUMN_BITMASK = 2L;
079            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
080                                    "lock.expiration.time.com.liferay.portal.model.ResourceAction"));
081    
082            public ResourceActionModelImpl() {
083            }
084    
085            public long getPrimaryKey() {
086                    return _resourceActionId;
087            }
088    
089            public void setPrimaryKey(long primaryKey) {
090                    setResourceActionId(primaryKey);
091            }
092    
093            public Serializable getPrimaryKeyObj() {
094                    return new Long(_resourceActionId);
095            }
096    
097            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
098                    setPrimaryKey(((Long)primaryKeyObj).longValue());
099            }
100    
101            public Class<?> getModelClass() {
102                    return ResourceAction.class;
103            }
104    
105            public String getModelClassName() {
106                    return ResourceAction.class.getName();
107            }
108    
109            public long getResourceActionId() {
110                    return _resourceActionId;
111            }
112    
113            public void setResourceActionId(long resourceActionId) {
114                    _resourceActionId = resourceActionId;
115            }
116    
117            public String getName() {
118                    if (_name == null) {
119                            return StringPool.BLANK;
120                    }
121                    else {
122                            return _name;
123                    }
124            }
125    
126            public void setName(String name) {
127                    _columnBitmask = -1L;
128    
129                    if (_originalName == null) {
130                            _originalName = _name;
131                    }
132    
133                    _name = name;
134            }
135    
136            public String getOriginalName() {
137                    return GetterUtil.getString(_originalName);
138            }
139    
140            public String getActionId() {
141                    if (_actionId == null) {
142                            return StringPool.BLANK;
143                    }
144                    else {
145                            return _actionId;
146                    }
147            }
148    
149            public void setActionId(String actionId) {
150                    _columnBitmask |= ACTIONID_COLUMN_BITMASK;
151    
152                    if (_originalActionId == null) {
153                            _originalActionId = _actionId;
154                    }
155    
156                    _actionId = actionId;
157            }
158    
159            public String getOriginalActionId() {
160                    return GetterUtil.getString(_originalActionId);
161            }
162    
163            public long getBitwiseValue() {
164                    return _bitwiseValue;
165            }
166    
167            public void setBitwiseValue(long bitwiseValue) {
168                    _columnBitmask = -1L;
169    
170                    _bitwiseValue = bitwiseValue;
171            }
172    
173            public long getColumnBitmask() {
174                    return _columnBitmask;
175            }
176    
177            @Override
178            public ResourceAction toEscapedModel() {
179                    if (_escapedModelProxy == null) {
180                            _escapedModelProxy = (ResourceAction)ProxyUtil.newProxyInstance(_classLoader,
181                                            _escapedModelProxyInterfaces,
182                                            new AutoEscapeBeanHandler(this));
183                    }
184    
185                    return _escapedModelProxy;
186            }
187    
188            @Override
189            public ExpandoBridge getExpandoBridge() {
190                    if (_expandoBridge == null) {
191                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
192                                            ResourceAction.class.getName(), getPrimaryKey());
193                    }
194    
195                    return _expandoBridge;
196            }
197    
198            @Override
199            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
200                    getExpandoBridge().setAttributes(serviceContext);
201            }
202    
203            @Override
204            public Object clone() {
205                    ResourceActionImpl resourceActionImpl = new ResourceActionImpl();
206    
207                    resourceActionImpl.setResourceActionId(getResourceActionId());
208                    resourceActionImpl.setName(getName());
209                    resourceActionImpl.setActionId(getActionId());
210                    resourceActionImpl.setBitwiseValue(getBitwiseValue());
211    
212                    resourceActionImpl.resetOriginalValues();
213    
214                    return resourceActionImpl;
215            }
216    
217            public int compareTo(ResourceAction resourceAction) {
218                    int value = 0;
219    
220                    value = getName().compareTo(resourceAction.getName());
221    
222                    if (value != 0) {
223                            return value;
224                    }
225    
226                    if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
227                            value = -1;
228                    }
229                    else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
230                            value = 1;
231                    }
232                    else {
233                            value = 0;
234                    }
235    
236                    if (value != 0) {
237                            return value;
238                    }
239    
240                    return 0;
241            }
242    
243            @Override
244            public boolean equals(Object obj) {
245                    if (obj == null) {
246                            return false;
247                    }
248    
249                    ResourceAction resourceAction = null;
250    
251                    try {
252                            resourceAction = (ResourceAction)obj;
253                    }
254                    catch (ClassCastException cce) {
255                            return false;
256                    }
257    
258                    long primaryKey = resourceAction.getPrimaryKey();
259    
260                    if (getPrimaryKey() == primaryKey) {
261                            return true;
262                    }
263                    else {
264                            return false;
265                    }
266            }
267    
268            @Override
269            public int hashCode() {
270                    return (int)getPrimaryKey();
271            }
272    
273            @Override
274            public void resetOriginalValues() {
275                    ResourceActionModelImpl resourceActionModelImpl = this;
276    
277                    resourceActionModelImpl._originalName = resourceActionModelImpl._name;
278    
279                    resourceActionModelImpl._originalActionId = resourceActionModelImpl._actionId;
280    
281                    resourceActionModelImpl._columnBitmask = 0;
282            }
283    
284            @Override
285            public CacheModel<ResourceAction> toCacheModel() {
286                    ResourceActionCacheModel resourceActionCacheModel = new ResourceActionCacheModel();
287    
288                    resourceActionCacheModel.resourceActionId = getResourceActionId();
289    
290                    resourceActionCacheModel.name = getName();
291    
292                    String name = resourceActionCacheModel.name;
293    
294                    if ((name != null) && (name.length() == 0)) {
295                            resourceActionCacheModel.name = null;
296                    }
297    
298                    resourceActionCacheModel.actionId = getActionId();
299    
300                    String actionId = resourceActionCacheModel.actionId;
301    
302                    if ((actionId != null) && (actionId.length() == 0)) {
303                            resourceActionCacheModel.actionId = null;
304                    }
305    
306                    resourceActionCacheModel.bitwiseValue = getBitwiseValue();
307    
308                    return resourceActionCacheModel;
309            }
310    
311            @Override
312            public String toString() {
313                    StringBundler sb = new StringBundler(9);
314    
315                    sb.append("{resourceActionId=");
316                    sb.append(getResourceActionId());
317                    sb.append(", name=");
318                    sb.append(getName());
319                    sb.append(", actionId=");
320                    sb.append(getActionId());
321                    sb.append(", bitwiseValue=");
322                    sb.append(getBitwiseValue());
323                    sb.append("}");
324    
325                    return sb.toString();
326            }
327    
328            public String toXmlString() {
329                    StringBundler sb = new StringBundler(16);
330    
331                    sb.append("<model><model-name>");
332                    sb.append("com.liferay.portal.model.ResourceAction");
333                    sb.append("</model-name>");
334    
335                    sb.append(
336                            "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
337                    sb.append(getResourceActionId());
338                    sb.append("]]></column-value></column>");
339                    sb.append(
340                            "<column><column-name>name</column-name><column-value><![CDATA[");
341                    sb.append(getName());
342                    sb.append("]]></column-value></column>");
343                    sb.append(
344                            "<column><column-name>actionId</column-name><column-value><![CDATA[");
345                    sb.append(getActionId());
346                    sb.append("]]></column-value></column>");
347                    sb.append(
348                            "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
349                    sb.append(getBitwiseValue());
350                    sb.append("]]></column-value></column>");
351    
352                    sb.append("</model>");
353    
354                    return sb.toString();
355            }
356    
357            private static ClassLoader _classLoader = ResourceAction.class.getClassLoader();
358            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
359                            ResourceAction.class
360                    };
361            private long _resourceActionId;
362            private String _name;
363            private String _originalName;
364            private String _actionId;
365            private String _originalActionId;
366            private long _bitwiseValue;
367            private transient ExpandoBridge _expandoBridge;
368            private long _columnBitmask;
369            private ResourceAction _escapedModelProxy;
370    }