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