001    /**
002     * Copyright (c) 2000-2010 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                    _name = name;
110    
111                    if (_originalName == null) {
112                            _originalName = name;
113                    }
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                    _actionId = actionId;
131    
132                    if (_originalActionId == null) {
133                            _originalActionId = actionId;
134                    }
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 clone = new ResourceActionImpl();
175    
176                    clone.setResourceActionId(getResourceActionId());
177                    clone.setName(getName());
178                    clone.setActionId(getActionId());
179                    clone.setBitwiseValue(getBitwiseValue());
180    
181                    return clone;
182            }
183    
184            public int compareTo(ResourceAction resourceAction) {
185                    int value = 0;
186    
187                    value = getName().compareTo(resourceAction.getName());
188    
189                    if (value != 0) {
190                            return value;
191                    }
192    
193                    if (getBitwiseValue() < resourceAction.getBitwiseValue()) {
194                            value = -1;
195                    }
196                    else if (getBitwiseValue() > resourceAction.getBitwiseValue()) {
197                            value = 1;
198                    }
199                    else {
200                            value = 0;
201                    }
202    
203                    if (value != 0) {
204                            return value;
205                    }
206    
207                    return 0;
208            }
209    
210            public boolean equals(Object obj) {
211                    if (obj == null) {
212                            return false;
213                    }
214    
215                    ResourceAction resourceAction = null;
216    
217                    try {
218                            resourceAction = (ResourceAction)obj;
219                    }
220                    catch (ClassCastException cce) {
221                            return false;
222                    }
223    
224                    long pk = resourceAction.getPrimaryKey();
225    
226                    if (getPrimaryKey() == pk) {
227                            return true;
228                    }
229                    else {
230                            return false;
231                    }
232            }
233    
234            public int hashCode() {
235                    return (int)getPrimaryKey();
236            }
237    
238            public String toString() {
239                    StringBundler sb = new StringBundler(9);
240    
241                    sb.append("{resourceActionId=");
242                    sb.append(getResourceActionId());
243                    sb.append(", name=");
244                    sb.append(getName());
245                    sb.append(", actionId=");
246                    sb.append(getActionId());
247                    sb.append(", bitwiseValue=");
248                    sb.append(getBitwiseValue());
249                    sb.append("}");
250    
251                    return sb.toString();
252            }
253    
254            public String toXmlString() {
255                    StringBundler sb = new StringBundler(16);
256    
257                    sb.append("<model><model-name>");
258                    sb.append("com.liferay.portal.model.ResourceAction");
259                    sb.append("</model-name>");
260    
261                    sb.append(
262                            "<column><column-name>resourceActionId</column-name><column-value><![CDATA[");
263                    sb.append(getResourceActionId());
264                    sb.append("]]></column-value></column>");
265                    sb.append(
266                            "<column><column-name>name</column-name><column-value><![CDATA[");
267                    sb.append(getName());
268                    sb.append("]]></column-value></column>");
269                    sb.append(
270                            "<column><column-name>actionId</column-name><column-value><![CDATA[");
271                    sb.append(getActionId());
272                    sb.append("]]></column-value></column>");
273                    sb.append(
274                            "<column><column-name>bitwiseValue</column-name><column-value><![CDATA[");
275                    sb.append(getBitwiseValue());
276                    sb.append("]]></column-value></column>");
277    
278                    sb.append("</model>");
279    
280                    return sb.toString();
281            }
282    
283            private long _resourceActionId;
284            private String _name;
285            private String _originalName;
286            private String _actionId;
287            private String _originalActionId;
288            private long _bitwiseValue;
289            private transient ExpandoBridge _expandoBridge;
290    }