001    /**
002     * Copyright (c) 2000-2011 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 |= NAME_COLUMN_BITMASK;
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                    _bitwiseValue = bitwiseValue;
169            }
170    
171            public long getColumnBitmask() {
172                    return _columnBitmask;
173            }
174    
175            @Override
176            public ResourceAction toEscapedModel() {
177                    if (_escapedModelProxy == null) {
178                            _escapedModelProxy = (ResourceAction)ProxyUtil.newProxyInstance(_classLoader,
179                                            _escapedModelProxyInterfaces,
180                                            new AutoEscapeBeanHandler(this));
181                    }
182    
183                    return _escapedModelProxy;
184            }
185    
186            @Override
187            public ExpandoBridge getExpandoBridge() {
188                    if (_expandoBridge == null) {
189                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
190                                            ResourceAction.class.getName(), getPrimaryKey());
191                    }
192    
193                    return _expandoBridge;
194            }
195    
196            @Override
197            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
198                    getExpandoBridge().setAttributes(serviceContext);
199            }
200    
201            @Override
202            public Object clone() {
203                    ResourceActionImpl resourceActionImpl = new ResourceActionImpl();
204    
205                    resourceActionImpl.setResourceActionId(getResourceActionId());
206                    resourceActionImpl.setName(getName());
207                    resourceActionImpl.setActionId(getActionId());
208                    resourceActionImpl.setBitwiseValue(getBitwiseValue());
209    
210                    resourceActionImpl.resetOriginalValues();
211    
212                    return resourceActionImpl;
213            }
214    
215            public int compareTo(ResourceAction resourceAction) {
216                    int value = 0;
217    
218                    value = getName().compareTo(resourceAction.getName());
219    
220                    if (value != 0) {
221                            return value;
222                    }
223    
224                    if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
225                            value = -1;
226                    }
227                    else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
228                            value = 1;
229                    }
230                    else {
231                            value = 0;
232                    }
233    
234                    if (value != 0) {
235                            return value;
236                    }
237    
238                    return 0;
239            }
240    
241            @Override
242            public boolean equals(Object obj) {
243                    if (obj == null) {
244                            return false;
245                    }
246    
247                    ResourceAction resourceAction = null;
248    
249                    try {
250                            resourceAction = (ResourceAction)obj;
251                    }
252                    catch (ClassCastException cce) {
253                            return false;
254                    }
255    
256                    long primaryKey = resourceAction.getPrimaryKey();
257    
258                    if (getPrimaryKey() == primaryKey) {
259                            return true;
260                    }
261                    else {
262                            return false;
263                    }
264            }
265    
266            @Override
267            public int hashCode() {
268                    return (int)getPrimaryKey();
269            }
270    
271            @Override
272            public void resetOriginalValues() {
273                    ResourceActionModelImpl resourceActionModelImpl = this;
274    
275                    resourceActionModelImpl._originalName = resourceActionModelImpl._name;
276    
277                    resourceActionModelImpl._originalActionId = resourceActionModelImpl._actionId;
278    
279                    resourceActionModelImpl._columnBitmask = 0;
280            }
281    
282            @Override
283            public CacheModel<ResourceAction> toCacheModel() {
284                    ResourceActionCacheModel resourceActionCacheModel = new ResourceActionCacheModel();
285    
286                    resourceActionCacheModel.resourceActionId = getResourceActionId();
287    
288                    resourceActionCacheModel.name = getName();
289    
290                    String name = resourceActionCacheModel.name;
291    
292                    if ((name != null) && (name.length() == 0)) {
293                            resourceActionCacheModel.name = null;
294                    }
295    
296                    resourceActionCacheModel.actionId = getActionId();
297    
298                    String actionId = resourceActionCacheModel.actionId;
299    
300                    if ((actionId != null) && (actionId.length() == 0)) {
301                            resourceActionCacheModel.actionId = null;
302                    }
303    
304                    resourceActionCacheModel.bitwiseValue = getBitwiseValue();
305    
306                    return resourceActionCacheModel;
307            }
308    
309            @Override
310            public String toString() {
311                    StringBundler sb = new StringBundler(9);
312    
313                    sb.append("{resourceActionId=");
314                    sb.append(getResourceActionId());
315                    sb.append(", name=");
316                    sb.append(getName());
317                    sb.append(", actionId=");
318                    sb.append(getActionId());
319                    sb.append(", bitwiseValue=");
320                    sb.append(getBitwiseValue());
321                    sb.append("}");
322    
323                    return sb.toString();
324            }
325    
326            public String toXmlString() {
327                    StringBundler sb = new StringBundler(16);
328    
329                    sb.append("<model><model-name>");
330                    sb.append("com.liferay.portal.model.ResourceAction");
331                    sb.append("</model-name>");
332    
333                    sb.append(
334                            "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
335                    sb.append(getResourceActionId());
336                    sb.append("]]></column-value></column>");
337                    sb.append(
338                            "<column><column-name>name</column-name><column-value><![CDATA[");
339                    sb.append(getName());
340                    sb.append("]]></column-value></column>");
341                    sb.append(
342                            "<column><column-name>actionId</column-name><column-value><![CDATA[");
343                    sb.append(getActionId());
344                    sb.append("]]></column-value></column>");
345                    sb.append(
346                            "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
347                    sb.append(getBitwiseValue());
348                    sb.append("]]></column-value></column>");
349    
350                    sb.append("</model>");
351    
352                    return sb.toString();
353            }
354    
355            private static ClassLoader _classLoader = ResourceAction.class.getClassLoader();
356            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
357                            ResourceAction.class
358                    };
359            private long _resourceActionId;
360            private String _name;
361            private String _originalName;
362            private String _actionId;
363            private String _originalActionId;
364            private long _bitwiseValue;
365            private transient ExpandoBridge _expandoBridge;
366            private long _columnBitmask;
367            private ResourceAction _escapedModelProxy;
368    }