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            @Override
090            public long getPrimaryKey() {
091                    return _resourceActionId;
092            }
093    
094            @Override
095            public void setPrimaryKey(long primaryKey) {
096                    setResourceActionId(primaryKey);
097            }
098    
099            @Override
100            public Serializable getPrimaryKeyObj() {
101                    return _resourceActionId;
102            }
103    
104            @Override
105            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
106                    setPrimaryKey(((Long)primaryKeyObj).longValue());
107            }
108    
109            @Override
110            public Class<?> getModelClass() {
111                    return ResourceAction.class;
112            }
113    
114            @Override
115            public String getModelClassName() {
116                    return ResourceAction.class.getName();
117            }
118    
119            @Override
120            public Map<String, Object> getModelAttributes() {
121                    Map<String, Object> attributes = new HashMap<String, Object>();
122    
123                    attributes.put("resourceActionId", getResourceActionId());
124                    attributes.put("name", getName());
125                    attributes.put("actionId", getActionId());
126                    attributes.put("bitwiseValue", getBitwiseValue());
127    
128                    return attributes;
129            }
130    
131            @Override
132            public void setModelAttributes(Map<String, Object> attributes) {
133                    Long resourceActionId = (Long)attributes.get("resourceActionId");
134    
135                    if (resourceActionId != null) {
136                            setResourceActionId(resourceActionId);
137                    }
138    
139                    String name = (String)attributes.get("name");
140    
141                    if (name != null) {
142                            setName(name);
143                    }
144    
145                    String actionId = (String)attributes.get("actionId");
146    
147                    if (actionId != null) {
148                            setActionId(actionId);
149                    }
150    
151                    Long bitwiseValue = (Long)attributes.get("bitwiseValue");
152    
153                    if (bitwiseValue != null) {
154                            setBitwiseValue(bitwiseValue);
155                    }
156            }
157    
158            @Override
159            public long getResourceActionId() {
160                    return _resourceActionId;
161            }
162    
163            @Override
164            public void setResourceActionId(long resourceActionId) {
165                    _resourceActionId = resourceActionId;
166            }
167    
168            @Override
169            public String getName() {
170                    if (_name == null) {
171                            return StringPool.BLANK;
172                    }
173                    else {
174                            return _name;
175                    }
176            }
177    
178            @Override
179            public void setName(String name) {
180                    _columnBitmask = -1L;
181    
182                    if (_originalName == null) {
183                            _originalName = _name;
184                    }
185    
186                    _name = name;
187            }
188    
189            public String getOriginalName() {
190                    return GetterUtil.getString(_originalName);
191            }
192    
193            @Override
194            public String getActionId() {
195                    if (_actionId == null) {
196                            return StringPool.BLANK;
197                    }
198                    else {
199                            return _actionId;
200                    }
201            }
202    
203            @Override
204            public void setActionId(String actionId) {
205                    _columnBitmask |= ACTIONID_COLUMN_BITMASK;
206    
207                    if (_originalActionId == null) {
208                            _originalActionId = _actionId;
209                    }
210    
211                    _actionId = actionId;
212            }
213    
214            public String getOriginalActionId() {
215                    return GetterUtil.getString(_originalActionId);
216            }
217    
218            @Override
219            public long getBitwiseValue() {
220                    return _bitwiseValue;
221            }
222    
223            @Override
224            public void setBitwiseValue(long bitwiseValue) {
225                    _columnBitmask = -1L;
226    
227                    _bitwiseValue = bitwiseValue;
228            }
229    
230            public long getColumnBitmask() {
231                    return _columnBitmask;
232            }
233    
234            @Override
235            public ExpandoBridge getExpandoBridge() {
236                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
237                            ResourceAction.class.getName(), getPrimaryKey());
238            }
239    
240            @Override
241            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
242                    ExpandoBridge expandoBridge = getExpandoBridge();
243    
244                    expandoBridge.setAttributes(serviceContext);
245            }
246    
247            @Override
248            public ResourceAction toEscapedModel() {
249                    if (_escapedModel == null) {
250                            _escapedModel = (ResourceAction)ProxyUtil.newProxyInstance(_classLoader,
251                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
252                    }
253    
254                    return _escapedModel;
255            }
256    
257            @Override
258            public Object clone() {
259                    ResourceActionImpl resourceActionImpl = new ResourceActionImpl();
260    
261                    resourceActionImpl.setResourceActionId(getResourceActionId());
262                    resourceActionImpl.setName(getName());
263                    resourceActionImpl.setActionId(getActionId());
264                    resourceActionImpl.setBitwiseValue(getBitwiseValue());
265    
266                    resourceActionImpl.resetOriginalValues();
267    
268                    return resourceActionImpl;
269            }
270    
271            @Override
272            public int compareTo(ResourceAction resourceAction) {
273                    int value = 0;
274    
275                    value = getName().compareTo(resourceAction.getName());
276    
277                    if (value != 0) {
278                            return value;
279                    }
280    
281                    if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
282                            value = -1;
283                    }
284                    else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
285                            value = 1;
286                    }
287                    else {
288                            value = 0;
289                    }
290    
291                    if (value != 0) {
292                            return value;
293                    }
294    
295                    return 0;
296            }
297    
298            @Override
299            public boolean equals(Object obj) {
300                    if (this == obj) {
301                            return true;
302                    }
303    
304                    if (!(obj instanceof ResourceAction)) {
305                            return false;
306                    }
307    
308                    ResourceAction resourceAction = (ResourceAction)obj;
309    
310                    long primaryKey = resourceAction.getPrimaryKey();
311    
312                    if (getPrimaryKey() == primaryKey) {
313                            return true;
314                    }
315                    else {
316                            return false;
317                    }
318            }
319    
320            @Override
321            public int hashCode() {
322                    return (int)getPrimaryKey();
323            }
324    
325            @Override
326            public void resetOriginalValues() {
327                    ResourceActionModelImpl resourceActionModelImpl = this;
328    
329                    resourceActionModelImpl._originalName = resourceActionModelImpl._name;
330    
331                    resourceActionModelImpl._originalActionId = resourceActionModelImpl._actionId;
332    
333                    resourceActionModelImpl._columnBitmask = 0;
334            }
335    
336            @Override
337            public CacheModel<ResourceAction> toCacheModel() {
338                    ResourceActionCacheModel resourceActionCacheModel = new ResourceActionCacheModel();
339    
340                    resourceActionCacheModel.resourceActionId = getResourceActionId();
341    
342                    resourceActionCacheModel.name = getName();
343    
344                    String name = resourceActionCacheModel.name;
345    
346                    if ((name != null) && (name.length() == 0)) {
347                            resourceActionCacheModel.name = null;
348                    }
349    
350                    resourceActionCacheModel.actionId = getActionId();
351    
352                    String actionId = resourceActionCacheModel.actionId;
353    
354                    if ((actionId != null) && (actionId.length() == 0)) {
355                            resourceActionCacheModel.actionId = null;
356                    }
357    
358                    resourceActionCacheModel.bitwiseValue = getBitwiseValue();
359    
360                    return resourceActionCacheModel;
361            }
362    
363            @Override
364            public String toString() {
365                    StringBundler sb = new StringBundler(9);
366    
367                    sb.append("{resourceActionId=");
368                    sb.append(getResourceActionId());
369                    sb.append(", name=");
370                    sb.append(getName());
371                    sb.append(", actionId=");
372                    sb.append(getActionId());
373                    sb.append(", bitwiseValue=");
374                    sb.append(getBitwiseValue());
375                    sb.append("}");
376    
377                    return sb.toString();
378            }
379    
380            @Override
381            public String toXmlString() {
382                    StringBundler sb = new StringBundler(16);
383    
384                    sb.append("<model><model-name>");
385                    sb.append("com.liferay.portal.model.ResourceAction");
386                    sb.append("</model-name>");
387    
388                    sb.append(
389                            "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
390                    sb.append(getResourceActionId());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>name</column-name><column-value><![CDATA[");
394                    sb.append(getName());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>actionId</column-name><column-value><![CDATA[");
398                    sb.append(getActionId());
399                    sb.append("]]></column-value></column>");
400                    sb.append(
401                            "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
402                    sb.append(getBitwiseValue());
403                    sb.append("]]></column-value></column>");
404    
405                    sb.append("</model>");
406    
407                    return sb.toString();
408            }
409    
410            private static ClassLoader _classLoader = ResourceAction.class.getClassLoader();
411            private static Class<?>[] _escapedModelInterfaces = new Class[] {
412                            ResourceAction.class
413                    };
414            private long _resourceActionId;
415            private String _name;
416            private String _originalName;
417            private String _actionId;
418            private String _originalActionId;
419            private long _bitwiseValue;
420            private long _columnBitmask;
421            private ResourceAction _escapedModel;
422    }