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.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.ResourceAction;
022    import com.liferay.portal.model.ResourceActionModel;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    
028    import java.io.Serializable;
029    
030    import java.lang.reflect.Proxy;
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     * <p>
042     * 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.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see ResourceActionImpl
047     * @see com.liferay.portal.model.ResourceAction
048     * @see com.liferay.portal.model.ResourceActionModel
049     * @generated
050     */
051    public class ResourceActionModelImpl extends BaseModelImpl<ResourceAction>
052            implements ResourceActionModel {
053            public static final String TABLE_NAME = "ResourceAction";
054            public static final Object[][] TABLE_COLUMNS = {
055                            { "resourceActionId", new Integer(Types.BIGINT) },
056                            { "name", new Integer(Types.VARCHAR) },
057                            { "actionId", new Integer(Types.VARCHAR) },
058                            { "bitwiseValue", new Integer(Types.BIGINT) }
059                    };
060            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)";
061            public static final String TABLE_SQL_DROP = "drop table ResourceAction";
062            public static final String ORDER_BY_JPQL = " ORDER BY resourceAction.name ASC, resourceAction.bitwiseValue ASC";
063            public static final String ORDER_BY_SQL = " ORDER BY ResourceAction.name ASC, ResourceAction.bitwiseValue ASC";
064            public static final String DATA_SOURCE = "liferayDataSource";
065            public static final String SESSION_FACTORY = "liferaySessionFactory";
066            public static final String TX_MANAGER = "liferayTransactionManager";
067            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
068                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceAction"),
069                            true);
070            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
071                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceAction"),
072                            true);
073            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
074                                    "lock.expiration.time.com.liferay.portal.model.ResourceAction"));
075    
076            public ResourceActionModelImpl() {
077            }
078    
079            public long getPrimaryKey() {
080                    return _resourceActionId;
081            }
082    
083            public void setPrimaryKey(long pk) {
084                    setResourceActionId(pk);
085            }
086    
087            public Serializable getPrimaryKeyObj() {
088                    return new Long(_resourceActionId);
089            }
090    
091            public long getResourceActionId() {
092                    return _resourceActionId;
093            }
094    
095            public void setResourceActionId(long resourceActionId) {
096                    _resourceActionId = resourceActionId;
097            }
098    
099            public String getName() {
100                    if (_name == null) {
101                            return StringPool.BLANK;
102                    }
103                    else {
104                            return _name;
105                    }
106            }
107    
108            public void setName(String name) {
109                    if (_originalName == null) {
110                            _originalName = _name;
111                    }
112    
113                    _name = name;
114            }
115    
116            public String getOriginalName() {
117                    return GetterUtil.getString(_originalName);
118            }
119    
120            public String getActionId() {
121                    if (_actionId == null) {
122                            return StringPool.BLANK;
123                    }
124                    else {
125                            return _actionId;
126                    }
127            }
128    
129            public void setActionId(String actionId) {
130                    if (_originalActionId == null) {
131                            _originalActionId = _actionId;
132                    }
133    
134                    _actionId = actionId;
135            }
136    
137            public String getOriginalActionId() {
138                    return GetterUtil.getString(_originalActionId);
139            }
140    
141            public long getBitwiseValue() {
142                    return _bitwiseValue;
143            }
144    
145            public void setBitwiseValue(long bitwiseValue) {
146                    _bitwiseValue = bitwiseValue;
147            }
148    
149            public ResourceAction toEscapedModel() {
150                    if (isEscapedModel()) {
151                            return (ResourceAction)this;
152                    }
153                    else {
154                            return (ResourceAction)Proxy.newProxyInstance(ResourceAction.class.getClassLoader(),
155                                    new Class[] { ResourceAction.class },
156                                    new AutoEscapeBeanHandler(this));
157                    }
158            }
159    
160            public ExpandoBridge getExpandoBridge() {
161                    if (_expandoBridge == null) {
162                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
163                                            ResourceAction.class.getName(), getPrimaryKey());
164                    }
165    
166                    return _expandoBridge;
167            }
168    
169            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
170                    getExpandoBridge().setAttributes(serviceContext);
171            }
172    
173            public Object clone() {
174                    ResourceActionImpl resourceActionImpl = new ResourceActionImpl();
175    
176                    resourceActionImpl.setResourceActionId(getResourceActionId());
177    
178                    resourceActionImpl.setName(getName());
179    
180                    ResourceActionModelImpl resourceActionModelImpl = resourceActionImpl;
181    
182                    resourceActionModelImpl._originalName = resourceActionModelImpl._name;
183    
184                    resourceActionImpl.setActionId(getActionId());
185    
186                    resourceActionModelImpl._originalActionId = resourceActionModelImpl._actionId;
187    
188                    resourceActionImpl.setBitwiseValue(getBitwiseValue());
189    
190                    return resourceActionImpl;
191            }
192    
193            public int compareTo(ResourceAction resourceAction) {
194                    int value = 0;
195    
196                    value = getName().compareTo(resourceAction.getName());
197    
198                    if (value != 0) {
199                            return value;
200                    }
201    
202                    if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
203                            value = -1;
204                    }
205                    else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
206                            value = 1;
207                    }
208                    else {
209                            value = 0;
210                    }
211    
212                    if (value != 0) {
213                            return value;
214                    }
215    
216                    return 0;
217            }
218    
219            public boolean equals(Object obj) {
220                    if (obj == null) {
221                            return false;
222                    }
223    
224                    ResourceAction resourceAction = null;
225    
226                    try {
227                            resourceAction = (ResourceAction)obj;
228                    }
229                    catch (ClassCastException cce) {
230                            return false;
231                    }
232    
233                    long pk = resourceAction.getPrimaryKey();
234    
235                    if (getPrimaryKey() == pk) {
236                            return true;
237                    }
238                    else {
239                            return false;
240                    }
241            }
242    
243            public int hashCode() {
244                    return (int)getPrimaryKey();
245            }
246    
247            public String toString() {
248                    StringBundler sb = new StringBundler(9);
249    
250                    sb.append("{resourceActionId=");
251                    sb.append(getResourceActionId());
252                    sb.append(", name=");
253                    sb.append(getName());
254                    sb.append(", actionId=");
255                    sb.append(getActionId());
256                    sb.append(", bitwiseValue=");
257                    sb.append(getBitwiseValue());
258                    sb.append("}");
259    
260                    return sb.toString();
261            }
262    
263            public String toXmlString() {
264                    StringBundler sb = new StringBundler(16);
265    
266                    sb.append("<model><model-name>");
267                    sb.append("com.liferay.portal.model.ResourceAction");
268                    sb.append("</model-name>");
269    
270                    sb.append(
271                            "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
272                    sb.append(getResourceActionId());
273                    sb.append("]]></column-value></column>");
274                    sb.append(
275                            "<column><column-name>name</column-name><column-value><![CDATA[");
276                    sb.append(getName());
277                    sb.append("]]></column-value></column>");
278                    sb.append(
279                            "<column><column-name>actionId</column-name><column-value><![CDATA[");
280                    sb.append(getActionId());
281                    sb.append("]]></column-value></column>");
282                    sb.append(
283                            "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
284                    sb.append(getBitwiseValue());
285                    sb.append("]]></column-value></column>");
286    
287                    sb.append("</model>");
288    
289                    return sb.toString();
290            }
291    
292            private long _resourceActionId;
293            private String _name;
294            private String _originalName;
295            private String _actionId;
296            private String _originalActionId;
297            private long _bitwiseValue;
298            private transient ExpandoBridge _expandoBridge;
299    }