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 final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
083                                    "lock.expiration.time.com.liferay.portal.model.ResourceAction"));
084    
085            public ResourceActionModelImpl() {
086            }
087    
088            public long getPrimaryKey() {
089                    return _resourceActionId;
090            }
091    
092            public void setPrimaryKey(long primaryKey) {
093                    setResourceActionId(primaryKey);
094            }
095    
096            public Serializable getPrimaryKeyObj() {
097                    return new Long(_resourceActionId);
098            }
099    
100            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
101                    setPrimaryKey(((Long)primaryKeyObj).longValue());
102            }
103    
104            public Class<?> getModelClass() {
105                    return ResourceAction.class;
106            }
107    
108            public String getModelClassName() {
109                    return ResourceAction.class.getName();
110            }
111    
112            @Override
113            public Map<String, Object> getModelAttributes() {
114                    Map<String, Object> attributes = new HashMap<String, Object>();
115    
116                    attributes.put("resourceActionId", getResourceActionId());
117                    attributes.put("name", getName());
118                    attributes.put("actionId", getActionId());
119                    attributes.put("bitwiseValue", getBitwiseValue());
120    
121                    return attributes;
122            }
123    
124            @Override
125            public void setModelAttributes(Map<String, Object> attributes) {
126                    Long resourceActionId = (Long)attributes.get("resourceActionId");
127    
128                    if (resourceActionId != null) {
129                            setResourceActionId(resourceActionId);
130                    }
131    
132                    String name = (String)attributes.get("name");
133    
134                    if (name != null) {
135                            setName(name);
136                    }
137    
138                    String actionId = (String)attributes.get("actionId");
139    
140                    if (actionId != null) {
141                            setActionId(actionId);
142                    }
143    
144                    Long bitwiseValue = (Long)attributes.get("bitwiseValue");
145    
146                    if (bitwiseValue != null) {
147                            setBitwiseValue(bitwiseValue);
148                    }
149            }
150    
151            public long getResourceActionId() {
152                    return _resourceActionId;
153            }
154    
155            public void setResourceActionId(long resourceActionId) {
156                    _resourceActionId = resourceActionId;
157            }
158    
159            public String getName() {
160                    if (_name == null) {
161                            return StringPool.BLANK;
162                    }
163                    else {
164                            return _name;
165                    }
166            }
167    
168            public void setName(String name) {
169                    _columnBitmask = -1L;
170    
171                    if (_originalName == null) {
172                            _originalName = _name;
173                    }
174    
175                    _name = name;
176            }
177    
178            public String getOriginalName() {
179                    return GetterUtil.getString(_originalName);
180            }
181    
182            public String getActionId() {
183                    if (_actionId == null) {
184                            return StringPool.BLANK;
185                    }
186                    else {
187                            return _actionId;
188                    }
189            }
190    
191            public void setActionId(String actionId) {
192                    _columnBitmask |= ACTIONID_COLUMN_BITMASK;
193    
194                    if (_originalActionId == null) {
195                            _originalActionId = _actionId;
196                    }
197    
198                    _actionId = actionId;
199            }
200    
201            public String getOriginalActionId() {
202                    return GetterUtil.getString(_originalActionId);
203            }
204    
205            public long getBitwiseValue() {
206                    return _bitwiseValue;
207            }
208    
209            public void setBitwiseValue(long bitwiseValue) {
210                    _columnBitmask = -1L;
211    
212                    _bitwiseValue = bitwiseValue;
213            }
214    
215            public long getColumnBitmask() {
216                    return _columnBitmask;
217            }
218    
219            @Override
220            public ExpandoBridge getExpandoBridge() {
221                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
222                            ResourceAction.class.getName(), getPrimaryKey());
223            }
224    
225            @Override
226            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
227                    ExpandoBridge expandoBridge = getExpandoBridge();
228    
229                    expandoBridge.setAttributes(serviceContext);
230            }
231    
232            @Override
233            public ResourceAction toEscapedModel() {
234                    if (_escapedModel == null) {
235                            _escapedModel = (ResourceAction)ProxyUtil.newProxyInstance(_classLoader,
236                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
237                    }
238    
239                    return _escapedModel;
240            }
241    
242            public ResourceAction toUnescapedModel() {
243                    return (ResourceAction)this;
244            }
245    
246            @Override
247            public Object clone() {
248                    ResourceActionImpl resourceActionImpl = new ResourceActionImpl();
249    
250                    resourceActionImpl.setResourceActionId(getResourceActionId());
251                    resourceActionImpl.setName(getName());
252                    resourceActionImpl.setActionId(getActionId());
253                    resourceActionImpl.setBitwiseValue(getBitwiseValue());
254    
255                    resourceActionImpl.resetOriginalValues();
256    
257                    return resourceActionImpl;
258            }
259    
260            public int compareTo(ResourceAction resourceAction) {
261                    int value = 0;
262    
263                    value = getName().compareTo(resourceAction.getName());
264    
265                    if (value != 0) {
266                            return value;
267                    }
268    
269                    if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
270                            value = -1;
271                    }
272                    else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
273                            value = 1;
274                    }
275                    else {
276                            value = 0;
277                    }
278    
279                    if (value != 0) {
280                            return value;
281                    }
282    
283                    return 0;
284            }
285    
286            @Override
287            public boolean equals(Object obj) {
288                    if (this == obj) {
289                            return true;
290                    }
291    
292                    if (!(obj instanceof ResourceAction)) {
293                            return false;
294                    }
295    
296                    ResourceAction resourceAction = (ResourceAction)obj;
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    }