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